Skip to content

Fix dbt clone for Snowflake Iceberg tables#1768

Open
jecolvin wants to merge 1 commit intodbt-labs:mainfrom
jecolvin:fix/snowflake-clone-iceberg-tables
Open

Fix dbt clone for Snowflake Iceberg tables#1768
jecolvin wants to merge 1 commit intodbt-labs:mainfrom
jecolvin:fix/snowflake-clone-iceberg-tables

Conversation

@jecolvin
Copy link

Summary

  • Detect Iceberg source tables in the clone macro via load_cached_relation and emit CREATE OR REPLACE ICEBERG TABLE ... CLONE ... instead of CREATE OR REPLACE [TRANSIENT] TABLE ... CLONE ...
  • Omit the transient keyword for Iceberg clones (Iceberg tables cannot be transient)
  • Add functional test for cloning an Iceberg table

Resolves #1767

Test plan

  • Existing clone tests pass (TestSnowflakeClonePossible, TestSnowflakeCloneTrainsentTable)
  • New TestSnowflakeCloneIcebergTable test passes against a Snowflake account with an Iceberg-enabled external volume
  • Verify generated SQL with --log-level debug shows CREATE OR REPLACE ICEBERG TABLE for Iceberg sources and CREATE OR REPLACE TRANSIENT TABLE for regular sources

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
@jecolvin jecolvin requested a review from a team as a code owner March 17, 2026 14:10
Copilot AI review requested due to automatic review settings March 17, 2026 14:10
@cla-bot cla-bot bot added the cla:yes The PR author has signed the CLA label Mar 17, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 clone and emit CREATE OR REPLACE ICEBERG TABLE ... CLONE ... when appropriate.
  • Ensure transient is 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:yes The PR author has signed the CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dbt clone fails on Snowflake Iceberg tables

2 participants