Fix dbt clone for Snowflake Iceberg tables#1768
Open
jecolvin wants to merge 1 commit intodbt-labs:mainfrom
Open
Fix dbt clone for Snowflake Iceberg tables#1768jecolvin wants to merge 1 commit intodbt-labs:mainfrom
jecolvin wants to merge 1 commit intodbt-labs:mainfrom
Conversation
The clone macro now detects whether the source relation is an Iceberg table via load_cached_relation and emits CREATE ICEBERG TABLE ... CLONE instead of CREATE TABLE ... CLONE. The transient keyword is correctly omitted for Iceberg clones since Iceberg tables cannot be transient. Resolves dbt-labs#1767
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Snowflake adapter’s clone materialization to correctly clone Iceberg source tables by generating Iceberg-specific DDL, and adds a functional test to validate the behavior.
Changes:
- Detect Iceberg source relations during
dbt cloneand emitCREATE OR REPLACE ICEBERG TABLE ... CLONE ...when appropriate. - Ensure
transientis not emitted for Iceberg clones (since Iceberg tables cannot be transient). - Add a functional test that clones an Iceberg table and asserts the cloned relation is also Iceberg.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dbt-snowflake/src/dbt/include/snowflake/macros/materializations/clone.sql | Conditionally renders Iceberg vs transient table clone DDL based on cached source relation metadata. |
| dbt-snowflake/tests/functional/adapter/dbt_clone/test_dbt_clone.py | Adds a functional test case covering cloning an Iceberg table and validating the cloned relation type. |
| dbt-snowflake/.changes/unreleased/Fixes-20260317-100403.yaml | Adds a changelog entry documenting the Iceberg clone fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+118
to
+131
| def copy_state(self, project_root): | ||
| state_path = os.path.join(project_root, "state") | ||
| if not os.path.exists(state_path): | ||
| os.makedirs(state_path) | ||
| shutil.copyfile( | ||
| f"{project_root}/target/manifest.json", f"{project_root}/state/manifest.json" | ||
| ) | ||
|
|
||
| def run_and_save_state(self, project_root): | ||
| results = run_dbt(["run"]) | ||
| assert len(results) == 1 | ||
|
|
||
| self.copy_state(project_root) | ||
|
|
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.
Summary
load_cached_relationand emitCREATE OR REPLACE ICEBERG TABLE ... CLONE ...instead ofCREATE OR REPLACE [TRANSIENT] TABLE ... CLONE ...transientkeyword for Iceberg clones (Iceberg tables cannot be transient)Resolves #1767
Test plan
TestSnowflakeClonePossible,TestSnowflakeCloneTrainsentTable)TestSnowflakeCloneIcebergTabletest passes against a Snowflake account with an Iceberg-enabled external volume--log-level debugshowsCREATE OR REPLACE ICEBERG TABLEfor Iceberg sources andCREATE OR REPLACE TRANSIENT TABLEfor regular sources