Skip to content

Fix/duckdb catalog table owner type mismatch - #16197

Open
DipakMandlik wants to merge 2 commits into
dbt-labs:mainfrom
DipakMandlik:fix/duckdb-catalog-table-owner-type-mismatch
Open

DipakMandlik wants to merge 2 commits into
dbt-labs:mainfrom
DipakMandlik:fix/duckdb-catalog-table-owner-type-mismatch

Conversation

@DipakMandlik

@DipakMandlik DipakMandlik commented Sep 4, 2026

Copy link
Copy Markdown

Resolves #

Problem

Solution

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.

@DipakMandlik
DipakMandlik requested a review from a team as a code owner September 4, 2026 07:28
@cla-bot cla-bot Bot added the cla:yes label Sep 4, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

DipakMandlik and others added 2 commits September 4, 2026 11:54
…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
DipakMandlik force-pushed the fix/duckdb-catalog-table-owner-type-mismatch branch from a1846fe to 3b2c578 Compare September 4, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant