Skip to content

[Bug] Plan IcebergCreateTable operator In CTAS queries to avoid double table create requests#974

Merged
Tmonster merged 10 commits into
duckdb:v1.5-variegatafrom
Tmonster:CTAS_union_with_reference
May 12, 2026
Merged

[Bug] Plan IcebergCreateTable operator In CTAS queries to avoid double table create requests#974
Tmonster merged 10 commits into
duckdb:v1.5-variegatafrom
Tmonster:CTAS_union_with_reference

Conversation

@Tmonster

@Tmonster Tmonster commented May 6, 2026

Copy link
Copy Markdown
Member

This supersedes #962

Resolves: #595
related: dbt-labs/dbt-core#14547
related: duckdb/dbt-duckdb#725

962 involves registering a client context on attach, but this will break down if many clients are involved since only one client will run the attach.

The solution in this PR is to introduce an intermediate Create Iceberg Table operator between the Copy to File and Select that is only responsible for creating the table on first chunk. This way the table is not created During Binding/Planning.

This also fixes an issue where EXPLAIN Create table as .. queries would actually create the table (assuming supports_stage_create = false.

@Tmonster Tmonster changed the title [Bug] Plan intermediate operator responsible for making API call. [Bug] Plan IcebergCreateTable operator In CTAS queries to avoid double table create requests May 6, 2026

@dataders dataders left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

really appreciate you picking this up @Tmonster -- cheers!

I've left an LLM-proposed test for your consideration and a pedantic suggestion to remove what smells like a spurious ;

Tmonster and others added 3 commits May 7, 2026 09:55
CTAS with partition information and table properties

Co-authored-by: Anders <anders.swanson@dbtlabs.com>
…n so copy operator has partition information as well
Comment thread src/execution/operator/physical_iceberg_create_table.cpp Outdated
Comment thread src/execution/operator/iceberg_insert.cpp Outdated
Comment thread src/execution/operator/physical_iceberg_create_table.cpp Outdated
@Tmonster

Copy link
Copy Markdown
Member Author

Chatted with @lnkuiper , apparently GetGlobalOperatorState is also called only once per operator, so we can create the table when the global operator state is created

@Tmonster
Tmonster requested a review from Tishj May 12, 2026 12:15

@Tishj Tishj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, looks good to me 👍

@Tmonster

Copy link
Copy Markdown
Member Author

ah just deploy left. Let's get this in

@Tmonster
Tmonster merged commit 44e4acb into duckdb:v1.5-variegata May 12, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CREATE TABLE fails when Iceberg is accessed from Adbc

3 participants