Repository navigation
Conversation
targetName returned "?column?" for a result column with no alias that is not a column reference or a function call. The Go generator uses a non-empty name as written, so it emitted "var ?column? ..." and sqlc generate failed with "illegal character U+003F". Return an empty name. The generator already falls back to column_N for an empty name, which is what the PostgreSQL and SQLite engines produce. Adds the duckdb_unnamed_columns 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 #4657
Problem
targetNamereturned"?column?"for a result column with no alias that is not a column reference or a function call. The Go generator uses a non-empty name as written, so it emittedvar ?column? ...andsqlc generatefailed withillegal character U+003F '?'.The PostgreSQL and SQLite engines name such a column by position (
column_1).Change
targetName(internal/core/analyzer/projection.go) returns an empty name for such a target. The Go generator already falls back tocolumn_Nfor an empty name (columnNameininternal/codegen/golang/result.go).?column?was the only place in non-test Go code that produced the string.Tests
New end-to-end case:
duckdb_unnamed_columns/duckdb(sqlc generate, output committed). It covers an unaliasedCAST, a||expression, two unnamed columns, and a mix of named and unnamed columns. It fails without the change (illegal character U+003F '?') 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. No existing golden contained?column?.go test ./internal/engine/... ./internal/core/... ./internal/compiler/... ./internal/codegen/... ./internal/cmd/... ./internal/metadata/... ./internal/sql/...: all ok.Not run: the
managed-dbcontext,--tags=examples, and theinternal/goldeneyechecks.Notes
With this change,
SELECT * EXCLUDE (...)no longer fails at generate time. It used to fail only because it produced an unnamed column. It now generates[]anyand fails at run time (expected 3 destination arguments in Scan, not 1). That is a separate problem with its own cause (convertStarreturns a TODO node), described in #4660.