GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): resolve a struct field through its column by xen0l · Pull Request #4661 · sqlc-dev/sqlc

Conversation

@xen0l

@xen0l xen0l commented Oct 24, 2026

Copy link
Copy Markdown

Fixes #4655

Problem

typeColumnRef read only the first two parts of a column reference.

  • For i.info.label it resolved the column info and dropped label, so the result had the type of the whole struct.
  • For info.label it looked for a relation named info, found none, and reported an unknown column.

Change

  • Keep the parts after relation.column as a field path.
  • If the first part is not a relation, resolve it as a column and use the rest as the field path.
  • Walk the path through the struct's TypeExpr (structField). A field is nullable and has no source column. A field name is matched without regard to case. An unknown field is an error.

Tests

New end-to-end case: duckdb_struct_field/duckdb (sqlc generate, output committed). It covers info.label, i.info.label, a parameter compared with a field, and a field name in a different case. The case fails without the change (unknown column "info"."label") and passes with it.

go test ./internal/endtoend -run TestReplay/base: 971 pass, 58 skip, 0 fail before; 972 pass, 58 skip, 0 fail after. The only difference is the new case.
go test ./internal/engine/... ./internal/core/... ./internal/compiler/... ./internal/codegen/... ./internal/cmd/... ./internal/metadata/... ./internal/sql/...: all ok.

I also ran the generated Go on DuckDB v1.5.6 (duckdb-go/v2 v2.10506.0). Each query returned the right rows, and a row whose struct is NULL scans as an invalid sql.NullString.

Not run: the managed-db context, --tags=examples, and the internal/goldeneye checks. They need databases or a DuckDB CLI.

Not changed

struct_extract(info, 'label') is still typed as struct, and info['label'] is still untyped. They go through function and subscript typing.
The check is Name == "struct", so a struct column of another engine that uses the core analyzer takes the same path. The existing suite shows no change for them.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@xen0l
fix(core): resolve a struct field through its column
d1ba54e
typeColumnRef read only the first two parts of a column reference. For
i.info.label it resolved the column info and dropped label, so the result
had the type of the whole struct. For info.label it looked for a relation
named info and reported an unknown column.

Resolve the first part as a column when it is not a relation, then walk
the remaining parts as fields of the column's struct type. A field is
nullable and has no source column. An unknown field is an error.

Adds the duckdb_struct_field end-to-end case.
@Tidehyc Tidehyc mentioned this pull request Nov 7, 2026
duckdb: a table name or alias used as a value (SELECT p FROM plan p, plan_doc(p)) is an unknown column #4677
Open
@xen0l

xen0l commented Nov 10, 2026

Copy link
Copy Markdown
Author

@kyleconroy Could you review this fix for #4655 when you have time, please? Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

duckdb: col.field of a STRUCT column does not resolve, and alias.col.field is typed as the whole struct

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@xen0l
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.