Skip to content

Resolve cross-schema row types to STRUCT (not VARCHAR)#476

Merged
staticlibs merged 3 commits into
duckdb:mainfrom
dialohq:main
May 26, 2026
Merged

Resolve cross-schema row types to STRUCT (not VARCHAR)#476
staticlibs merged 3 commits into
duckdb:mainfrom
dialohq:main

Conversation

@adamchol
Copy link
Copy Markdown
Contributor

Follow-up to #474 / #475. After PR #475, row types of relations are discovered and registered under their own schema, so the in-schema case works. But when a relation in schema B has a column whose type is the row type of a relation in schema A, PostgresUtils::TypeToLogicalType still looked up the type entry against the relation's schema (B). It finds nothing there and falls back to VARCHAR.

Follow-up to duckdb#474 / duckdb#475. After PR duckdb#475, row types of relations are
discovered and registered under their own schema, so the in-schema
case works. But when a relation in schema B has a column whose type
is the row type of a relation in schema A, PostgresUtils::TypeToLogicalType
still looked up the type entry against the relation's schema (B). It
finds nothing there and falls back to VARCHAR.

Plumb the type's own namespace through PostgresTypeData. The two
discovery queries now join pg_namespace on pg_type.typnamespace and
expose nspname as the type's schema, and TypeToLogicalType uses
Catalog::GetSchema to resolve the lookup against that schema when it
differs from the relation's own.

Extend test/sql/storage/attach_types_table_row.test with a cross-
schema view and table; the existing test put both ends in the same
schema, which is why this slipped through.
@staticlibs
Copy link
Copy Markdown
Member

Hi, thanks for the PR! I think it looks good, just there is an outage with GH actions right now so CI tests are not running. I'll trigger the tests run when the actions are back on.

adamchol added 2 commits May 26, 2026 14:29
The two SQL discovery queries pull type_schema from an INNER JOIN on
pg_namespace, so the column is never NULL.
Copy link
Copy Markdown
Member

@staticlibs staticlibs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@staticlibs staticlibs merged commit 916d862 into duckdb:main May 26, 2026
7 checks passed
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.

2 participants