Repository navigation
Conversation
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.
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.
Fixes #4655
Problem
typeColumnRefread only the first two parts of a column reference.i.info.labelit resolved the columninfoand droppedlabel, so the result had the type of the whole struct.info.labelit looked for a relation namedinfo, found none, and reported an unknown column.Change
relation.columnas a field path.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 coversinfo.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 invalidsql.NullString.Not run: the
managed-dbcontext,--tags=examples, and theinternal/goldeneyechecks. They need databases or a DuckDB CLI.Not changed
struct_extract(info, 'label')is still typed asstruct, andinfo['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.