-
Notifications
You must be signed in to change notification settings - Fork 25
Add null engine table implementation #3029
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
base: main
Are you sure you want to change the base?
Changes from all commits
1f2b7ca
ef633d4
5d180ef
175ac2e
11517f5
01c19eb
3dcbf7c
88ef238
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,6 +393,16 @@ impl ClickHouseTableDiffStrategy { | |
| // Skip population in production (user must handle manually) | ||
| // Only populate in dev for new MVs with non-S3Queue sources | ||
| if is_new && !has_s3queue_source && !is_production { | ||
| // If the target table uses the Null engine, skip truncation because there's nothing to truncate | ||
| let target_is_null_engine = tables.values().any(|table| { | ||
| matches!(table.engine, ClickhouseEngine::Null) | ||
| && Self::table_matches_mv_target( | ||
| table, | ||
| &mv_stmt.target_table, | ||
| &mv_stmt.target_database, | ||
| ) | ||
| }); | ||
|
|
||
| log::info!( | ||
| "Adding population operation for materialized view '{}'", | ||
| sql_resource.name | ||
|
|
@@ -408,7 +418,7 @@ impl ClickHouseTableDiffStrategy { | |
| .into_iter() | ||
| .map(|t| t.qualified_name()) | ||
| .collect(), | ||
| should_truncate: true, | ||
| should_truncate: !target_is_null_engine, | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -417,6 +427,30 @@ impl ClickHouseTableDiffStrategy { | |
| } | ||
| } | ||
| } | ||
|
|
||
| /// Helper: does the given table correspond to the MV target (by name and optional database)? | ||
| fn table_matches_mv_target( | ||
| table: &Table, | ||
| target_table: &str, | ||
| target_database: &Option<String>, | ||
| ) -> bool { | ||
| if table.name == target_table { | ||
| return true; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Table matching ignores database when names matchThe |
||
|
|
||
| match (&table.database, target_database) { | ||
| (Some(table_db), Some(target_db)) => { | ||
| table_db == target_db && table.name == target_table | ||
| || format!("{table_db}.{}", table.name) == format!("{target_db}.{target_table}") | ||
| } | ||
| (Some(table_db), None) => table_db.is_empty() && table.name == target_table, | ||
| (None, Some(target_db)) => { | ||
| format!("{target_db}.{target_table}") == table.name | ||
| || format!("{target_db}.{}", table.name) == target_table | ||
| } | ||
| _ => false, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl TableDiffStrategy for ClickHouseTableDiffStrategy { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.