[Bug] Plan IcebergCreateTable operator In CTAS queries to avoid double table create requests#974
Open
Tmonster wants to merge 8 commits intoduckdb:v1.5-variegatafrom
Open
[Bug] Plan IcebergCreateTable operator In CTAS queries to avoid double table create requests#974Tmonster wants to merge 8 commits intoduckdb:v1.5-variegatafrom
Tmonster wants to merge 8 commits intoduckdb:v1.5-variegatafrom
Conversation
…ll and also also responsible for updating Copy to file bind data
CTAS with partition information and table properties Co-authored-by: Anders <anders.swanson@dbtlabs.com>
…n so copy operator has partition information as well
Tishj
reviewed
May 8, 2026
| OperatorResultType PhysicalIcebergCreateTable::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk, | ||
| GlobalOperatorState &gstate_p, OperatorState &state) const { | ||
| auto &global_state = gstate_p.Cast<IcebergCreateTableGlobalState>(); | ||
| // Create the table in the IRC, record the field ids (columns ids) and update the binding in the |
Tishj
reviewed
May 8, 2026
|
|
||
| // create shared state to be used between IcebergTableCreate and IcebergInsert | ||
| auto create_state = make_shared_ptr<IcebergCTASCreateState>(); | ||
| // create a pass through IcebergCTASCrecateStatement operator to make the |
Tishj
reviewed
May 8, 2026
| GlobalOperatorState &gstate_p, OperatorState &state) const { | ||
| auto &global_state = gstate_p.Cast<IcebergCreateTableGlobalState>(); | ||
| // Create the table in the IRC, record the field ids (columns ids) and update the binding in the | ||
| MakeCreateTableRequest(context, global_state); |
Member
There was a problem hiding this comment.
Can't we do this only in FinalExecute, that should ensure it only runs once I believe?
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.
This supersedes #962
Resolves: #595
related: dbt-labs/dbt-fusion#1635
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 Tableoperator between theCopy to FileandSelectthat 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 (assumingsupports_stage_create = false.