Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Clickhouse Schemas #150

Merged
merged 4 commits into from
Dec 6, 2024
Merged

Add Clickhouse Schemas #150

merged 4 commits into from
Dec 6, 2024

Conversation

marcus-snx
Copy link
Collaborator

@marcus-snx marcus-snx commented Dec 6, 2024

  • generate schemas based on event ABIs
  • save schemas to file system (right now in /parquet-data/indexers/schemas/{network_name}/{protocol_name}/{table_name}.sql)

@marcus-snx marcus-snx added the wip Work in progress label Dec 6, 2024
@Tburm
Copy link
Collaborator

Tburm commented Dec 6, 2024

@marcus-snx how do we use these schemas to define the raw tables? Does this get included somehow when we define sources in dbt? I wouldn't think we need the CREATE TABLE statements, but let me know where these will eventually go.

@marcus-snx
Copy link
Collaborator Author

@Tburm

@marcus-snx how do we use these schemas to define the raw tables? Does this get included somehow when we define sources in dbt? I wouldn't think we need the CREATE TABLE statements, but let me know where these will eventually go.

These schemas get saved locally and are called when we start the indexer, and the (empty) tables get created in ClickHouse. Then, when the listener detects new data, it will insert it into these tables.

@marcus-snx
Copy link
Collaborator Author

These tables are then used as sources in dbt.

@Tburm
Copy link
Collaborator

Tburm commented Dec 6, 2024

Won't this result in these CREATE TABLE statements not being written and checked into dbt though? I would think we want to do something like define these types in a sql file that gets stored, or in the sources.yml file.

For example, what happens if an ABI suddenly changes and has one more field? It will create a new sql file, but it won't run because the table already exists.

@marcus-snx
Copy link
Collaborator Author

Won't this result in these CREATE TABLE statements not being written and checked into dbt though? I would think we want to do something like define these types in a sql file that gets stored, or in the sources.yml file.

For example, what happens if an ABI suddenly changes and has one more field? It will create a new sql file, but it won't run because the table already exists.

We would need to handle such migrations (for example by checking if a generated schema differs from an existing schema), but I think this would still be handled outside dbt?

@Tburm Tburm merged commit 8af713c into main-v2 Dec 6, 2024
1 check passed
@Tburm Tburm deleted the feat/clickhouse-schemas branch December 6, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants