Fix/duckdb catalog table owner type mismatch - #16197
Open
DipakMandlik wants to merge 2 commits into
Open
DipakMandlik wants to merge 2 commits into
DipakMandlik wants to merge 2 commits into
Conversation
…rrow type
dbt compile --write-catalog against DuckDB panicked with a dbt9002
Internal Error while building catalog.json: DuckDB's ADBC driver reports
the table_owner column -- defined in the catalog macro as a hardcoded
`cast(null as varchar)`, since DuckDB has no per-table owner concept -- as
Arrow Int32 rather than Utf8. build_schemas_from_stats_sql's strict
`column_values::<StringArray>("table_owner")` extraction then fails to
downcast, hard-erroring the whole catalog generation.
DuckDB's ADBC driver is an external, prebuilt binary (downloaded from
DuckDB's own releases), not code in this repo, so the type-reporting
quirk itself isn't something we can fix directly.
column_values already normalizes Utf8View/LargeUtf8 to Utf8 for exactly
this kind of "driver reports a different but compatible type" case (see
the existing comment/tests for that). Extend the same normalization: when
the requested type is StringArray but the column's actual type isn't
Utf8, and every value in the column is null, treat it as an all-null
string column instead of erroring -- there is no real data that could be
misinterpreted, since nothing but nulls is present. A column with any
non-null value of the wrong type is unaffected and still errors, exactly
as before.
Verified against current main's actual DuckDB ADBC driver-loading path
(cargo build -p dbt-sa-cli, minimal local DuckDB project); the official
driver binary itself isn't reachable from this sandbox (its CDN isn't on
the network allowlist here), so the exact reported scenario is instead
covered by a unit test reproducing the same RecordBatch shape (an Int32
column named table_owner, entirely null) through the same code path.
Extracted the branch conditions into named booleans
(wants_string_array / is_widened_utf8 / is_all_null_of_wrong_type)
to keep each if/else-if condition to a single logical operator.
Fixes dbt-labs#14647
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AGLxMGvaxDZLANJKH6E5f
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019AGLxMGvaxDZLANJKH6E5f
DipakMandlik
force-pushed
the
fix/duckdb-catalog-table-owner-type-mismatch
branch
from
September 4, 2026 12:04
a1846fe to
3b2c578
Compare
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.
Resolves #
Problem
Solution
Checklist