-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathast.go
More file actions
1795 lines (1537 loc) · 78.9 KB
/
ast.go
File metadata and controls
1795 lines (1537 loc) · 78.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Package ast defines the abstract syntax tree for ClickHouse SQL.
package ast
import (
"encoding/json"
"math"
"github.com/sqlc-dev/doubleclick/token"
)
// Node is the interface implemented by all AST nodes.
type Node interface {
Pos() token.Position
End() token.Position
}
// Statement is the interface implemented by all statement nodes.
type Statement interface {
Node
statementNode()
}
// Expression is the interface implemented by all expression nodes.
type Expression interface {
Node
expressionNode()
}
// -----------------------------------------------------------------------------
// Statements
// SelectWithUnionQuery represents a SELECT query possibly with UNION.
type SelectWithUnionQuery struct {
Position token.Position `json:"-"`
Selects []Statement `json:"selects"`
UnionAll bool `json:"union_all,omitempty"`
UnionModes []string `json:"union_modes,omitempty"` // "ALL", "DISTINCT", or "" for each union
Settings []*SettingExpr `json:"settings,omitempty"` // Union-level SETTINGS
SettingsAfterFormat bool `json:"settings_after_format,omitempty"`
SettingsBeforeFormat bool `json:"settings_before_format,omitempty"`
}
func (s *SelectWithUnionQuery) Pos() token.Position { return s.Position }
func (s *SelectWithUnionQuery) End() token.Position { return s.Position }
func (s *SelectWithUnionQuery) statementNode() {}
// SelectIntersectExceptQuery represents SELECT ... INTERSECT/EXCEPT ... queries.
type SelectIntersectExceptQuery struct {
Position token.Position `json:"-"`
Selects []Statement `json:"selects"`
Operators []string `json:"operators,omitempty"` // "INTERSECT", "EXCEPT", etc. for each operator between selects
}
func (s *SelectIntersectExceptQuery) Pos() token.Position { return s.Position }
func (s *SelectIntersectExceptQuery) End() token.Position { return s.Position }
func (s *SelectIntersectExceptQuery) statementNode() {}
// SelectQuery represents a SELECT statement.
type SelectQuery struct {
Position token.Position `json:"-"`
With []Expression `json:"with,omitempty"`
Distinct bool `json:"distinct,omitempty"`
DistinctOn []Expression `json:"distinct_on,omitempty"` // DISTINCT ON (col1, col2, ...) syntax
Top Expression `json:"top,omitempty"`
Columns []Expression `json:"columns"`
From *TablesInSelectQuery `json:"from,omitempty"`
ArrayJoin *ArrayJoinClause `json:"array_join,omitempty"`
PreWhere Expression `json:"prewhere,omitempty"`
Where Expression `json:"where,omitempty"`
GroupBy []Expression `json:"group_by,omitempty"`
GroupByAll bool `json:"group_by_all,omitempty"` // true if GROUP BY ALL was used
GroupingSets bool `json:"grouping_sets,omitempty"` // true if GROUP BY uses GROUPING SETS
WithRollup bool `json:"with_rollup,omitempty"`
WithCube bool `json:"with_cube,omitempty"`
WithTotals bool `json:"with_totals,omitempty"`
Having Expression `json:"having,omitempty"`
Qualify Expression `json:"qualify,omitempty"`
Window []*WindowDefinition `json:"window,omitempty"`
OrderBy []*OrderByElement `json:"order_by,omitempty"`
Interpolate []*InterpolateElement `json:"interpolate,omitempty"`
Limit Expression `json:"limit,omitempty"`
LimitBy []Expression `json:"limit_by,omitempty"`
LimitByLimit Expression `json:"limit_by_limit,omitempty"` // LIMIT value before BY (e.g., LIMIT 1 BY x LIMIT 3)
LimitByOffset Expression `json:"limit_by_offset,omitempty"` // Offset for LIMIT BY (e.g., LIMIT 2, 3 BY x -> offset=2)
LimitByHasLimit bool `json:"limit_by_has_limit,omitempty"` // true if LIMIT BY was followed by another LIMIT
Offset Expression `json:"offset,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
SettingsAfterFormat bool `json:"settings_after_format,omitempty"` // true if SETTINGS came after FORMAT (at union level)
SettingsBeforeFormat bool `json:"settings_before_format,omitempty"` // true if SETTINGS came before FORMAT (at union level)
IntoOutfile *IntoOutfileClause `json:"into_outfile,omitempty"`
Format *Identifier `json:"format,omitempty"`
}
// ArrayJoinClause represents an ARRAY JOIN clause.
type ArrayJoinClause struct {
Position token.Position `json:"-"`
Left bool `json:"left,omitempty"`
Columns []Expression `json:"columns"`
}
func (a *ArrayJoinClause) Pos() token.Position { return a.Position }
func (a *ArrayJoinClause) End() token.Position { return a.Position }
// WindowDefinition represents a named window definition in the WINDOW clause.
type WindowDefinition struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Spec *WindowSpec `json:"spec"`
}
func (w *WindowDefinition) Pos() token.Position { return w.Position }
func (w *WindowDefinition) End() token.Position { return w.Position }
// IntoOutfileClause represents INTO OUTFILE clause.
type IntoOutfileClause struct {
Position token.Position `json:"-"`
Filename string `json:"filename"`
Truncate bool `json:"truncate,omitempty"`
}
func (i *IntoOutfileClause) Pos() token.Position { return i.Position }
func (i *IntoOutfileClause) End() token.Position { return i.Position }
func (s *SelectQuery) Pos() token.Position { return s.Position }
func (s *SelectQuery) End() token.Position { return s.Position }
func (s *SelectQuery) statementNode() {}
// TablesInSelectQuery represents the tables in a SELECT query.
type TablesInSelectQuery struct {
Position token.Position `json:"-"`
Tables []*TablesInSelectQueryElement `json:"tables"`
}
func (t *TablesInSelectQuery) Pos() token.Position { return t.Position }
func (t *TablesInSelectQuery) End() token.Position { return t.Position }
// TablesInSelectQueryElement represents a single table element in a SELECT.
type TablesInSelectQueryElement struct {
Position token.Position `json:"-"`
Table *TableExpression `json:"table,omitempty"`
Join *TableJoin `json:"join,omitempty"`
ArrayJoin *ArrayJoinClause `json:"array_join,omitempty"` // For ARRAY JOIN as table element
}
func (t *TablesInSelectQueryElement) Pos() token.Position { return t.Position }
func (t *TablesInSelectQueryElement) End() token.Position { return t.Position }
// TableExpression represents a table reference.
type TableExpression struct {
Position token.Position `json:"-"`
Table Expression `json:"table"` // TableIdentifier, Subquery, or Function
Alias string `json:"alias,omitempty"`
Final bool `json:"final,omitempty"`
Sample *SampleClause `json:"sample,omitempty"`
}
func (t *TableExpression) Pos() token.Position { return t.Position }
func (t *TableExpression) End() token.Position { return t.Position }
// SampleClause represents a SAMPLE clause.
type SampleClause struct {
Position token.Position `json:"-"`
Ratio Expression `json:"ratio"`
Offset Expression `json:"offset,omitempty"`
}
func (s *SampleClause) Pos() token.Position { return s.Position }
func (s *SampleClause) End() token.Position { return s.Position }
// TableJoin represents a JOIN clause.
type TableJoin struct {
Position token.Position `json:"-"`
Type JoinType `json:"type"`
Strictness JoinStrictness `json:"strictness,omitempty"`
Global bool `json:"global,omitempty"`
On Expression `json:"on,omitempty"`
Using []Expression `json:"using,omitempty"`
}
func (t *TableJoin) Pos() token.Position { return t.Position }
func (t *TableJoin) End() token.Position { return t.Position }
// JoinType represents the type of join.
type JoinType string
const (
JoinInner JoinType = "INNER"
JoinLeft JoinType = "LEFT"
JoinRight JoinType = "RIGHT"
JoinFull JoinType = "FULL"
JoinCross JoinType = "CROSS"
JoinPaste JoinType = "PASTE"
)
// JoinStrictness represents the join strictness.
type JoinStrictness string
const (
JoinStrictAny JoinStrictness = "ANY"
JoinStrictAll JoinStrictness = "ALL"
JoinStrictAsof JoinStrictness = "ASOF"
JoinStrictSemi JoinStrictness = "SEMI"
JoinStrictAnti JoinStrictness = "ANTI"
)
// OrderByElement represents an ORDER BY element.
type OrderByElement struct {
Position token.Position `json:"-"`
Expression Expression `json:"expression"`
Descending bool `json:"descending,omitempty"`
NullsFirst *bool `json:"nulls_first,omitempty"`
Collate string `json:"collate,omitempty"`
WithFill bool `json:"with_fill,omitempty"`
FillFrom Expression `json:"fill_from,omitempty"`
FillTo Expression `json:"fill_to,omitempty"`
FillStep Expression `json:"fill_step,omitempty"`
FillStaleness Expression `json:"fill_staleness,omitempty"`
}
func (o *OrderByElement) Pos() token.Position { return o.Position }
func (o *OrderByElement) End() token.Position { return o.Position }
// InterpolateElement represents a single column interpolation in INTERPOLATE clause.
// Example: INTERPOLATE (value AS value + 1)
type InterpolateElement struct {
Position token.Position `json:"-"`
Column string `json:"column"`
Value Expression `json:"value,omitempty"` // nil if just column name
}
func (i *InterpolateElement) Pos() token.Position { return i.Position }
func (i *InterpolateElement) End() token.Position { return i.Position }
// SettingExpr represents a setting expression.
type SettingExpr struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Value Expression `json:"value"`
}
func (s *SettingExpr) Pos() token.Position { return s.Position }
func (s *SettingExpr) End() token.Position { return s.Position }
// InsertQuery represents an INSERT statement.
type InsertQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
Function *FunctionCall `json:"function,omitempty"` // For INSERT INTO FUNCTION syntax
Columns []*Identifier `json:"columns,omitempty"`
ColumnExpressions []Expression `json:"column_expressions,omitempty"` // For asterisk/COLUMNS expressions with transformers
AllColumns bool `json:"all_columns,omitempty"` // For (*) syntax meaning all columns
PartitionBy Expression `json:"partition_by,omitempty"` // For PARTITION BY clause
Infile string `json:"infile,omitempty"` // For FROM INFILE clause
Compression string `json:"compression,omitempty"` // For COMPRESSION clause
Values [][]Expression `json:"-"` // For VALUES clause (format only, not in AST JSON)
Select Statement `json:"select,omitempty"`
With []Expression `json:"with,omitempty"` // For WITH ... INSERT ... SELECT syntax
Format *Identifier `json:"format,omitempty"`
HasSettings bool `json:"has_settings,omitempty"` // For SETTINGS clause
Settings []*SettingExpr `json:"settings,omitempty"` // For SETTINGS clause in INSERT
}
func (i *InsertQuery) Pos() token.Position { return i.Position }
func (i *InsertQuery) End() token.Position { return i.Position }
func (i *InsertQuery) statementNode() {}
// CreateQuery represents a CREATE statement.
type CreateQuery struct {
Position token.Position `json:"-"`
OrReplace bool `json:"or_replace,omitempty"`
IfNotExists bool `json:"if_not_exists,omitempty"`
Temporary bool `json:"temporary,omitempty"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
View string `json:"view,omitempty"`
Materialized bool `json:"materialized,omitempty"`
WindowView bool `json:"window_view,omitempty"` // WINDOW VIEW type
InnerEngine *EngineClause `json:"inner_engine,omitempty"` // INNER ENGINE for window views
ToDatabase string `json:"to_database,omitempty"` // Target database for materialized views
To string `json:"to,omitempty"` // Target table for materialized views
Populate bool `json:"populate,omitempty"` // POPULATE for materialized views
HasRefresh bool `json:"has_refresh,omitempty"` // Has REFRESH clause
RefreshType string `json:"refresh_type,omitempty"` // AFTER or EVERY
RefreshInterval Expression `json:"refresh_interval,omitempty"` // Interval value
RefreshUnit string `json:"refresh_unit,omitempty"` // SECOND, MINUTE, etc.
RefreshAppend bool `json:"refresh_append,omitempty"` // APPEND TO was specified
Empty bool `json:"empty,omitempty"` // EMPTY keyword was specified
Columns []*ColumnDeclaration `json:"columns,omitempty"`
Indexes []*IndexDefinition `json:"indexes,omitempty"`
Projections []*Projection `json:"projections,omitempty"`
Constraints []*Constraint `json:"constraints,omitempty"`
ColumnsPrimaryKey []Expression `json:"columns_primary_key,omitempty"` // PRIMARY KEY in column list
HasEmptyColumnsPrimaryKey bool `json:"has_empty_columns_primary_key,omitempty"` // TRUE if PRIMARY KEY () was seen with empty parens
Engine *EngineClause `json:"engine,omitempty"`
OrderBy []Expression `json:"order_by,omitempty"`
OrderByHasModifiers bool `json:"order_by_has_modifiers,omitempty"` // True if ORDER BY has ASC/DESC modifiers
PartitionBy Expression `json:"partition_by,omitempty"`
PrimaryKey []Expression `json:"primary_key,omitempty"`
SampleBy Expression `json:"sample_by,omitempty"`
TTL *TTLClause `json:"ttl,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
QuerySettings []*SettingExpr `json:"query_settings,omitempty"` // Query-level SETTINGS (second SETTINGS clause)
SettingsBeforeComment bool `json:"settings_before_comment,omitempty"` // True if SETTINGS comes before COMMENT
AsSelect Statement `json:"as_select,omitempty"`
AsTableFunction Expression `json:"as_table_function,omitempty"` // AS table_function(...) in CREATE TABLE
CloneAs string `json:"clone_as,omitempty"` // CLONE AS source_table in CREATE TABLE
Comment string `json:"comment,omitempty"`
OnCluster string `json:"on_cluster,omitempty"`
CreateDatabase bool `json:"create_database,omitempty"`
CreateFunction bool `json:"create_function,omitempty"`
CreateUser bool `json:"create_user,omitempty"`
AlterUser bool `json:"alter_user,omitempty"`
HasAuthenticationData bool `json:"has_authentication_data,omitempty"`
AuthenticationValues []string `json:"authentication_values,omitempty"` // Password/hash values from IDENTIFIED BY
SSHKeyCount int `json:"ssh_key_count,omitempty"` // Number of SSH keys for ssh_key auth
CreateDictionary bool `json:"create_dictionary,omitempty"`
DictionaryAttrs []*DictionaryAttributeDeclaration `json:"dictionary_attrs,omitempty"`
DictionaryDef *DictionaryDefinition `json:"dictionary_def,omitempty"`
FunctionName string `json:"function_name,omitempty"`
FunctionBody Expression `json:"function_body,omitempty"`
UserName string `json:"user_name,omitempty"`
Format string `json:"format,omitempty"` // For FORMAT clause
}
func (c *CreateQuery) Pos() token.Position { return c.Position }
func (c *CreateQuery) End() token.Position { return c.Position }
func (c *CreateQuery) statementNode() {}
// ColumnDeclaration represents a column definition.
type ColumnDeclaration struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Type *DataType `json:"type"`
Nullable *bool `json:"nullable,omitempty"`
Default Expression `json:"default,omitempty"`
DefaultKind string `json:"default_kind,omitempty"` // DEFAULT, MATERIALIZED, ALIAS, EPHEMERAL
Codec *CodecExpr `json:"codec,omitempty"`
Statistics []*FunctionCall `json:"statistics,omitempty"` // STATISTICS clause
TTL Expression `json:"ttl,omitempty"`
PrimaryKey bool `json:"primary_key,omitempty"` // PRIMARY KEY constraint
Comment string `json:"comment,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"` // Column-level SETTINGS
}
func (c *ColumnDeclaration) Pos() token.Position { return c.Position }
func (c *ColumnDeclaration) End() token.Position { return c.Position }
// DictionaryAttributeDeclaration represents a dictionary attribute definition.
type DictionaryAttributeDeclaration struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Type *DataType `json:"type"`
Default Expression `json:"default,omitempty"`
Expression Expression `json:"expression,omitempty"` // EXPRESSION clause
Hierarchical bool `json:"hierarchical,omitempty"` // HIERARCHICAL flag
Injective bool `json:"injective,omitempty"` // INJECTIVE flag
IsObjectID bool `json:"is_object_id,omitempty"` // IS_OBJECT_ID flag
}
func (d *DictionaryAttributeDeclaration) Pos() token.Position { return d.Position }
func (d *DictionaryAttributeDeclaration) End() token.Position { return d.Position }
// DictionaryDefinition represents the definition part of a dictionary (PRIMARY KEY, SOURCE, LIFETIME, LAYOUT).
type DictionaryDefinition struct {
Position token.Position `json:"-"`
PrimaryKey []Expression `json:"primary_key,omitempty"`
Source *DictionarySource `json:"source,omitempty"`
Lifetime *DictionaryLifetime `json:"lifetime,omitempty"`
Layout *DictionaryLayout `json:"layout,omitempty"`
Range *DictionaryRange `json:"range,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
}
func (d *DictionaryDefinition) Pos() token.Position { return d.Position }
func (d *DictionaryDefinition) End() token.Position { return d.Position }
// DictionarySource represents the SOURCE clause of a dictionary.
type DictionarySource struct {
Position token.Position `json:"-"`
Type string `json:"type"` // e.g., "CLICKHOUSE", "MYSQL", "FILE"
Args []*KeyValuePair `json:"args,omitempty"`
}
func (d *DictionarySource) Pos() token.Position { return d.Position }
func (d *DictionarySource) End() token.Position { return d.Position }
// KeyValuePair represents a key-value pair in dictionary source or other contexts.
type KeyValuePair struct {
Position token.Position `json:"-"`
Key string `json:"key"`
Value Expression `json:"value"`
}
func (k *KeyValuePair) Pos() token.Position { return k.Position }
func (k *KeyValuePair) End() token.Position { return k.Position }
// DictionaryLifetime represents the LIFETIME clause of a dictionary.
type DictionaryLifetime struct {
Position token.Position `json:"-"`
Min Expression `json:"min,omitempty"`
Max Expression `json:"max,omitempty"`
}
func (d *DictionaryLifetime) Pos() token.Position { return d.Position }
func (d *DictionaryLifetime) End() token.Position { return d.Position }
// DictionaryLayout represents the LAYOUT clause of a dictionary.
type DictionaryLayout struct {
Position token.Position `json:"-"`
Type string `json:"type"` // e.g., "FLAT", "HASHED", "COMPLEX_KEY_HASHED"
Args []*KeyValuePair `json:"args,omitempty"`
}
func (d *DictionaryLayout) Pos() token.Position { return d.Position }
func (d *DictionaryLayout) End() token.Position { return d.Position }
// DictionaryRange represents the RANGE clause of a dictionary.
type DictionaryRange struct {
Position token.Position `json:"-"`
Min Expression `json:"min,omitempty"`
Max Expression `json:"max,omitempty"`
}
func (d *DictionaryRange) Pos() token.Position { return d.Position }
func (d *DictionaryRange) End() token.Position { return d.Position }
// DataType represents a data type.
type DataType struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Parameters []Expression `json:"parameters,omitempty"`
HasParentheses bool `json:"has_parentheses,omitempty"`
}
func (d *DataType) Pos() token.Position { return d.Position }
func (d *DataType) End() token.Position { return d.Position }
func (d *DataType) expressionNode() {}
// ObjectTypeArgument wraps an expression that is an argument to JSON/OBJECT types.
// This matches ClickHouse's ASTObjectTypeArgument node structure.
type ObjectTypeArgument struct {
Position token.Position `json:"-"`
Expr Expression `json:"expr"`
}
func (o *ObjectTypeArgument) Pos() token.Position { return o.Position }
func (o *ObjectTypeArgument) End() token.Position { return o.Position }
func (o *ObjectTypeArgument) expressionNode() {}
// NameTypePair represents a named type pair, used in Nested types.
type NameTypePair struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Type *DataType `json:"type"`
}
func (n *NameTypePair) Pos() token.Position { return n.Position }
func (n *NameTypePair) End() token.Position { return n.Position }
func (n *NameTypePair) expressionNode() {}
// CodecExpr represents a CODEC expression.
type CodecExpr struct {
Position token.Position `json:"-"`
Codecs []*FunctionCall `json:"codecs"`
}
func (c *CodecExpr) Pos() token.Position { return c.Position }
func (c *CodecExpr) End() token.Position { return c.Position }
// IndexDefinition represents an INDEX definition in CREATE TABLE.
type IndexDefinition struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Expression Expression `json:"expression"`
Type *FunctionCall `json:"type"`
Granularity Expression `json:"granularity,omitempty"`
}
func (i *IndexDefinition) Pos() token.Position { return i.Position }
func (i *IndexDefinition) End() token.Position { return i.Position }
func (i *IndexDefinition) expressionNode() {}
// Constraint represents a table constraint.
type Constraint struct {
Position token.Position `json:"-"`
Name string `json:"name,omitempty"`
Expression Expression `json:"expression"`
}
func (c *Constraint) Pos() token.Position { return c.Position }
func (c *Constraint) End() token.Position { return c.Position }
// EngineClause represents an ENGINE clause.
type EngineClause struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Parameters []Expression `json:"parameters,omitempty"`
HasParentheses bool `json:"has_parentheses,omitempty"` // true if called with ()
}
func (e *EngineClause) Pos() token.Position { return e.Position }
func (e *EngineClause) End() token.Position { return e.Position }
// TTLClause represents a TTL clause.
type TTLClause struct {
Position token.Position `json:"-"`
Expression Expression `json:"expression"`
Expressions []Expression `json:"expressions,omitempty"` // Additional TTL expressions (for multiple TTL elements)
Elements []*TTLElement `json:"elements,omitempty"` // TTL elements with WHERE conditions
}
func (t *TTLClause) Pos() token.Position { return t.Position }
func (t *TTLClause) End() token.Position { return t.Position }
// TTLElement represents a single TTL element with optional WHERE condition.
type TTLElement struct {
Position token.Position `json:"-"`
Expr Expression `json:"expr"`
Where Expression `json:"where,omitempty"` // WHERE condition for DELETE
}
func (t *TTLElement) Pos() token.Position { return t.Position }
func (t *TTLElement) End() token.Position { return t.Position }
// DropQuery represents a DROP statement.
type DropQuery struct {
Position token.Position `json:"-"`
IfExists bool `json:"if_exists,omitempty"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
Tables []*TableIdentifier `json:"tables,omitempty"` // For DROP TABLE t1, t2, t3
View string `json:"view,omitempty"`
User string `json:"user,omitempty"`
Function string `json:"function,omitempty"` // For DROP FUNCTION
Dictionary string `json:"-"` // For DROP DICTIONARY (format only, not in AST JSON)
Role string `json:"role,omitempty"` // For DROP ROLE
Quota string `json:"quota,omitempty"` // For DROP QUOTA
Policy string `json:"policy,omitempty"` // For DROP POLICY
RowPolicy string `json:"row_policy,omitempty"` // For DROP ROW POLICY
SettingsProfile string `json:"settings_profile,omitempty"` // For DROP SETTINGS PROFILE
Index string `json:"index,omitempty"` // For DROP INDEX
Temporary bool `json:"temporary,omitempty"`
OnCluster string `json:"on_cluster,omitempty"`
DropDatabase bool `json:"drop_database,omitempty"`
Sync bool `json:"sync,omitempty"`
Format string `json:"format,omitempty"` // For FORMAT clause
Settings []*SettingExpr `json:"settings,omitempty"` // For SETTINGS clause
}
func (d *DropQuery) Pos() token.Position { return d.Position }
func (d *DropQuery) End() token.Position { return d.Position }
func (d *DropQuery) statementNode() {}
// UndropQuery represents an UNDROP TABLE statement.
type UndropQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table"`
OnCluster string `json:"on_cluster,omitempty"`
UUID string `json:"uuid,omitempty"`
Format string `json:"format,omitempty"`
}
func (u *UndropQuery) Pos() token.Position { return u.Position }
func (u *UndropQuery) End() token.Position { return u.Position }
func (u *UndropQuery) statementNode() {}
// UpdateQuery represents a standalone UPDATE statement.
// In ClickHouse, UPDATE is syntactic sugar for ALTER TABLE ... UPDATE
type UpdateQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table"`
Assignments []*Assignment `json:"assignments"`
Where Expression `json:"where,omitempty"`
}
func (u *UpdateQuery) Pos() token.Position { return u.Position }
func (u *UpdateQuery) End() token.Position { return u.Position }
func (u *UpdateQuery) statementNode() {}
// AlterQuery represents an ALTER statement.
type AlterQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table"`
Commands []*AlterCommand `json:"commands"`
OnCluster string `json:"on_cluster,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
Format string `json:"format,omitempty"` // For FORMAT clause
}
func (a *AlterQuery) Pos() token.Position { return a.Position }
func (a *AlterQuery) End() token.Position { return a.Position }
func (a *AlterQuery) statementNode() {}
// AlterCommand represents an ALTER command.
type AlterCommand struct {
Position token.Position `json:"-"`
Type AlterCommandType `json:"type"`
Column *ColumnDeclaration `json:"column,omitempty"`
ColumnName string `json:"column_name,omitempty"`
AfterColumn string `json:"after_column,omitempty"`
NewName string `json:"new_name,omitempty"`
IfNotExists bool `json:"if_not_exists,omitempty"`
IfExists bool `json:"if_exists,omitempty"`
Index string `json:"index,omitempty"`
IndexExpr Expression `json:"index_expr,omitempty"`
IndexType string `json:"index_type,omitempty"`
IndexDef *IndexDefinition `json:"index_def,omitempty"` // For ADD INDEX with full definition
Granularity int `json:"granularity,omitempty"`
AfterIndex string `json:"after_index,omitempty"` // For ADD INDEX ... AFTER name
Constraint *Constraint `json:"constraint,omitempty"`
ConstraintName string `json:"constraint_name,omitempty"`
Partition Expression `json:"partition,omitempty"`
PartitionIsID bool `json:"partition_is_id,omitempty"` // True when using PARTITION ID 'value' syntax
IsPart bool `json:"-"` // True for PART (not PARTITION) - output directly without Partition wrapper
FromTable string `json:"from_table,omitempty"`
ToDatabase string `json:"to_database,omitempty"` // For MOVE PARTITION TO TABLE
ToTable string `json:"to_table,omitempty"` // For MOVE PARTITION TO TABLE
FromPath string `json:"from_path,omitempty"` // For FETCH PARTITION FROM
TTL *TTLClause `json:"ttl,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
Where Expression `json:"where,omitempty"` // For DELETE WHERE
Assignments []*Assignment `json:"assignments,omitempty"` // For UPDATE
Projection *Projection `json:"projection,omitempty"` // For ADD PROJECTION
ProjectionName string `json:"projection_name,omitempty"` // For DROP/MATERIALIZE/CLEAR PROJECTION
StatisticsColumns []string `json:"statistics_columns,omitempty"` // For ADD/DROP/CLEAR/MATERIALIZE STATISTICS
StatisticsTypes []*FunctionCall `json:"statistics_types,omitempty"` // For ADD/MODIFY STATISTICS TYPE
Comment string `json:"comment,omitempty"` // For COMMENT COLUMN
OrderByExpr []Expression `json:"order_by_expr,omitempty"` // For MODIFY ORDER BY
SampleByExpr Expression `json:"sample_by_expr,omitempty"` // For MODIFY SAMPLE BY
ResetSettings []string `json:"reset_settings,omitempty"` // For MODIFY COLUMN ... RESET SETTING
Query Statement `json:"query,omitempty"` // For MODIFY QUERY
}
// Projection represents a projection definition.
type Projection struct {
Position token.Position `json:"-"`
Name string `json:"name"`
Select *ProjectionSelectQuery `json:"select"`
}
func (p *Projection) Pos() token.Position { return p.Position }
func (p *Projection) End() token.Position { return p.Position }
// ProjectionSelectQuery represents the SELECT part of a projection.
type ProjectionSelectQuery struct {
Position token.Position `json:"-"`
With []Expression `json:"with,omitempty"` // WITH clause expressions
Columns []Expression `json:"columns"`
GroupBy []Expression `json:"group_by,omitempty"`
OrderBy []Expression `json:"order_by,omitempty"` // ORDER BY columns
}
// Assignment represents a column assignment in UPDATE.
type Assignment struct {
Position token.Position `json:"-"`
Column string `json:"column"`
Value Expression `json:"value"`
}
func (a *Assignment) Pos() token.Position { return a.Position }
func (a *Assignment) End() token.Position { return a.Position }
func (a *AlterCommand) Pos() token.Position { return a.Position }
func (a *AlterCommand) End() token.Position { return a.Position }
// AlterCommandType represents the type of ALTER command.
type AlterCommandType string
const (
AlterAddColumn AlterCommandType = "ADD_COLUMN"
AlterDropColumn AlterCommandType = "DROP_COLUMN"
AlterModifyColumn AlterCommandType = "MODIFY_COLUMN"
AlterRenameColumn AlterCommandType = "RENAME_COLUMN"
AlterClearColumn AlterCommandType = "CLEAR_COLUMN"
AlterMaterializeColumn AlterCommandType = "MATERIALIZE_COLUMN"
AlterCommentColumn AlterCommandType = "COMMENT_COLUMN"
AlterAddIndex AlterCommandType = "ADD_INDEX"
AlterDropIndex AlterCommandType = "DROP_INDEX"
AlterClearIndex AlterCommandType = "CLEAR_INDEX"
AlterMaterializeIndex AlterCommandType = "MATERIALIZE_INDEX"
AlterAddConstraint AlterCommandType = "ADD_CONSTRAINT"
AlterDropConstraint AlterCommandType = "DROP_CONSTRAINT"
AlterModifyTTL AlterCommandType = "MODIFY_TTL"
AlterMaterializeTTL AlterCommandType = "MATERIALIZE_TTL"
AlterRemoveTTL AlterCommandType = "REMOVE_TTL"
AlterModifySetting AlterCommandType = "MODIFY_SETTING"
AlterResetSetting AlterCommandType = "RESET_SETTING"
AlterDropPartition AlterCommandType = "DROP_PARTITION"
AlterDropDetachedPartition AlterCommandType = "DROP_DETACHED_PARTITION"
AlterDetachPartition AlterCommandType = "DETACH_PARTITION"
AlterAttachPartition AlterCommandType = "ATTACH_PARTITION"
AlterReplacePartition AlterCommandType = "REPLACE_PARTITION"
AlterFetchPartition AlterCommandType = "FETCH_PARTITION"
AlterMovePartition AlterCommandType = "MOVE_PARTITION"
AlterFreezePartition AlterCommandType = "FREEZE_PARTITION"
AlterFreeze AlterCommandType = "FREEZE"
AlterApplyPatches AlterCommandType = "APPLY_PATCHES"
AlterDeleteWhere AlterCommandType = "DELETE_WHERE"
AlterUpdate AlterCommandType = "UPDATE"
AlterAddProjection AlterCommandType = "ADD_PROJECTION"
AlterDropProjection AlterCommandType = "DROP_PROJECTION"
AlterMaterializeProjection AlterCommandType = "MATERIALIZE_PROJECTION"
AlterClearProjection AlterCommandType = "CLEAR_PROJECTION"
AlterAddStatistics AlterCommandType = "ADD_STATISTICS"
AlterModifyStatistics AlterCommandType = "MODIFY_STATISTICS"
AlterDropStatistics AlterCommandType = "DROP_STATISTICS"
AlterClearStatistics AlterCommandType = "CLEAR_STATISTICS"
AlterMaterializeStatistics AlterCommandType = "MATERIALIZE_STATISTICS"
AlterModifyComment AlterCommandType = "MODIFY_COMMENT"
AlterModifyOrderBy AlterCommandType = "MODIFY_ORDER_BY"
AlterModifySampleBy AlterCommandType = "MODIFY_SAMPLE_BY"
AlterModifyQuery AlterCommandType = "MODIFY_QUERY"
AlterRemoveSampleBy AlterCommandType = "REMOVE_SAMPLE_BY"
AlterApplyDeletedMask AlterCommandType = "APPLY_DELETED_MASK"
)
// TruncateQuery represents a TRUNCATE statement.
type TruncateQuery struct {
Position token.Position `json:"-"`
Temporary bool `json:"temporary,omitempty"`
IfExists bool `json:"if_exists,omitempty"`
TruncateDatabase bool `json:"truncate_database,omitempty"` // True for TRUNCATE DATABASE
Database string `json:"database,omitempty"`
Table string `json:"table"`
OnCluster string `json:"on_cluster,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
}
func (t *TruncateQuery) Pos() token.Position { return t.Position }
func (t *TruncateQuery) End() token.Position { return t.Position }
func (t *TruncateQuery) statementNode() {}
// DeleteQuery represents a lightweight DELETE statement.
type DeleteQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table"`
OnCluster string `json:"on_cluster,omitempty"` // ON CLUSTER clause
Partition Expression `json:"partition,omitempty"` // IN PARTITION clause
Where Expression `json:"where,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
}
func (d *DeleteQuery) Pos() token.Position { return d.Position }
func (d *DeleteQuery) End() token.Position { return d.Position }
func (d *DeleteQuery) statementNode() {}
// UseQuery represents a USE statement.
type UseQuery struct {
Position token.Position `json:"-"`
Database string `json:"database"`
}
func (u *UseQuery) Pos() token.Position { return u.Position }
func (u *UseQuery) End() token.Position { return u.Position }
func (u *UseQuery) statementNode() {}
// DetachQuery represents a DETACH statement.
type DetachQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
Dictionary string `json:"dictionary,omitempty"`
}
func (d *DetachQuery) Pos() token.Position { return d.Position }
func (d *DetachQuery) End() token.Position { return d.Position }
func (d *DetachQuery) statementNode() {}
// AttachQuery represents an ATTACH statement.
type AttachQuery struct {
Position token.Position `json:"-"`
IfNotExists bool `json:"if_not_exists,omitempty"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
Dictionary string `json:"dictionary,omitempty"`
FromPath string `json:"from_path,omitempty"` // FROM 'path' clause
Columns []*ColumnDeclaration `json:"columns,omitempty"`
ColumnsPrimaryKey []Expression `json:"columns_primary_key,omitempty"` // PRIMARY KEY in column list
HasEmptyColumnsPrimaryKey bool `json:"has_empty_columns_primary_key,omitempty"` // TRUE if PRIMARY KEY () was seen with empty parens
Indexes []*IndexDefinition `json:"indexes,omitempty"` // INDEX definitions in column list
Engine *EngineClause `json:"engine,omitempty"`
OrderBy []Expression `json:"order_by,omitempty"`
PrimaryKey []Expression `json:"primary_key,omitempty"`
IsMaterializedView bool `json:"is_materialized_view,omitempty"`
UUID string `json:"uuid,omitempty"` // UUID clause
InnerUUID string `json:"inner_uuid,omitempty"` // TO INNER UUID clause
PartitionBy Expression `json:"partition_by,omitempty"`
SelectQuery Statement `json:"select_query,omitempty"` // AS SELECT clause
Settings []*SettingExpr `json:"settings,omitempty"` // SETTINGS clause
}
func (a *AttachQuery) Pos() token.Position { return a.Position }
func (a *AttachQuery) End() token.Position { return a.Position }
func (a *AttachQuery) statementNode() {}
// BackupQuery represents a BACKUP statement.
type BackupQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
Dictionary string `json:"dictionary,omitempty"`
All bool `json:"all,omitempty"` // BACKUP ALL
Temporary bool `json:"temporary,omitempty"`
Target *FunctionCall `json:"target,omitempty"` // Disk('path') or Null
Settings []*SettingExpr `json:"settings,omitempty"`
Format string `json:"format,omitempty"`
}
func (b *BackupQuery) Pos() token.Position { return b.Position }
func (b *BackupQuery) End() token.Position { return b.Position }
func (b *BackupQuery) statementNode() {}
// RestoreQuery represents a RESTORE statement.
type RestoreQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
Dictionary string `json:"dictionary,omitempty"`
All bool `json:"all,omitempty"` // RESTORE ALL
Temporary bool `json:"temporary,omitempty"`
Source *FunctionCall `json:"source,omitempty"` // Disk('path') or Null
Settings []*SettingExpr `json:"settings,omitempty"`
Format string `json:"format,omitempty"`
}
func (r *RestoreQuery) Pos() token.Position { return r.Position }
func (r *RestoreQuery) End() token.Position { return r.Position }
func (r *RestoreQuery) statementNode() {}
// DescribeQuery represents a DESCRIBE statement.
type DescribeQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
TableFunction *FunctionCall `json:"table_function,omitempty"`
TableExpr *TableExpression `json:"table_expr,omitempty"` // For DESCRIBE (SELECT ...)
Settings []*SettingExpr `json:"settings,omitempty"`
Format string `json:"format,omitempty"`
}
func (d *DescribeQuery) Pos() token.Position { return d.Position }
func (d *DescribeQuery) End() token.Position { return d.Position }
func (d *DescribeQuery) statementNode() {}
// ShowQuery represents a SHOW statement.
type ShowQuery struct {
Position token.Position `json:"-"`
ShowType ShowType `json:"show_type"`
Temporary bool `json:"temporary,omitempty"`
Database string `json:"database,omitempty"`
From string `json:"from,omitempty"`
Like string `json:"like,omitempty"`
Where Expression `json:"where,omitempty"`
Limit Expression `json:"limit,omitempty"`
Format string `json:"format,omitempty"`
HasSettings bool `json:"has_settings,omitempty"` // Whether SETTINGS clause was specified
MultipleUsers bool `json:"multiple_users,omitempty"` // True when SHOW CREATE USER has multiple users
}
func (s *ShowQuery) Pos() token.Position { return s.Position }
func (s *ShowQuery) End() token.Position { return s.Position }
func (s *ShowQuery) statementNode() {}
// ShowType represents the type of SHOW statement.
type ShowType string
const (
ShowTables ShowType = "TABLES"
ShowDatabases ShowType = "DATABASES"
ShowProcesses ShowType = "PROCESSLIST"
ShowCreate ShowType = "CREATE"
ShowCreateDB ShowType = "CREATE_DATABASE"
ShowCreateDictionary ShowType = "CREATE_DICTIONARY"
ShowCreateView ShowType = "CREATE_VIEW"
ShowCreateUser ShowType = "CREATE_USER"
ShowCreateRole ShowType = "CREATE_ROLE"
ShowCreatePolicy ShowType = "CREATE_POLICY"
ShowCreateRowPolicy ShowType = "CREATE_ROW_POLICY"
ShowCreateQuota ShowType = "CREATE_QUOTA"
ShowCreateSettingsProfile ShowType = "CREATE_SETTINGS_PROFILE"
ShowColumns ShowType = "COLUMNS"
ShowDictionaries ShowType = "DICTIONARIES"
ShowFunctions ShowType = "FUNCTIONS"
ShowSettings ShowType = "SETTINGS"
ShowSetting ShowType = "SETTING"
ShowGrants ShowType = "GRANTS"
)
// ExplainQuery represents an EXPLAIN statement.
type ExplainQuery struct {
Position token.Position `json:"-"`
ExplainType ExplainType `json:"explain_type"`
Statement Statement `json:"statement"`
HasSettings bool `json:"has_settings,omitempty"`
ExplicitType bool `json:"explicit_type,omitempty"` // true if type was explicitly specified
OptionsString string `json:"options_string,omitempty"` // Formatted options like "actions = 1"
}
func (e *ExplainQuery) Pos() token.Position { return e.Position }
func (e *ExplainQuery) End() token.Position { return e.Position }
func (e *ExplainQuery) statementNode() {}
// ExplainType represents the type of EXPLAIN.
type ExplainType string
const (
ExplainAST ExplainType = "AST"
ExplainSyntax ExplainType = "SYNTAX"
ExplainPlan ExplainType = "PLAN"
ExplainPipeline ExplainType = "PIPELINE"
ExplainEstimate ExplainType = "ESTIMATE"
ExplainQueryTree ExplainType = "QUERY TREE"
ExplainCurrentTransaction ExplainType = "CURRENT TRANSACTION"
)
// SetQuery represents a SET statement.
type SetQuery struct {
Position token.Position `json:"-"`
Settings []*SettingExpr `json:"settings"`
}
func (s *SetQuery) Pos() token.Position { return s.Position }
func (s *SetQuery) End() token.Position { return s.Position }
func (s *SetQuery) statementNode() {}
// OptimizeQuery represents an OPTIMIZE statement.
type OptimizeQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table"`
Partition Expression `json:"partition,omitempty"`
PartitionByID bool `json:"partition_by_id,omitempty"` // PARTITION ID vs PARTITION expr
Final bool `json:"final,omitempty"`
Cleanup bool `json:"cleanup,omitempty"`
Dedupe bool `json:"dedupe,omitempty"`
OnCluster string `json:"on_cluster,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
}
func (o *OptimizeQuery) Pos() token.Position { return o.Position }
func (o *OptimizeQuery) End() token.Position { return o.Position }
func (o *OptimizeQuery) statementNode() {}
// CheckQuery represents a CHECK TABLE statement.
type CheckQuery struct {
Position token.Position `json:"-"`
Database string `json:"database,omitempty"`
Table string `json:"table"`
Partition Expression `json:"partition,omitempty"`
Part Expression `json:"part,omitempty"`
Format string `json:"format,omitempty"`
Settings []*SettingExpr `json:"settings,omitempty"`
}
func (c *CheckQuery) Pos() token.Position { return c.Position }
func (c *CheckQuery) End() token.Position { return c.Position }
func (c *CheckQuery) statementNode() {}
// SystemQuery represents a SYSTEM statement.
type SystemQuery struct {
Position token.Position `json:"-"`
Command string `json:"command"`
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
OnCluster string `json:"on_cluster,omitempty"`
DuplicateTableOutput bool `json:"duplicate_table_output,omitempty"` // True for commands that need database/table output twice
Settings []*SettingExpr `json:"settings,omitempty"`
}
func (s *SystemQuery) Pos() token.Position { return s.Position }
func (s *SystemQuery) End() token.Position { return s.Position }
func (s *SystemQuery) statementNode() {}
// TransactionControlQuery represents a transaction control statement (BEGIN, COMMIT, ROLLBACK, SET TRANSACTION SNAPSHOT).
type TransactionControlQuery struct {
Position token.Position `json:"-"`
Action string `json:"action"` // "BEGIN", "COMMIT", "ROLLBACK", "SET_SNAPSHOT"
Snapshot int64 `json:"snapshot,omitempty"`
}
func (t *TransactionControlQuery) Pos() token.Position { return t.Position }
func (t *TransactionControlQuery) End() token.Position { return t.Position }
func (t *TransactionControlQuery) statementNode() {}
// RenamePair represents a single rename pair in RENAME TABLE.
type RenamePair struct {
FromDatabase string `json:"from_database,omitempty"`
FromTable string `json:"from_table"`
ToDatabase string `json:"to_database,omitempty"`
ToTable string `json:"to_table"`
}
// RenameQuery represents a RENAME TABLE statement.
type RenameQuery struct {
Position token.Position `json:"-"`