perf: allow V1 incremental path to skip config change metadata queries#1403
Open
moomindani wants to merge 2 commits intodatabricks:mainfrom
Open
perf: allow V1 incremental path to skip config change metadata queries#1403moomindani wants to merge 2 commits intodatabricks:mainfrom
moomindani wants to merge 2 commits intodatabricks:mainfrom
Conversation
databricks#1402) Replace inline config change detection/application in the V1 incremental path with the existing `process_config_changes()` macro already used by V2. This allows users to set `incremental_apply_config_changes: false` to skip 8 unnecessary information_schema queries per incremental model execution. Co-authored-by: Isaac
Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1402
Description
The V1 incremental materialization path calls
adapter.get_relation_config()unconditionally during every incremental merge run. This triggers 8 sequential metadata queries againstinformation_schemaandsystemtables — even when none of the related features (tags, constraints, column masks) are in use.The V2 path already uses
process_config_changes(), which respects theincremental_apply_config_changesconfig flag. This PR replaces the V1 inline code with the same macro, bringing V1 in line with V2.Change:
{{ process_config_changes(target_relation) }}callQueries eliminated when
incremental_apply_config_changes: false:SELECT ... FROM system.information_schema.table_tagsSELECT ... FROM system.information_schema.column_tagsSELECT ... FROM information_schema.columns(NOT NULL constraints)SELECT ... FROM information_schema.key_column_usage(PRIMARY KEY)SELECT ... FROM information_schema.key_column_usage(FOREIGN KEY)SELECT ... FROM system.information_schema.column_masksSHOW TBLPROPERTIESDESCRIBE TABLE EXTENDEDMeasured results (Serverless SQL Warehouse, incremental merge model with
auto_liquid_cluster: true):incremental_apply_config_changes: falseget_relation_configoverheadTest assets used for benchmarking
dbt_project.yml:
models/incremental_merge_test.sql (default run):
{{ config( materialized='incremental', incremental_strategy='merge', unique_key='id', auto_liquid_cluster=true ) }} SELECT id, name, category, amount, updated_at FROM ( VALUES (1, 'Alice', 'A', 100.0, current_timestamp()), (2, 'Bob', 'B', 200.0, current_timestamp()), (3, 'Charlie', 'A', 150.0, current_timestamp()), (4, 'Diana', 'C', 300.0, current_timestamp()), (5, 'Eve', 'B', 250.0, current_timestamp()) ) AS t(id, name, category, amount, updated_at)models/incremental_merge_test.sql (skip run — only config diff):
{{ config( materialized='incremental', incremental_strategy='merge', unique_key='id', auto_liquid_cluster=true, incremental_apply_config_changes=false ) }}Steps:
dbt run(initial table creation) →dbt run(incremental merge, default) → addincremental_apply_config_changes=false→dbt run(incremental merge, skip). Comparedbt.logfrom the last two runs.Query-level breakdown (default run)
Query-level breakdown (skip run)
Functional parity:
apply_config_changeset(used byprocess_config_changes) handles all config types that the V1 inline code handled (tags, tblproperties, liquid_clustering, constraints) plus additional types (column_comments, column_tags, column_masks).When
incremental_apply_config_changesistrue(default), behavior is unchanged — all 8 queries run and config changes are applied.Checklist
CHANGELOG.mdand added information about my change to the "dbt-databricks next" section.