Repository navigation
Fix parsing columns that omit the type before DEFAULT, MATERIALIZED or ALIAS - #339
Merged
Merged
Conversation
Member
|
@youdie006 Thanks for your improvement. |
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.
#338 stopped
COMMENT,CODECandTTLfrom being read as a type name when a column's type is omitted. The same guard inparseTableColumnExprdoesn't skipDEFAULT,MATERIALIZEDandALIAS, which are handled a few lines below it, so a column that omits its type before one of them either fails to parse or is misparsed. ClickHouse allows this: "The column type of a default value column can be omitted in which case it is inferred fromexpr's type", e.g.EventDate DEFAULT toDate(EventTime)(CREATE TABLE, default values).This adds the three keywords to that guard. All three statements (CREATE, ADD COLUMN, MODIFY COLUMN) go through
parseTableColumnExpr.TestParser_ColumnValueExprWithoutTypecovers each keyword in each statement, includingDate DEFAULT today()andNullable(String) ALIAS 'x', where the type must still be parsed. It also checks thatDEFAULT,MATERIALIZEDorALIASwithout an expression is an error; those used to parse as a type name, and the docs say a type is required when the expression is left out. New fixtureparser/testdata/ddl/column_value_without_type.sql, with goldens regenerated by-update; no other golden changed.clickhouse-localwas not available here, so the syntax is checked against the docs above rather than the engine.go test -v ./... -covermode=atomic -race -compatible(asmake test) passes andgofmtis clean; I couldn't runmake lint, since golangci-lint v1.53.3 isn't installed.Written with AI assistance (Claude); I have reviewed the change.