@@ -31,10 +31,13 @@ type Expression interface {
3131
3232// SelectWithUnionQuery represents a SELECT query possibly with UNION.
3333type SelectWithUnionQuery struct {
34- Position token.Position `json:"-"`
35- Selects []Statement `json:"selects"`
36- UnionAll bool `json:"union_all,omitempty"`
37- UnionModes []string `json:"union_modes,omitempty"` // "ALL", "DISTINCT", or "" for each union
34+ Position token.Position `json:"-"`
35+ Selects []Statement `json:"selects"`
36+ UnionAll bool `json:"union_all,omitempty"`
37+ UnionModes []string `json:"union_modes,omitempty"` // "ALL", "DISTINCT", or "" for each union
38+ Settings []* SettingExpr `json:"settings,omitempty"` // Union-level SETTINGS
39+ SettingsAfterFormat bool `json:"settings_after_format,omitempty"`
40+ SettingsBeforeFormat bool `json:"settings_before_format,omitempty"`
3841}
3942
4043func (s * SelectWithUnionQuery ) Pos () token.Position { return s .Position }
@@ -80,8 +83,9 @@ type SelectQuery struct {
8083 LimitByLimit Expression `json:"limit_by_limit,omitempty"` // LIMIT value before BY (e.g., LIMIT 1 BY x LIMIT 3)
8184 LimitByHasLimit bool `json:"limit_by_has_limit,omitempty"` // true if LIMIT BY was followed by another LIMIT
8285 Offset Expression `json:"offset,omitempty"`
83- Settings []* SettingExpr `json:"settings,omitempty"`
84- SettingsAfterFormat bool `json:"settings_after_format,omitempty"` // true if SETTINGS came after FORMAT
86+ Settings []* SettingExpr `json:"settings,omitempty"`
87+ SettingsAfterFormat bool `json:"settings_after_format,omitempty"` // true if SETTINGS came after FORMAT (at union level)
88+ SettingsBeforeFormat bool `json:"settings_before_format,omitempty"` // true if SETTINGS came before FORMAT (at union level)
8589 IntoOutfile * IntoOutfileClause `json:"into_outfile,omitempty"`
8690 Format * Identifier `json:"format,omitempty"`
8791}
@@ -285,6 +289,7 @@ type CreateQuery struct {
285289 Settings []* SettingExpr `json:"settings,omitempty"`
286290 AsSelect Statement `json:"as_select,omitempty"`
287291 AsTableFunction Expression `json:"as_table_function,omitempty"` // AS table_function(...) in CREATE TABLE
292+ CloneAs string `json:"clone_as,omitempty"` // CLONE AS source_table in CREATE TABLE
288293 Comment string `json:"comment,omitempty"`
289294 OnCluster string `json:"on_cluster,omitempty"`
290295 CreateDatabase bool `json:"create_database,omitempty"`
@@ -319,6 +324,7 @@ type ColumnDeclaration struct {
319324 TTL Expression `json:"ttl,omitempty"`
320325 PrimaryKey bool `json:"primary_key,omitempty"` // PRIMARY KEY constraint
321326 Comment string `json:"comment,omitempty"`
327+ Settings []* SettingExpr `json:"settings,omitempty"` // Column-level SETTINGS
322328}
323329
324330func (c * ColumnDeclaration ) Pos () token.Position { return c .Position }
@@ -572,11 +578,13 @@ type AlterCommand struct {
572578 Index string `json:"index,omitempty"`
573579 IndexExpr Expression `json:"index_expr,omitempty"`
574580 IndexType string `json:"index_type,omitempty"`
581+ IndexDef * IndexDefinition `json:"index_def,omitempty"` // For ADD INDEX with full definition
575582 Granularity int `json:"granularity,omitempty"`
576583 Constraint * Constraint `json:"constraint,omitempty"`
577584 ConstraintName string `json:"constraint_name,omitempty"`
578585 Partition Expression `json:"partition,omitempty"`
579586 PartitionIsID bool `json:"partition_is_id,omitempty"` // True when using PARTITION ID 'value' syntax
587+ IsPart bool `json:"-"` // True for PART (not PARTITION) - output directly without Partition wrapper
580588 FromTable string `json:"from_table,omitempty"`
581589 ToDatabase string `json:"to_database,omitempty"` // For MOVE PARTITION TO TABLE
582590 ToTable string `json:"to_table,omitempty"` // For MOVE PARTITION TO TABLE
@@ -591,6 +599,8 @@ type AlterCommand struct {
591599 StatisticsTypes []* FunctionCall `json:"statistics_types,omitempty"` // For ADD/MODIFY STATISTICS TYPE
592600 Comment string `json:"comment,omitempty"` // For COMMENT COLUMN
593601 OrderByExpr []Expression `json:"order_by_expr,omitempty"` // For MODIFY ORDER BY
602+ SampleByExpr Expression `json:"sample_by_expr,omitempty"` // For MODIFY SAMPLE BY
603+ ResetSettings []string `json:"reset_settings,omitempty"` // For MODIFY COLUMN ... RESET SETTING
594604}
595605
596606// Projection represents a projection definition.
@@ -633,6 +643,7 @@ const (
633643 AlterModifyColumn AlterCommandType = "MODIFY_COLUMN"
634644 AlterRenameColumn AlterCommandType = "RENAME_COLUMN"
635645 AlterClearColumn AlterCommandType = "CLEAR_COLUMN"
646+ AlterMaterializeColumn AlterCommandType = "MATERIALIZE_COLUMN"
636647 AlterCommentColumn AlterCommandType = "COMMENT_COLUMN"
637648 AlterAddIndex AlterCommandType = "ADD_INDEX"
638649 AlterDropIndex AlterCommandType = "DROP_INDEX"
@@ -665,6 +676,8 @@ const (
665676 AlterMaterializeStatistics AlterCommandType = "MATERIALIZE_STATISTICS"
666677 AlterModifyComment AlterCommandType = "MODIFY_COMMENT"
667678 AlterModifyOrderBy AlterCommandType = "MODIFY_ORDER_BY"
679+ AlterModifySampleBy AlterCommandType = "MODIFY_SAMPLE_BY"
680+ AlterRemoveSampleBy AlterCommandType = "REMOVE_SAMPLE_BY"
668681)
669682
670683// TruncateQuery represents a TRUNCATE statement.
@@ -674,6 +687,7 @@ type TruncateQuery struct {
674687 Database string `json:"database,omitempty"`
675688 Table string `json:"table"`
676689 OnCluster string `json:"on_cluster,omitempty"`
690+ Settings []* SettingExpr `json:"settings,omitempty"`
677691}
678692
679693func (t * TruncateQuery ) Pos () token.Position { return t .Position }
@@ -704,9 +718,10 @@ func (u *UseQuery) statementNode() {}
704718
705719// DetachQuery represents a DETACH statement.
706720type DetachQuery struct {
707- Position token.Position `json:"-"`
708- Database string `json:"database,omitempty"`
709- Table string `json:"table,omitempty"`
721+ Position token.Position `json:"-"`
722+ Database string `json:"database,omitempty"`
723+ Table string `json:"table,omitempty"`
724+ Dictionary string `json:"dictionary,omitempty"`
710725}
711726
712727func (d * DetachQuery ) Pos () token.Position { return d .Position }
@@ -718,6 +733,7 @@ type AttachQuery struct {
718733 Position token.Position `json:"-"`
719734 Database string `json:"database,omitempty"`
720735 Table string `json:"table,omitempty"`
736+ Dictionary string `json:"dictionary,omitempty"`
721737 Columns []* ColumnDeclaration `json:"columns,omitempty"`
722738 ColumnsPrimaryKey []Expression `json:"columns_primary_key,omitempty"` // PRIMARY KEY in column list
723739 Engine * EngineClause `json:"engine,omitempty"`
@@ -832,6 +848,7 @@ type OptimizeQuery struct {
832848 Cleanup bool `json:"cleanup,omitempty"`
833849 Dedupe bool `json:"dedupe,omitempty"`
834850 OnCluster string `json:"on_cluster,omitempty"`
851+ Settings []* SettingExpr `json:"settings,omitempty"`
835852}
836853
837854func (o * OptimizeQuery ) Pos () token.Position { return o .Position }
@@ -891,6 +908,7 @@ type RenameQuery struct {
891908 From string `json:"from,omitempty"` // Deprecated: for backward compat
892909 To string `json:"to,omitempty"` // Deprecated: for backward compat
893910 OnCluster string `json:"on_cluster,omitempty"`
911+ Settings []* SettingExpr `json:"settings,omitempty"`
894912}
895913
896914func (r * RenameQuery ) Pos () token.Position { return r .Position }
@@ -927,6 +945,7 @@ type ExistsQuery struct {
927945 ExistsType ExistsType `json:"exists_type,omitempty"`
928946 Database string `json:"database,omitempty"`
929947 Table string `json:"table"`
948+ Settings []* SettingExpr `json:"settings,omitempty"`
930949}
931950
932951func (e * ExistsQuery ) Pos () token.Position { return e .Position }
@@ -1153,9 +1172,10 @@ func (c *CreateIndexQuery) statementNode() {}
11531172
11541173// Identifier represents an identifier.
11551174type Identifier struct {
1156- Position token.Position `json:"-"`
1157- Parts []string `json:"parts"` // e.g., ["db", "table", "column"] for db.table.column
1158- Alias string `json:"alias,omitempty"`
1175+ Position token.Position `json:"-"`
1176+ Parts []string `json:"parts"` // e.g., ["db", "table", "column"] for db.table.column
1177+ Alias string `json:"alias,omitempty"`
1178+ Parenthesized bool `json:"-"` // true if wrapped in parentheses, affects dot access parsing
11591179}
11601180
11611181func (i * Identifier ) Pos () token.Position { return i .Position }
0 commit comments