[AI] Fix Iceberg CTAS prepared rebind#962
Closed
dataders wants to merge 3 commits into
Closed
Conversation
dataders
marked this pull request as ready for review
April 24, 2026 20:39
dataders
marked this pull request as draft
April 25, 2026 05:02
dataders
marked this pull request as ready for review
April 27, 2026 16:59
Member
|
Hi @dataders, Thanks for looking into this! I'm looking through it and it seems reasonable to me. I will chat with some people on core first to make sure this is the right approach before merging. Hopefully we can get this in for v1.5.3 |
Contributor
Author
|
thanks @Tmonster! for the record, I feel guilty and "part of the problem" to be slinging slop your way, so thanks for your understanding. Hope this PR is more helpful to you than harmful at the very least the repro I added to the issue is instructive |
Member
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.
Important
this patch was created by me, a human, and I heavily leaned on LLM agents. That said, it actually fixes the bug for me. My intent in opening this was predominately to unblock the integration of duckdb-iceberg into the dbt Fusion engine. Any feedback here is more than welcome!
Summary
Resolves: dbt-labs/dbt-core#13621
related: dbt-labs/dbt-core#14547
related: duckdb/dbt-duckdb#725
Why this still seems right
the likely shape was described on #595 (comment): prepare and execute can both try to create the Iceberg table when staged create handling does not protect the flow.
That matches the clean repro. The table does not exist before
duckdb_prepare. Published Iceberg creates it during prepare. Thenduckdb_execute_prepared_streamingrebinds/replans and hits create again.I also tried the same repro with
SUPPORT_STAGE_CREATE true. Published 1.4.4 still fails withTable ... already exists; published 1.5.2 still fails with the optional-pointer internal error.This patch makes Iceberg CTAS prepare side-effect free and marks the prepared statement as needing execution-time rebind.
Repro
columnsdefined underversionsdbt-labs/dbt-core#13621: CREATE TABLE fails when Iceberg is accessed from Adbc #595 (comment)PREPARE ctas AS CREATE TABLE ... AS ...Table ctas_prepare_rebind_595_<uuid> already existsINTERNAL Error: Attempting to dereference an optional pointer that is not setTesting
cmake --build build/debug --target libduckdb.dylib iceberg.duckdb_extension duckdb_local_extension_repouv run python3 -m py_compile test/python/test_prepared_ctas.pyuv run --with pytest --with pyspark==3.5.2 python3 -m pytest test/python/test_prepared_ctas.py -q(local no-catalog path: 2 skipped)duckdb_prepare+duckdb_execute_prepared_streamingdbt run --target iceberg_rest --select iceberg_rest_catalog_demo, plus DuckDB readback count=1