Skip to content

fix: match native column types in scoped pg_tables/pg_views/pg_sequences views#683

Draft
EDsCODE wants to merge 1 commit into
mainfrom
fix/pg-catalog-convenience-view-types
Draft

fix: match native column types in scoped pg_tables/pg_views/pg_sequences views#683
EDsCODE wants to merge 1 commit into
mainfrom
fix/pg-catalog-convenience-view-types

Conversation

@EDsCODE
Copy link
Copy Markdown
Contributor

@EDsCODE EDsCODE commented Jun 4, 2026

Summary

Follow-up to the iceberg/ducklake catalog-separation work (PR #679, now on main). The session-scoped pg_tables / pg_views / pg_sequences compat views replace DuckDB's native pg_catalog views in client queries, so their synthesized columns must match the native column types exactly — the only intended behavior change is the current_database() row-filter, not the result shape.

While verifying separation on the prod cluster I observed that pg_tables was correctly routed to memory.main.pg_tables (the scoping works), but a probe query tripped Could not convert string 'NULL' to INT32 — the synthesized columns had drifted from native types.

DuckDB's native types are:

  • pg_tables.tablespaceINTEGER
  • pg_sequences.data_typeINTEGER (not a 'bigint' string)
  • pg_sequences.cache_sizeINTEGER
  • sequence value columns → BIGINT

Changes

  • Pin synthesized columns to native types (tablespace/data_type/cache_sizeINTEGER, value columns → BIGINT).
  • Add TestPgCatalogConvenienceViewsMatchNativeShape: DESCRIBEs each compat view and asserts its (column_name, column_type) list is byte-for-byte identical to the native pg_catalog view.

Test plan

  • go test ./server -run 'TestPgCatalogConvenienceViewsMatchNativeShape|TestPgTablesViewsSequencesOnlyExposeSelectedCatalog' -count=1
  • go build ./..., gofmt, golangci-lint clean

🤖 Generated with Claude Code

…ces views

The session-scoped pg_tables/pg_views/pg_sequences compat views (added in
the catalog-separation work) replace DuckDB's native pg_catalog views in
client queries. Their synthesized columns must match the native column
types exactly so the only behavior change is the catalog row-filter, not
the result shape.

DuckDB's native pg_tables.tablespace and pg_sequences.data_type/cache_size
are INTEGER (not text/bigint). A bare `NULL AS tablespace` types as INT32
which happened to match, but `'bigint' AS data_type` (VARCHAR) and other
nulls diverged, so a client filtering e.g. `WHERE tablespace = 'x'` could
hit a type error it would not have hit against the native view.

Pin the synthesized columns to native types (tablespace/data_type/
cache_size -> INTEGER, value columns -> BIGINT) and add
TestPgCatalogConvenienceViewsMatchNativeShape, which DESCRIBEs each compat
view and asserts its (column_name, column_type) list is identical to the
native pg_catalog view.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant