Skip to main content

polyglot_sql/
expressions.rs

1//! SQL Expression AST (Abstract Syntax Tree).
2//!
3//! This module defines all the AST node types used to represent parsed SQL
4//! statements and expressions. The design follows Python sqlglot's expression
5//! hierarchy, ported to a Rust enum-based AST.
6//!
7//! # Architecture
8//!
9//! The central type is [`Expression`], a large tagged enum with one variant per
10//! SQL construct. Inner structs carry the fields for each variant. Most
11//! heap-allocated variants are wrapped in `Box` to keep the enum size small.
12//!
13//! # Variant Groups
14//!
15//! | Group | Examples | Purpose |
16//! |---|---|---|
17//! | **Queries** | `Select`, `Union`, `Intersect`, `Except`, `Subquery` | Top-level query structures |
18//! | **DML** | `Insert`, `Update`, `Delete`, `Merge`, `Copy` | Data manipulation |
19//! | **DDL** | `CreateTable`, `AlterTable`, `DropView`, `CreateIndex` | Schema definition |
20//! | **Clauses** | `From`, `Join`, `Where`, `GroupBy`, `OrderBy`, `With` | Query clauses |
21//! | **Operators** | `And`, `Or`, `Add`, `Eq`, `Like`, `Not` | Binary and unary operations |
22//! | **Functions** | `Function`, `AggregateFunction`, `WindowFunction`, `Count`, `Sum` | Scalar, aggregate, and window functions |
23//! | **Literals** | `Literal`, `Boolean`, `Null`, `Interval` | Constant values |
24//! | **Types** | `DataType`, `Cast`, `TryCast`, `SafeCast` | Data types and casts |
25//! | **Identifiers** | `Identifier`, `Column`, `Table`, `Star` | Name references |
26//!
27//! # SQL Generation
28//!
29//! Every `Expression` can be rendered back to SQL via [`Expression::sql()`]
30//! (generic dialect) or [`Expression::sql_for()`] (specific dialect). The
31//! actual generation logic lives in the `generator` module.
32
33use serde::{Deserialize, Serialize};
34use std::fmt;
35#[cfg(feature = "bindings")]
36use ts_rs::TS;
37
38/// Helper function for serde default value
39fn default_true() -> bool {
40    true
41}
42
43fn is_true(v: &bool) -> bool {
44    *v
45}
46
47/// Represent any SQL expression or statement as a single, recursive AST node.
48///
49/// `Expression` is the root type of the polyglot AST. Every parsed SQL
50/// construct -- from a simple integer literal to a multi-CTE query with
51/// window functions -- is represented as a variant of this enum.
52///
53/// Variants are organized into logical groups (see the module-level docs).
54/// Most non-trivial variants box their payload so that `size_of::<Expression>()`
55/// stays small (currently two words: tag + pointer).
56///
57/// # Constructing Expressions
58///
59/// Use the convenience constructors on `impl Expression` for common cases:
60///
61/// ```rust,ignore
62/// use polyglot_sql::expressions::Expression;
63///
64/// let col  = Expression::column("id");
65/// let lit  = Expression::number(42);
66/// let star = Expression::star();
67/// ```
68///
69/// # Generating SQL
70///
71/// ```rust,ignore
72/// let expr = Expression::column("name");
73/// assert_eq!(expr.sql(), "name");
74/// ```
75#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
76#[cfg_attr(feature = "bindings", derive(TS))]
77#[serde(rename_all = "snake_case")]
78#[cfg_attr(feature = "bindings", ts(export))]
79pub enum Expression {
80    // Literals
81    Literal(Literal),
82    Boolean(BooleanLiteral),
83    Null(Null),
84
85    // Identifiers
86    Identifier(Identifier),
87    Column(Column),
88    Table(TableRef),
89    Star(Star),
90    /// Snowflake braced wildcard syntax: {*}, {tbl.*}, {* EXCLUDE (...)}, {* ILIKE '...'}
91    BracedWildcard(Box<Expression>),
92
93    // Queries
94    Select(Box<Select>),
95    Union(Box<Union>),
96    Intersect(Box<Intersect>),
97    Except(Box<Except>),
98    Subquery(Box<Subquery>),
99    PipeOperator(Box<PipeOperator>),
100    Pivot(Box<Pivot>),
101    PivotAlias(Box<PivotAlias>),
102    Unpivot(Box<Unpivot>),
103    Values(Box<Values>),
104    PreWhere(Box<PreWhere>),
105    Stream(Box<Stream>),
106    UsingData(Box<UsingData>),
107    XmlNamespace(Box<XmlNamespace>),
108
109    // DML
110    Insert(Box<Insert>),
111    Update(Box<Update>),
112    Delete(Box<Delete>),
113    Copy(Box<CopyStmt>),
114    Put(Box<PutStmt>),
115    StageReference(Box<StageReference>),
116
117    // Expressions
118    Alias(Box<Alias>),
119    Cast(Box<Cast>),
120    Collation(Box<CollationExpr>),
121    Case(Box<Case>),
122
123    // Binary operations
124    And(Box<BinaryOp>),
125    Or(Box<BinaryOp>),
126    Add(Box<BinaryOp>),
127    Sub(Box<BinaryOp>),
128    Mul(Box<BinaryOp>),
129    Div(Box<BinaryOp>),
130    Mod(Box<BinaryOp>),
131    Eq(Box<BinaryOp>),
132    Neq(Box<BinaryOp>),
133    Lt(Box<BinaryOp>),
134    Lte(Box<BinaryOp>),
135    Gt(Box<BinaryOp>),
136    Gte(Box<BinaryOp>),
137    Like(Box<LikeOp>),
138    ILike(Box<LikeOp>),
139    /// SQLite MATCH operator (FTS)
140    Match(Box<BinaryOp>),
141    BitwiseAnd(Box<BinaryOp>),
142    BitwiseOr(Box<BinaryOp>),
143    BitwiseXor(Box<BinaryOp>),
144    Concat(Box<BinaryOp>),
145    Adjacent(Box<BinaryOp>),  // PostgreSQL range adjacency operator (-|-)
146    TsMatch(Box<BinaryOp>),   // PostgreSQL text search match operator (@@)
147    PropertyEQ(Box<BinaryOp>), // := assignment operator (MySQL @var := val, DuckDB named args)
148
149    // PostgreSQL array/JSONB operators
150    ArrayContainsAll(Box<BinaryOp>),       // @> operator (array contains all)
151    ArrayContainedBy(Box<BinaryOp>),       // <@ operator (array contained by)
152    ArrayOverlaps(Box<BinaryOp>),          // && operator (array overlaps)
153    JSONBContainsAllTopKeys(Box<BinaryOp>), // ?& operator (JSONB contains all keys)
154    JSONBContainsAnyTopKeys(Box<BinaryOp>), // ?| operator (JSONB contains any key)
155    JSONBDeleteAtPath(Box<BinaryOp>),      // #- operator (JSONB delete at path)
156    ExtendsLeft(Box<BinaryOp>),            // &< operator (PostgreSQL range extends left)
157    ExtendsRight(Box<BinaryOp>),           // &> operator (PostgreSQL range extends right)
158
159    // Unary operations
160    Not(Box<UnaryOp>),
161    Neg(Box<UnaryOp>),
162    BitwiseNot(Box<UnaryOp>),
163
164    // Predicates
165    In(Box<In>),
166    Between(Box<Between>),
167    IsNull(Box<IsNull>),
168    IsTrue(Box<IsTrueFalse>),
169    IsFalse(Box<IsTrueFalse>),
170    IsJson(Box<IsJson>),
171    Is(Box<BinaryOp>),  // General IS expression (e.g., a IS ?)
172    Exists(Box<Exists>),
173    /// MySQL MEMBER OF operator: expr MEMBER OF(json_array)
174    MemberOf(Box<BinaryOp>),
175
176    // Functions
177    Function(Box<Function>),
178    AggregateFunction(Box<AggregateFunction>),
179    WindowFunction(Box<WindowFunction>),
180
181    // Clauses
182    From(Box<From>),
183    Join(Box<Join>),
184    JoinedTable(Box<JoinedTable>),
185    Where(Box<Where>),
186    GroupBy(Box<GroupBy>),
187    Having(Box<Having>),
188    OrderBy(Box<OrderBy>),
189    Limit(Box<Limit>),
190    Offset(Box<Offset>),
191    Qualify(Box<Qualify>),
192    With(Box<With>),
193    Cte(Box<Cte>),
194    DistributeBy(Box<DistributeBy>),
195    ClusterBy(Box<ClusterBy>),
196    SortBy(Box<SortBy>),
197    LateralView(Box<LateralView>),
198    Hint(Box<Hint>),
199    Pseudocolumn(Pseudocolumn),
200
201    // Oracle hierarchical queries (CONNECT BY)
202    Connect(Box<Connect>),
203    Prior(Box<Prior>),
204    ConnectByRoot(Box<ConnectByRoot>),
205
206    // Pattern matching (MATCH_RECOGNIZE)
207    MatchRecognize(Box<MatchRecognize>),
208
209    // Order expressions
210    Ordered(Box<Ordered>),
211
212    // Window specifications
213    Window(Box<WindowSpec>),
214    Over(Box<Over>),
215    WithinGroup(Box<WithinGroup>),
216
217    // Data types
218    DataType(DataType),
219
220    // Arrays and structs
221    Array(Box<Array>),
222    Struct(Box<Struct>),
223    Tuple(Box<Tuple>),
224
225    // Interval
226    Interval(Box<Interval>),
227
228    // String functions
229    ConcatWs(Box<ConcatWs>),
230    Substring(Box<SubstringFunc>),
231    Upper(Box<UnaryFunc>),
232    Lower(Box<UnaryFunc>),
233    Length(Box<UnaryFunc>),
234    Trim(Box<TrimFunc>),
235    LTrim(Box<UnaryFunc>),
236    RTrim(Box<UnaryFunc>),
237    Replace(Box<ReplaceFunc>),
238    Reverse(Box<UnaryFunc>),
239    Left(Box<LeftRightFunc>),
240    Right(Box<LeftRightFunc>),
241    Repeat(Box<RepeatFunc>),
242    Lpad(Box<PadFunc>),
243    Rpad(Box<PadFunc>),
244    Split(Box<SplitFunc>),
245    RegexpLike(Box<RegexpFunc>),
246    RegexpReplace(Box<RegexpReplaceFunc>),
247    RegexpExtract(Box<RegexpExtractFunc>),
248    Overlay(Box<OverlayFunc>),
249
250    // Math functions
251    Abs(Box<UnaryFunc>),
252    Round(Box<RoundFunc>),
253    Floor(Box<FloorFunc>),
254    Ceil(Box<CeilFunc>),
255    Power(Box<BinaryFunc>),
256    Sqrt(Box<UnaryFunc>),
257    Cbrt(Box<UnaryFunc>),
258    Ln(Box<UnaryFunc>),
259    Log(Box<LogFunc>),
260    Exp(Box<UnaryFunc>),
261    Sign(Box<UnaryFunc>),
262    Greatest(Box<VarArgFunc>),
263    Least(Box<VarArgFunc>),
264
265    // Date/time functions
266    CurrentDate(CurrentDate),
267    CurrentTime(CurrentTime),
268    CurrentTimestamp(CurrentTimestamp),
269    CurrentTimestampLTZ(CurrentTimestampLTZ),
270    AtTimeZone(Box<AtTimeZone>),
271    DateAdd(Box<DateAddFunc>),
272    DateSub(Box<DateAddFunc>),
273    DateDiff(Box<DateDiffFunc>),
274    DateTrunc(Box<DateTruncFunc>),
275    Extract(Box<ExtractFunc>),
276    ToDate(Box<ToDateFunc>),
277    ToTimestamp(Box<ToTimestampFunc>),
278    Date(Box<UnaryFunc>),
279    Time(Box<UnaryFunc>),
280    DateFromUnixDate(Box<UnaryFunc>),
281    UnixDate(Box<UnaryFunc>),
282    UnixSeconds(Box<UnaryFunc>),
283    UnixMillis(Box<UnaryFunc>),
284    UnixMicros(Box<UnaryFunc>),
285    UnixToTimeStr(Box<BinaryFunc>),
286    TimeStrToDate(Box<UnaryFunc>),
287    DateToDi(Box<UnaryFunc>),
288    DiToDate(Box<UnaryFunc>),
289    TsOrDiToDi(Box<UnaryFunc>),
290    TsOrDsToDatetime(Box<UnaryFunc>),
291    TsOrDsToTimestamp(Box<UnaryFunc>),
292    YearOfWeek(Box<UnaryFunc>),
293    YearOfWeekIso(Box<UnaryFunc>),
294
295    // Control flow functions
296    Coalesce(Box<VarArgFunc>),
297    NullIf(Box<BinaryFunc>),
298    IfFunc(Box<IfFunc>),
299    IfNull(Box<BinaryFunc>),
300    Nvl(Box<BinaryFunc>),
301    Nvl2(Box<Nvl2Func>),
302
303    // Type conversion
304    TryCast(Box<Cast>),
305    SafeCast(Box<Cast>),
306
307    // Typed aggregate functions
308    Count(Box<CountFunc>),
309    Sum(Box<AggFunc>),
310    Avg(Box<AggFunc>),
311    Min(Box<AggFunc>),
312    Max(Box<AggFunc>),
313    GroupConcat(Box<GroupConcatFunc>),
314    StringAgg(Box<StringAggFunc>),
315    ListAgg(Box<ListAggFunc>),
316    ArrayAgg(Box<AggFunc>),
317    CountIf(Box<AggFunc>),
318    SumIf(Box<SumIfFunc>),
319    Stddev(Box<AggFunc>),
320    StddevPop(Box<AggFunc>),
321    StddevSamp(Box<AggFunc>),
322    Variance(Box<AggFunc>),
323    VarPop(Box<AggFunc>),
324    VarSamp(Box<AggFunc>),
325    Median(Box<AggFunc>),
326    Mode(Box<AggFunc>),
327    First(Box<AggFunc>),
328    Last(Box<AggFunc>),
329    AnyValue(Box<AggFunc>),
330    ApproxDistinct(Box<AggFunc>),
331    ApproxCountDistinct(Box<AggFunc>),
332    ApproxPercentile(Box<ApproxPercentileFunc>),
333    Percentile(Box<PercentileFunc>),
334    LogicalAnd(Box<AggFunc>),
335    LogicalOr(Box<AggFunc>),
336    Skewness(Box<AggFunc>),
337    BitwiseCount(Box<UnaryFunc>),
338    ArrayConcatAgg(Box<AggFunc>),
339    ArrayUniqueAgg(Box<AggFunc>),
340    BoolXorAgg(Box<AggFunc>),
341
342    // Typed window functions
343    RowNumber(RowNumber),
344    Rank(Rank),
345    DenseRank(DenseRank),
346    NTile(Box<NTileFunc>),
347    Lead(Box<LeadLagFunc>),
348    Lag(Box<LeadLagFunc>),
349    FirstValue(Box<ValueFunc>),
350    LastValue(Box<ValueFunc>),
351    NthValue(Box<NthValueFunc>),
352    PercentRank(PercentRank),
353    CumeDist(CumeDist),
354    PercentileCont(Box<PercentileFunc>),
355    PercentileDisc(Box<PercentileFunc>),
356
357    // Additional string functions
358    Contains(Box<BinaryFunc>),
359    StartsWith(Box<BinaryFunc>),
360    EndsWith(Box<BinaryFunc>),
361    Position(Box<PositionFunc>),
362    Initcap(Box<UnaryFunc>),
363    Ascii(Box<UnaryFunc>),
364    Chr(Box<UnaryFunc>),
365    /// MySQL CHAR function with multiple args and optional USING charset
366    CharFunc(Box<CharFunc>),
367    Soundex(Box<UnaryFunc>),
368    Levenshtein(Box<BinaryFunc>),
369    ByteLength(Box<UnaryFunc>),
370    Hex(Box<UnaryFunc>),
371    LowerHex(Box<UnaryFunc>),
372    Unicode(Box<UnaryFunc>),
373
374    // Additional math functions
375    ModFunc(Box<BinaryFunc>),
376    Random(Random),
377    Rand(Box<Rand>),
378    TruncFunc(Box<TruncateFunc>),
379    Pi(Pi),
380    Radians(Box<UnaryFunc>),
381    Degrees(Box<UnaryFunc>),
382    Sin(Box<UnaryFunc>),
383    Cos(Box<UnaryFunc>),
384    Tan(Box<UnaryFunc>),
385    Asin(Box<UnaryFunc>),
386    Acos(Box<UnaryFunc>),
387    Atan(Box<UnaryFunc>),
388    Atan2(Box<BinaryFunc>),
389    IsNan(Box<UnaryFunc>),
390    IsInf(Box<UnaryFunc>),
391    IntDiv(Box<BinaryFunc>),
392
393    // Control flow
394    Decode(Box<DecodeFunc>),
395
396    // Additional date/time functions
397    DateFormat(Box<DateFormatFunc>),
398    FormatDate(Box<DateFormatFunc>),
399    Year(Box<UnaryFunc>),
400    Month(Box<UnaryFunc>),
401    Day(Box<UnaryFunc>),
402    Hour(Box<UnaryFunc>),
403    Minute(Box<UnaryFunc>),
404    Second(Box<UnaryFunc>),
405    DayOfWeek(Box<UnaryFunc>),
406    DayOfWeekIso(Box<UnaryFunc>),
407    DayOfMonth(Box<UnaryFunc>),
408    DayOfYear(Box<UnaryFunc>),
409    WeekOfYear(Box<UnaryFunc>),
410    Quarter(Box<UnaryFunc>),
411    AddMonths(Box<BinaryFunc>),
412    MonthsBetween(Box<BinaryFunc>),
413    LastDay(Box<LastDayFunc>),
414    NextDay(Box<BinaryFunc>),
415    Epoch(Box<UnaryFunc>),
416    EpochMs(Box<UnaryFunc>),
417    FromUnixtime(Box<FromUnixtimeFunc>),
418    UnixTimestamp(Box<UnixTimestampFunc>),
419    MakeDate(Box<MakeDateFunc>),
420    MakeTimestamp(Box<MakeTimestampFunc>),
421    TimestampTrunc(Box<DateTruncFunc>),
422    TimeStrToUnix(Box<UnaryFunc>),
423
424    // Session/User functions
425    SessionUser(SessionUser),
426
427    // Hash/Crypto functions
428    SHA(Box<UnaryFunc>),
429    SHA1Digest(Box<UnaryFunc>),
430
431    // Time conversion functions
432    TimeToUnix(Box<UnaryFunc>),
433
434    // Array functions
435    ArrayFunc(Box<ArrayConstructor>),
436    ArrayLength(Box<UnaryFunc>),
437    ArraySize(Box<UnaryFunc>),
438    Cardinality(Box<UnaryFunc>),
439    ArrayContains(Box<BinaryFunc>),
440    ArrayPosition(Box<BinaryFunc>),
441    ArrayAppend(Box<BinaryFunc>),
442    ArrayPrepend(Box<BinaryFunc>),
443    ArrayConcat(Box<VarArgFunc>),
444    ArraySort(Box<ArraySortFunc>),
445    ArrayReverse(Box<UnaryFunc>),
446    ArrayDistinct(Box<UnaryFunc>),
447    ArrayJoin(Box<ArrayJoinFunc>),
448    ArrayToString(Box<ArrayJoinFunc>),
449    Unnest(Box<UnnestFunc>),
450    Explode(Box<UnaryFunc>),
451    ExplodeOuter(Box<UnaryFunc>),
452    ArrayFilter(Box<ArrayFilterFunc>),
453    ArrayTransform(Box<ArrayTransformFunc>),
454    ArrayFlatten(Box<UnaryFunc>),
455    ArrayCompact(Box<UnaryFunc>),
456    ArrayIntersect(Box<BinaryFunc>),
457    ArrayUnion(Box<BinaryFunc>),
458    ArrayExcept(Box<BinaryFunc>),
459    ArrayRemove(Box<BinaryFunc>),
460    ArrayZip(Box<VarArgFunc>),
461    Sequence(Box<SequenceFunc>),
462    Generate(Box<SequenceFunc>),
463    ExplodingGenerateSeries(Box<SequenceFunc>),
464    ToArray(Box<UnaryFunc>),
465    StarMap(Box<BinaryFunc>),
466
467    // Struct functions
468    StructFunc(Box<StructConstructor>),
469    StructExtract(Box<StructExtractFunc>),
470    NamedStruct(Box<NamedStructFunc>),
471
472    // Map functions
473    MapFunc(Box<MapConstructor>),
474    MapFromEntries(Box<UnaryFunc>),
475    MapFromArrays(Box<BinaryFunc>),
476    MapKeys(Box<UnaryFunc>),
477    MapValues(Box<UnaryFunc>),
478    MapContainsKey(Box<BinaryFunc>),
479    MapConcat(Box<VarArgFunc>),
480    ElementAt(Box<BinaryFunc>),
481    TransformKeys(Box<TransformFunc>),
482    TransformValues(Box<TransformFunc>),
483
484    // JSON functions
485    JsonExtract(Box<JsonExtractFunc>),
486    JsonExtractScalar(Box<JsonExtractFunc>),
487    JsonExtractPath(Box<JsonPathFunc>),
488    JsonArray(Box<VarArgFunc>),
489    JsonObject(Box<JsonObjectFunc>),
490    JsonQuery(Box<JsonExtractFunc>),
491    JsonValue(Box<JsonExtractFunc>),
492    JsonArrayLength(Box<UnaryFunc>),
493    JsonKeys(Box<UnaryFunc>),
494    JsonType(Box<UnaryFunc>),
495    ParseJson(Box<UnaryFunc>),
496    ToJson(Box<UnaryFunc>),
497    JsonSet(Box<JsonModifyFunc>),
498    JsonInsert(Box<JsonModifyFunc>),
499    JsonRemove(Box<JsonPathFunc>),
500    JsonMergePatch(Box<BinaryFunc>),
501    JsonArrayAgg(Box<JsonArrayAggFunc>),
502    JsonObjectAgg(Box<JsonObjectAggFunc>),
503
504    // Type casting/conversion
505    Convert(Box<ConvertFunc>),
506    Typeof(Box<UnaryFunc>),
507
508    // Additional expressions
509    Lambda(Box<LambdaExpr>),
510    Parameter(Box<Parameter>),
511    Placeholder(Placeholder),
512    NamedArgument(Box<NamedArgument>),
513    /// TABLE ref or MODEL ref used as a function argument (BigQuery)
514    /// e.g., GAP_FILL(TABLE device_data, ...) or ML.PREDICT(MODEL mydataset.mymodel, ...)
515    TableArgument(Box<TableArgument>),
516    SqlComment(Box<SqlComment>),
517
518    // Additional predicates
519    NullSafeEq(Box<BinaryOp>),
520    NullSafeNeq(Box<BinaryOp>),
521    Glob(Box<BinaryOp>),
522    SimilarTo(Box<SimilarToExpr>),
523    Any(Box<QuantifiedExpr>),
524    All(Box<QuantifiedExpr>),
525    Overlaps(Box<OverlapsExpr>),
526
527    // Bitwise operations
528    BitwiseLeftShift(Box<BinaryOp>),
529    BitwiseRightShift(Box<BinaryOp>),
530    BitwiseAndAgg(Box<AggFunc>),
531    BitwiseOrAgg(Box<AggFunc>),
532    BitwiseXorAgg(Box<AggFunc>),
533
534    // Array/struct/map access
535    Subscript(Box<Subscript>),
536    Dot(Box<DotAccess>),
537    MethodCall(Box<MethodCall>),
538    ArraySlice(Box<ArraySlice>),
539
540    // DDL statements
541    CreateTable(Box<CreateTable>),
542    DropTable(Box<DropTable>),
543    AlterTable(Box<AlterTable>),
544    CreateIndex(Box<CreateIndex>),
545    DropIndex(Box<DropIndex>),
546    CreateView(Box<CreateView>),
547    DropView(Box<DropView>),
548    AlterView(Box<AlterView>),
549    AlterIndex(Box<AlterIndex>),
550    Truncate(Box<Truncate>),
551    Use(Box<Use>),
552    Cache(Box<Cache>),
553    Uncache(Box<Uncache>),
554    LoadData(Box<LoadData>),
555    Pragma(Box<Pragma>),
556    Grant(Box<Grant>),
557    Revoke(Box<Revoke>),
558    Comment(Box<Comment>),
559    SetStatement(Box<SetStatement>),
560    // Phase 4: Additional DDL statements
561    CreateSchema(Box<CreateSchema>),
562    DropSchema(Box<DropSchema>),
563    DropNamespace(Box<DropNamespace>),
564    CreateDatabase(Box<CreateDatabase>),
565    DropDatabase(Box<DropDatabase>),
566    CreateFunction(Box<CreateFunction>),
567    DropFunction(Box<DropFunction>),
568    CreateProcedure(Box<CreateProcedure>),
569    DropProcedure(Box<DropProcedure>),
570    CreateSequence(Box<CreateSequence>),
571    DropSequence(Box<DropSequence>),
572    AlterSequence(Box<AlterSequence>),
573    CreateTrigger(Box<CreateTrigger>),
574    DropTrigger(Box<DropTrigger>),
575    CreateType(Box<CreateType>),
576    DropType(Box<DropType>),
577    Describe(Box<Describe>),
578    Show(Box<Show>),
579
580    // Transaction and other commands
581    Command(Box<Command>),
582    Kill(Box<Kill>),
583    /// EXEC/EXECUTE statement (TSQL stored procedure call)
584    Execute(Box<ExecuteStatement>),
585
586    // Placeholder for unparsed/raw SQL
587    Raw(Raw),
588
589    // Paren for grouping
590    Paren(Box<Paren>),
591
592    // Expression with trailing comments (for round-trip preservation)
593    Annotated(Box<Annotated>),
594
595    // === BATCH GENERATED EXPRESSION TYPES ===
596    // Generated from Python sqlglot expressions.py
597    Refresh(Box<Refresh>),
598    LockingStatement(Box<LockingStatement>),
599    SequenceProperties(Box<SequenceProperties>),
600    TruncateTable(Box<TruncateTable>),
601    Clone(Box<Clone>),
602    Attach(Box<Attach>),
603    Detach(Box<Detach>),
604    Install(Box<Install>),
605    Summarize(Box<Summarize>),
606    Declare(Box<Declare>),
607    DeclareItem(Box<DeclareItem>),
608    Set(Box<Set>),
609    Heredoc(Box<Heredoc>),
610    SetItem(Box<SetItem>),
611    QueryBand(Box<QueryBand>),
612    UserDefinedFunction(Box<UserDefinedFunction>),
613    RecursiveWithSearch(Box<RecursiveWithSearch>),
614    ProjectionDef(Box<ProjectionDef>),
615    TableAlias(Box<TableAlias>),
616    ByteString(Box<ByteString>),
617    HexStringExpr(Box<HexStringExpr>),
618    UnicodeString(Box<UnicodeString>),
619    ColumnPosition(Box<ColumnPosition>),
620    ColumnDef(Box<ColumnDef>),
621    AlterColumn(Box<AlterColumn>),
622    AlterSortKey(Box<AlterSortKey>),
623    AlterSet(Box<AlterSet>),
624    RenameColumn(Box<RenameColumn>),
625    Comprehension(Box<Comprehension>),
626    MergeTreeTTLAction(Box<MergeTreeTTLAction>),
627    MergeTreeTTL(Box<MergeTreeTTL>),
628    IndexConstraintOption(Box<IndexConstraintOption>),
629    ColumnConstraint(Box<ColumnConstraint>),
630    PeriodForSystemTimeConstraint(Box<PeriodForSystemTimeConstraint>),
631    CaseSpecificColumnConstraint(Box<CaseSpecificColumnConstraint>),
632    CharacterSetColumnConstraint(Box<CharacterSetColumnConstraint>),
633    CheckColumnConstraint(Box<CheckColumnConstraint>),
634    CompressColumnConstraint(Box<CompressColumnConstraint>),
635    DateFormatColumnConstraint(Box<DateFormatColumnConstraint>),
636    EphemeralColumnConstraint(Box<EphemeralColumnConstraint>),
637    WithOperator(Box<WithOperator>),
638    GeneratedAsIdentityColumnConstraint(Box<GeneratedAsIdentityColumnConstraint>),
639    AutoIncrementColumnConstraint(AutoIncrementColumnConstraint),
640    CommentColumnConstraint(CommentColumnConstraint),
641    GeneratedAsRowColumnConstraint(Box<GeneratedAsRowColumnConstraint>),
642    IndexColumnConstraint(Box<IndexColumnConstraint>),
643    MaskingPolicyColumnConstraint(Box<MaskingPolicyColumnConstraint>),
644    NotNullColumnConstraint(Box<NotNullColumnConstraint>),
645    PrimaryKeyColumnConstraint(Box<PrimaryKeyColumnConstraint>),
646    UniqueColumnConstraint(Box<UniqueColumnConstraint>),
647    WatermarkColumnConstraint(Box<WatermarkColumnConstraint>),
648    ComputedColumnConstraint(Box<ComputedColumnConstraint>),
649    InOutColumnConstraint(Box<InOutColumnConstraint>),
650    DefaultColumnConstraint(Box<DefaultColumnConstraint>),
651    PathColumnConstraint(Box<PathColumnConstraint>),
652    Constraint(Box<Constraint>),
653    Export(Box<Export>),
654    Filter(Box<Filter>),
655    Changes(Box<Changes>),
656    CopyParameter(Box<CopyParameter>),
657    Credentials(Box<Credentials>),
658    Directory(Box<Directory>),
659    ForeignKey(Box<ForeignKey>),
660    ColumnPrefix(Box<ColumnPrefix>),
661    PrimaryKey(Box<PrimaryKey>),
662    IntoClause(Box<IntoClause>),
663    JoinHint(Box<JoinHint>),
664    Opclass(Box<Opclass>),
665    Index(Box<Index>),
666    IndexParameters(Box<IndexParameters>),
667    ConditionalInsert(Box<ConditionalInsert>),
668    MultitableInserts(Box<MultitableInserts>),
669    OnConflict(Box<OnConflict>),
670    OnCondition(Box<OnCondition>),
671    Returning(Box<Returning>),
672    Introducer(Box<Introducer>),
673    PartitionRange(Box<PartitionRange>),
674    Fetch(Box<Fetch>),
675    Group(Box<Group>),
676    Cube(Box<Cube>),
677    Rollup(Box<Rollup>),
678    GroupingSets(Box<GroupingSets>),
679    LimitOptions(Box<LimitOptions>),
680    Lateral(Box<Lateral>),
681    TableFromRows(Box<TableFromRows>),
682    RowsFrom(Box<RowsFrom>),
683    MatchRecognizeMeasure(Box<MatchRecognizeMeasure>),
684    WithFill(Box<WithFill>),
685    Property(Box<Property>),
686    GrantPrivilege(Box<GrantPrivilege>),
687    GrantPrincipal(Box<GrantPrincipal>),
688    AllowedValuesProperty(Box<AllowedValuesProperty>),
689    AlgorithmProperty(Box<AlgorithmProperty>),
690    AutoIncrementProperty(Box<AutoIncrementProperty>),
691    AutoRefreshProperty(Box<AutoRefreshProperty>),
692    BackupProperty(Box<BackupProperty>),
693    BuildProperty(Box<BuildProperty>),
694    BlockCompressionProperty(Box<BlockCompressionProperty>),
695    CharacterSetProperty(Box<CharacterSetProperty>),
696    ChecksumProperty(Box<ChecksumProperty>),
697    CollateProperty(Box<CollateProperty>),
698    DataBlocksizeProperty(Box<DataBlocksizeProperty>),
699    DataDeletionProperty(Box<DataDeletionProperty>),
700    DefinerProperty(Box<DefinerProperty>),
701    DistKeyProperty(Box<DistKeyProperty>),
702    DistributedByProperty(Box<DistributedByProperty>),
703    DistStyleProperty(Box<DistStyleProperty>),
704    DuplicateKeyProperty(Box<DuplicateKeyProperty>),
705    EngineProperty(Box<EngineProperty>),
706    ToTableProperty(Box<ToTableProperty>),
707    ExecuteAsProperty(Box<ExecuteAsProperty>),
708    ExternalProperty(Box<ExternalProperty>),
709    FallbackProperty(Box<FallbackProperty>),
710    FileFormatProperty(Box<FileFormatProperty>),
711    CredentialsProperty(Box<CredentialsProperty>),
712    FreespaceProperty(Box<FreespaceProperty>),
713    InheritsProperty(Box<InheritsProperty>),
714    InputModelProperty(Box<InputModelProperty>),
715    OutputModelProperty(Box<OutputModelProperty>),
716    IsolatedLoadingProperty(Box<IsolatedLoadingProperty>),
717    JournalProperty(Box<JournalProperty>),
718    LanguageProperty(Box<LanguageProperty>),
719    EnviromentProperty(Box<EnviromentProperty>),
720    ClusteredByProperty(Box<ClusteredByProperty>),
721    DictProperty(Box<DictProperty>),
722    DictRange(Box<DictRange>),
723    OnCluster(Box<OnCluster>),
724    LikeProperty(Box<LikeProperty>),
725    LocationProperty(Box<LocationProperty>),
726    LockProperty(Box<LockProperty>),
727    LockingProperty(Box<LockingProperty>),
728    LogProperty(Box<LogProperty>),
729    MaterializedProperty(Box<MaterializedProperty>),
730    MergeBlockRatioProperty(Box<MergeBlockRatioProperty>),
731    OnProperty(Box<OnProperty>),
732    OnCommitProperty(Box<OnCommitProperty>),
733    PartitionedByProperty(Box<PartitionedByProperty>),
734    PartitionedByBucket(Box<PartitionedByBucket>),
735    PartitionByTruncate(Box<PartitionByTruncate>),
736    PartitionByRangeProperty(Box<PartitionByRangeProperty>),
737    PartitionByRangePropertyDynamic(Box<PartitionByRangePropertyDynamic>),
738    PartitionByListProperty(Box<PartitionByListProperty>),
739    PartitionList(Box<PartitionList>),
740    Partition(Box<Partition>),
741    RefreshTriggerProperty(Box<RefreshTriggerProperty>),
742    UniqueKeyProperty(Box<UniqueKeyProperty>),
743    RollupProperty(Box<RollupProperty>),
744    PartitionBoundSpec(Box<PartitionBoundSpec>),
745    PartitionedOfProperty(Box<PartitionedOfProperty>),
746    RemoteWithConnectionModelProperty(Box<RemoteWithConnectionModelProperty>),
747    ReturnsProperty(Box<ReturnsProperty>),
748    RowFormatProperty(Box<RowFormatProperty>),
749    RowFormatDelimitedProperty(Box<RowFormatDelimitedProperty>),
750    RowFormatSerdeProperty(Box<RowFormatSerdeProperty>),
751    QueryTransform(Box<QueryTransform>),
752    SampleProperty(Box<SampleProperty>),
753    SecurityProperty(Box<SecurityProperty>),
754    SchemaCommentProperty(Box<SchemaCommentProperty>),
755    SemanticView(Box<SemanticView>),
756    SerdeProperties(Box<SerdeProperties>),
757    SetProperty(Box<SetProperty>),
758    SharingProperty(Box<SharingProperty>),
759    SetConfigProperty(Box<SetConfigProperty>),
760    SettingsProperty(Box<SettingsProperty>),
761    SortKeyProperty(Box<SortKeyProperty>),
762    SqlReadWriteProperty(Box<SqlReadWriteProperty>),
763    SqlSecurityProperty(Box<SqlSecurityProperty>),
764    StabilityProperty(Box<StabilityProperty>),
765    StorageHandlerProperty(Box<StorageHandlerProperty>),
766    TemporaryProperty(Box<TemporaryProperty>),
767    Tags(Box<Tags>),
768    TransformModelProperty(Box<TransformModelProperty>),
769    TransientProperty(Box<TransientProperty>),
770    UsingTemplateProperty(Box<UsingTemplateProperty>),
771    ViewAttributeProperty(Box<ViewAttributeProperty>),
772    VolatileProperty(Box<VolatileProperty>),
773    WithDataProperty(Box<WithDataProperty>),
774    WithJournalTableProperty(Box<WithJournalTableProperty>),
775    WithSchemaBindingProperty(Box<WithSchemaBindingProperty>),
776    WithSystemVersioningProperty(Box<WithSystemVersioningProperty>),
777    WithProcedureOptions(Box<WithProcedureOptions>),
778    EncodeProperty(Box<EncodeProperty>),
779    IncludeProperty(Box<IncludeProperty>),
780    Properties(Box<Properties>),
781    InputOutputFormat(Box<InputOutputFormat>),
782    Reference(Box<Reference>),
783    QueryOption(Box<QueryOption>),
784    WithTableHint(Box<WithTableHint>),
785    IndexTableHint(Box<IndexTableHint>),
786    HistoricalData(Box<HistoricalData>),
787    Get(Box<Get>),
788    SetOperation(Box<SetOperation>),
789    Var(Box<Var>),
790    Version(Box<Version>),
791    Schema(Box<Schema>),
792    Lock(Box<Lock>),
793    TableSample(Box<TableSample>),
794    Tag(Box<Tag>),
795    UnpivotColumns(Box<UnpivotColumns>),
796    WindowSpec(Box<WindowSpec>),
797    SessionParameter(Box<SessionParameter>),
798    PseudoType(Box<PseudoType>),
799    ObjectIdentifier(Box<ObjectIdentifier>),
800    Transaction(Box<Transaction>),
801    Commit(Box<Commit>),
802    Rollback(Box<Rollback>),
803    AlterSession(Box<AlterSession>),
804    Analyze(Box<Analyze>),
805    AnalyzeStatistics(Box<AnalyzeStatistics>),
806    AnalyzeHistogram(Box<AnalyzeHistogram>),
807    AnalyzeSample(Box<AnalyzeSample>),
808    AnalyzeListChainedRows(Box<AnalyzeListChainedRows>),
809    AnalyzeDelete(Box<AnalyzeDelete>),
810    AnalyzeWith(Box<AnalyzeWith>),
811    AnalyzeValidate(Box<AnalyzeValidate>),
812    AddPartition(Box<AddPartition>),
813    AttachOption(Box<AttachOption>),
814    DropPartition(Box<DropPartition>),
815    ReplacePartition(Box<ReplacePartition>),
816    DPipe(Box<DPipe>),
817    Operator(Box<Operator>),
818    PivotAny(Box<PivotAny>),
819    Aliases(Box<Aliases>),
820    AtIndex(Box<AtIndex>),
821    FromTimeZone(Box<FromTimeZone>),
822    FormatPhrase(Box<FormatPhrase>),
823    ForIn(Box<ForIn>),
824    TimeUnit(Box<TimeUnit>),
825    IntervalOp(Box<IntervalOp>),
826    IntervalSpan(Box<IntervalSpan>),
827    HavingMax(Box<HavingMax>),
828    CosineDistance(Box<CosineDistance>),
829    DotProduct(Box<DotProduct>),
830    EuclideanDistance(Box<EuclideanDistance>),
831    ManhattanDistance(Box<ManhattanDistance>),
832    JarowinklerSimilarity(Box<JarowinklerSimilarity>),
833    Booland(Box<Booland>),
834    Boolor(Box<Boolor>),
835    ParameterizedAgg(Box<ParameterizedAgg>),
836    ArgMax(Box<ArgMax>),
837    ArgMin(Box<ArgMin>),
838    ApproxTopK(Box<ApproxTopK>),
839    ApproxTopKAccumulate(Box<ApproxTopKAccumulate>),
840    ApproxTopKCombine(Box<ApproxTopKCombine>),
841    ApproxTopKEstimate(Box<ApproxTopKEstimate>),
842    ApproxTopSum(Box<ApproxTopSum>),
843    ApproxQuantiles(Box<ApproxQuantiles>),
844    Minhash(Box<Minhash>),
845    FarmFingerprint(Box<FarmFingerprint>),
846    Float64(Box<Float64>),
847    Transform(Box<Transform>),
848    Translate(Box<Translate>),
849    Grouping(Box<Grouping>),
850    GroupingId(Box<GroupingId>),
851    Anonymous(Box<Anonymous>),
852    AnonymousAggFunc(Box<AnonymousAggFunc>),
853    CombinedAggFunc(Box<CombinedAggFunc>),
854    CombinedParameterizedAgg(Box<CombinedParameterizedAgg>),
855    HashAgg(Box<HashAgg>),
856    Hll(Box<Hll>),
857    Apply(Box<Apply>),
858    ToBoolean(Box<ToBoolean>),
859    List(Box<List>),
860    ToMap(Box<ToMap>),
861    Pad(Box<Pad>),
862    ToChar(Box<ToChar>),
863    ToNumber(Box<ToNumber>),
864    ToDouble(Box<ToDouble>),
865    Int64(Box<UnaryFunc>),
866    StringFunc(Box<StringFunc>),
867    ToDecfloat(Box<ToDecfloat>),
868    TryToDecfloat(Box<TryToDecfloat>),
869    ToFile(Box<ToFile>),
870    Columns(Box<Columns>),
871    ConvertToCharset(Box<ConvertToCharset>),
872    ConvertTimezone(Box<ConvertTimezone>),
873    GenerateSeries(Box<GenerateSeries>),
874    AIAgg(Box<AIAgg>),
875    AIClassify(Box<AIClassify>),
876    ArrayAll(Box<ArrayAll>),
877    ArrayAny(Box<ArrayAny>),
878    ArrayConstructCompact(Box<ArrayConstructCompact>),
879    StPoint(Box<StPoint>),
880    StDistance(Box<StDistance>),
881    StringToArray(Box<StringToArray>),
882    ArraySum(Box<ArraySum>),
883    ObjectAgg(Box<ObjectAgg>),
884    CastToStrType(Box<CastToStrType>),
885    CheckJson(Box<CheckJson>),
886    CheckXml(Box<CheckXml>),
887    TranslateCharacters(Box<TranslateCharacters>),
888    CurrentSchemas(Box<CurrentSchemas>),
889    CurrentDatetime(Box<CurrentDatetime>),
890    Localtime(Box<Localtime>),
891    Localtimestamp(Box<Localtimestamp>),
892    Systimestamp(Box<Systimestamp>),
893    CurrentSchema(Box<CurrentSchema>),
894    CurrentUser(Box<CurrentUser>),
895    UtcTime(Box<UtcTime>),
896    UtcTimestamp(Box<UtcTimestamp>),
897    Timestamp(Box<TimestampFunc>),
898    DateBin(Box<DateBin>),
899    Datetime(Box<Datetime>),
900    DatetimeAdd(Box<DatetimeAdd>),
901    DatetimeSub(Box<DatetimeSub>),
902    DatetimeDiff(Box<DatetimeDiff>),
903    DatetimeTrunc(Box<DatetimeTrunc>),
904    Dayname(Box<Dayname>),
905    MakeInterval(Box<MakeInterval>),
906    PreviousDay(Box<PreviousDay>),
907    Elt(Box<Elt>),
908    TimestampAdd(Box<TimestampAdd>),
909    TimestampSub(Box<TimestampSub>),
910    TimestampDiff(Box<TimestampDiff>),
911    TimeSlice(Box<TimeSlice>),
912    TimeAdd(Box<TimeAdd>),
913    TimeSub(Box<TimeSub>),
914    TimeDiff(Box<TimeDiff>),
915    TimeTrunc(Box<TimeTrunc>),
916    DateFromParts(Box<DateFromParts>),
917    TimeFromParts(Box<TimeFromParts>),
918    DecodeCase(Box<DecodeCase>),
919    Decrypt(Box<Decrypt>),
920    DecryptRaw(Box<DecryptRaw>),
921    Encode(Box<Encode>),
922    Encrypt(Box<Encrypt>),
923    EncryptRaw(Box<EncryptRaw>),
924    EqualNull(Box<EqualNull>),
925    ToBinary(Box<ToBinary>),
926    Base64DecodeBinary(Box<Base64DecodeBinary>),
927    Base64DecodeString(Box<Base64DecodeString>),
928    Base64Encode(Box<Base64Encode>),
929    TryBase64DecodeBinary(Box<TryBase64DecodeBinary>),
930    TryBase64DecodeString(Box<TryBase64DecodeString>),
931    GapFill(Box<GapFill>),
932    GenerateDateArray(Box<GenerateDateArray>),
933    GenerateTimestampArray(Box<GenerateTimestampArray>),
934    GetExtract(Box<GetExtract>),
935    Getbit(Box<Getbit>),
936    OverflowTruncateBehavior(Box<OverflowTruncateBehavior>),
937    HexEncode(Box<HexEncode>),
938    Compress(Box<Compress>),
939    DecompressBinary(Box<DecompressBinary>),
940    DecompressString(Box<DecompressString>),
941    Xor(Box<Xor>),
942    Nullif(Box<Nullif>),
943    JSON(Box<JSON>),
944    JSONPath(Box<JSONPath>),
945    JSONPathFilter(Box<JSONPathFilter>),
946    JSONPathKey(Box<JSONPathKey>),
947    JSONPathRecursive(Box<JSONPathRecursive>),
948    JSONPathScript(Box<JSONPathScript>),
949    JSONPathSlice(Box<JSONPathSlice>),
950    JSONPathSelector(Box<JSONPathSelector>),
951    JSONPathSubscript(Box<JSONPathSubscript>),
952    JSONPathUnion(Box<JSONPathUnion>),
953    Format(Box<Format>),
954    JSONKeys(Box<JSONKeys>),
955    JSONKeyValue(Box<JSONKeyValue>),
956    JSONKeysAtDepth(Box<JSONKeysAtDepth>),
957    JSONObject(Box<JSONObject>),
958    JSONObjectAgg(Box<JSONObjectAgg>),
959    JSONBObjectAgg(Box<JSONBObjectAgg>),
960    JSONArray(Box<JSONArray>),
961    JSONArrayAgg(Box<JSONArrayAgg>),
962    JSONExists(Box<JSONExists>),
963    JSONColumnDef(Box<JSONColumnDef>),
964    JSONSchema(Box<JSONSchema>),
965    JSONSet(Box<JSONSet>),
966    JSONStripNulls(Box<JSONStripNulls>),
967    JSONValue(Box<JSONValue>),
968    JSONValueArray(Box<JSONValueArray>),
969    JSONRemove(Box<JSONRemove>),
970    JSONTable(Box<JSONTable>),
971    JSONType(Box<JSONType>),
972    ObjectInsert(Box<ObjectInsert>),
973    OpenJSONColumnDef(Box<OpenJSONColumnDef>),
974    OpenJSON(Box<OpenJSON>),
975    JSONBExists(Box<JSONBExists>),
976    JSONBContains(Box<BinaryFunc>),
977    JSONBExtract(Box<BinaryFunc>),
978    JSONCast(Box<JSONCast>),
979    JSONExtract(Box<JSONExtract>),
980    JSONExtractQuote(Box<JSONExtractQuote>),
981    JSONExtractArray(Box<JSONExtractArray>),
982    JSONExtractScalar(Box<JSONExtractScalar>),
983    JSONBExtractScalar(Box<JSONBExtractScalar>),
984    JSONFormat(Box<JSONFormat>),
985    JSONBool(Box<UnaryFunc>),
986    JSONPathRoot(JSONPathRoot),
987    JSONArrayAppend(Box<JSONArrayAppend>),
988    JSONArrayContains(Box<JSONArrayContains>),
989    JSONArrayInsert(Box<JSONArrayInsert>),
990    ParseJSON(Box<ParseJSON>),
991    ParseUrl(Box<ParseUrl>),
992    ParseIp(Box<ParseIp>),
993    ParseTime(Box<ParseTime>),
994    ParseDatetime(Box<ParseDatetime>),
995    Map(Box<Map>),
996    MapCat(Box<MapCat>),
997    MapDelete(Box<MapDelete>),
998    MapInsert(Box<MapInsert>),
999    MapPick(Box<MapPick>),
1000    ScopeResolution(Box<ScopeResolution>),
1001    Slice(Box<Slice>),
1002    VarMap(Box<VarMap>),
1003    MatchAgainst(Box<MatchAgainst>),
1004    MD5Digest(Box<MD5Digest>),
1005    MD5NumberLower64(Box<UnaryFunc>),
1006    MD5NumberUpper64(Box<UnaryFunc>),
1007    Monthname(Box<Monthname>),
1008    Ntile(Box<Ntile>),
1009    Normalize(Box<Normalize>),
1010    Normal(Box<Normal>),
1011    Predict(Box<Predict>),
1012    MLTranslate(Box<MLTranslate>),
1013    FeaturesAtTime(Box<FeaturesAtTime>),
1014    GenerateEmbedding(Box<GenerateEmbedding>),
1015    MLForecast(Box<MLForecast>),
1016    ModelAttribute(Box<ModelAttribute>),
1017    VectorSearch(Box<VectorSearch>),
1018    Quantile(Box<Quantile>),
1019    ApproxQuantile(Box<ApproxQuantile>),
1020    ApproxPercentileEstimate(Box<ApproxPercentileEstimate>),
1021    Randn(Box<Randn>),
1022    Randstr(Box<Randstr>),
1023    RangeN(Box<RangeN>),
1024    RangeBucket(Box<RangeBucket>),
1025    ReadCSV(Box<ReadCSV>),
1026    ReadParquet(Box<ReadParquet>),
1027    Reduce(Box<Reduce>),
1028    RegexpExtractAll(Box<RegexpExtractAll>),
1029    RegexpILike(Box<RegexpILike>),
1030    RegexpFullMatch(Box<RegexpFullMatch>),
1031    RegexpInstr(Box<RegexpInstr>),
1032    RegexpSplit(Box<RegexpSplit>),
1033    RegexpCount(Box<RegexpCount>),
1034    RegrValx(Box<RegrValx>),
1035    RegrValy(Box<RegrValy>),
1036    RegrAvgy(Box<RegrAvgy>),
1037    RegrAvgx(Box<RegrAvgx>),
1038    RegrCount(Box<RegrCount>),
1039    RegrIntercept(Box<RegrIntercept>),
1040    RegrR2(Box<RegrR2>),
1041    RegrSxx(Box<RegrSxx>),
1042    RegrSxy(Box<RegrSxy>),
1043    RegrSyy(Box<RegrSyy>),
1044    RegrSlope(Box<RegrSlope>),
1045    SafeAdd(Box<SafeAdd>),
1046    SafeDivide(Box<SafeDivide>),
1047    SafeMultiply(Box<SafeMultiply>),
1048    SafeSubtract(Box<SafeSubtract>),
1049    SHA2(Box<SHA2>),
1050    SHA2Digest(Box<SHA2Digest>),
1051    SortArray(Box<SortArray>),
1052    SplitPart(Box<SplitPart>),
1053    SubstringIndex(Box<SubstringIndex>),
1054    StandardHash(Box<StandardHash>),
1055    StrPosition(Box<StrPosition>),
1056    Search(Box<Search>),
1057    SearchIp(Box<SearchIp>),
1058    StrToDate(Box<StrToDate>),
1059    DateStrToDate(Box<UnaryFunc>),
1060    DateToDateStr(Box<UnaryFunc>),
1061    StrToTime(Box<StrToTime>),
1062    StrToUnix(Box<StrToUnix>),
1063    StrToMap(Box<StrToMap>),
1064    NumberToStr(Box<NumberToStr>),
1065    FromBase(Box<FromBase>),
1066    Stuff(Box<Stuff>),
1067    TimeToStr(Box<TimeToStr>),
1068    TimeStrToTime(Box<TimeStrToTime>),
1069    TsOrDsAdd(Box<TsOrDsAdd>),
1070    TsOrDsDiff(Box<TsOrDsDiff>),
1071    TsOrDsToDate(Box<TsOrDsToDate>),
1072    TsOrDsToTime(Box<TsOrDsToTime>),
1073    Unhex(Box<Unhex>),
1074    Uniform(Box<Uniform>),
1075    UnixToStr(Box<UnixToStr>),
1076    UnixToTime(Box<UnixToTime>),
1077    Uuid(Box<Uuid>),
1078    TimestampFromParts(Box<TimestampFromParts>),
1079    TimestampTzFromParts(Box<TimestampTzFromParts>),
1080    Corr(Box<Corr>),
1081    WidthBucket(Box<WidthBucket>),
1082    CovarSamp(Box<CovarSamp>),
1083    CovarPop(Box<CovarPop>),
1084    Week(Box<Week>),
1085    XMLElement(Box<XMLElement>),
1086    XMLGet(Box<XMLGet>),
1087    XMLTable(Box<XMLTable>),
1088    XMLKeyValueOption(Box<XMLKeyValueOption>),
1089    Zipf(Box<Zipf>),
1090    Merge(Box<Merge>),
1091    When(Box<When>),
1092    Whens(Box<Whens>),
1093    NextValueFor(Box<NextValueFor>),
1094    /// RETURN statement (DuckDB stored procedures)
1095    ReturnStmt(Box<Expression>),
1096}
1097
1098impl Expression {
1099    /// Create a literal number expression from an integer.
1100    pub fn number(n: i64) -> Self {
1101        Expression::Literal(Literal::Number(n.to_string()))
1102    }
1103
1104    /// Create a single-quoted literal string expression.
1105    pub fn string(s: impl Into<String>) -> Self {
1106        Expression::Literal(Literal::String(s.into()))
1107    }
1108
1109    /// Create a literal number expression from a float.
1110    pub fn float(f: f64) -> Self {
1111        Expression::Literal(Literal::Number(f.to_string()))
1112    }
1113
1114    /// Create an unqualified column reference (e.g. `name`).
1115    pub fn column(name: impl Into<String>) -> Self {
1116        Expression::Column(Column {
1117            name: Identifier::new(name),
1118            table: None,
1119            join_mark: false,
1120            trailing_comments: Vec::new(),
1121        })
1122    }
1123
1124    /// Create a qualified column reference (`table.column`).
1125    pub fn qualified_column(table: impl Into<String>, column: impl Into<String>) -> Self {
1126        Expression::Column(Column {
1127            name: Identifier::new(column),
1128            table: Some(Identifier::new(table)),
1129            join_mark: false,
1130            trailing_comments: Vec::new(),
1131        })
1132    }
1133
1134    /// Create a bare identifier expression (not a column reference).
1135    pub fn identifier(name: impl Into<String>) -> Self {
1136        Expression::Identifier(Identifier::new(name))
1137    }
1138
1139    /// Create a NULL expression
1140    pub fn null() -> Self {
1141        Expression::Null(Null)
1142    }
1143
1144    /// Create a TRUE expression
1145    pub fn true_() -> Self {
1146        Expression::Boolean(BooleanLiteral { value: true })
1147    }
1148
1149    /// Create a FALSE expression
1150    pub fn false_() -> Self {
1151        Expression::Boolean(BooleanLiteral { value: false })
1152    }
1153
1154    /// Create a wildcard star (`*`) expression with no EXCEPT/REPLACE/RENAME modifiers.
1155    pub fn star() -> Self {
1156        Expression::Star(Star {
1157            table: None,
1158            except: None,
1159            replace: None,
1160            rename: None,
1161            trailing_comments: Vec::new(),
1162        })
1163    }
1164
1165    /// Wrap this expression in an `AS` alias (e.g. `expr AS name`).
1166    pub fn alias(self, name: impl Into<String>) -> Self {
1167        Expression::Alias(Box::new(Alias::new(self, Identifier::new(name))))
1168    }
1169
1170    /// Check if this is a SELECT expression
1171    pub fn is_select(&self) -> bool {
1172        matches!(self, Expression::Select(_))
1173    }
1174
1175    /// Try to get as a Select
1176    pub fn as_select(&self) -> Option<&Select> {
1177        match self {
1178            Expression::Select(s) => Some(s),
1179            _ => None,
1180        }
1181    }
1182
1183    /// Try to get as a mutable Select
1184    pub fn as_select_mut(&mut self) -> Option<&mut Select> {
1185        match self {
1186            Expression::Select(s) => Some(s),
1187            _ => None,
1188        }
1189    }
1190
1191    /// Generate a SQL string for this expression using the generic (dialect-agnostic) generator.
1192    ///
1193    /// Returns an empty string if generation fails. For dialect-specific output,
1194    /// use [`sql_for()`](Self::sql_for) instead.
1195    pub fn sql(&self) -> String {
1196        crate::generator::Generator::sql(self).unwrap_or_default()
1197    }
1198
1199    /// Generate a SQL string for this expression targeting a specific dialect.
1200    ///
1201    /// Dialect-specific rules (identifier quoting, function names, type mappings,
1202    /// syntax variations) are applied automatically.  Returns an empty string if
1203    /// generation fails.
1204    pub fn sql_for(&self, dialect: crate::dialects::DialectType) -> String {
1205        crate::generate(self, dialect).unwrap_or_default()
1206    }
1207
1208}
1209
1210impl fmt::Display for Expression {
1211    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1212        // Basic display - full SQL generation is in generator module
1213        match self {
1214            Expression::Literal(lit) => write!(f, "{}", lit),
1215            Expression::Identifier(id) => write!(f, "{}", id),
1216            Expression::Column(col) => write!(f, "{}", col),
1217            Expression::Star(_) => write!(f, "*"),
1218            Expression::Null(_) => write!(f, "NULL"),
1219            Expression::Boolean(b) => write!(f, "{}", if b.value { "TRUE" } else { "FALSE" }),
1220            Expression::Select(_) => write!(f, "SELECT ..."),
1221            _ => write!(f, "{:?}", self),
1222        }
1223    }
1224}
1225
1226/// Represent a SQL literal value.
1227///
1228/// Numeric values are stored as their original text representation (not parsed
1229/// to `i64`/`f64`) so that precision, trailing zeros, and hex notation are
1230/// preserved across round-trips.
1231///
1232/// Dialect-specific literal forms (triple-quoted strings, dollar-quoted
1233/// strings, raw strings, etc.) each have a dedicated variant so that the
1234/// generator can emit them with the correct syntax.
1235#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1236#[cfg_attr(feature = "bindings", derive(TS))]
1237#[serde(tag = "literal_type", content = "value", rename_all = "snake_case")]
1238pub enum Literal {
1239    /// Single-quoted string literal: `'hello'`
1240    String(String),
1241    /// Numeric literal, stored as the original text: `42`, `3.14`, `1e10`
1242    Number(String),
1243    /// Hex string literal: `X'FF'`
1244    HexString(String),
1245    /// Hex number: 0xA, 0xFF (BigQuery, SQLite style) - represents an integer in hex notation
1246    HexNumber(String),
1247    BitString(String),
1248    /// Byte string: b"..." (BigQuery style)
1249    ByteString(String),
1250    /// National string: N'abc'
1251    NationalString(String),
1252    /// DATE literal: DATE '2024-01-15'
1253    Date(String),
1254    /// TIME literal: TIME '10:30:00'
1255    Time(String),
1256    /// TIMESTAMP literal: TIMESTAMP '2024-01-15 10:30:00'
1257    Timestamp(String),
1258    /// DATETIME literal: DATETIME '2024-01-15 10:30:00' (BigQuery)
1259    Datetime(String),
1260    /// Triple-quoted string: """...""" or '''...'''
1261    /// Contains (content, quote_char) where quote_char is '"' or '\''
1262    TripleQuotedString(String, char),
1263    /// Escape string: E'...' (PostgreSQL)
1264    EscapeString(String),
1265    /// Dollar-quoted string: $$...$$  (PostgreSQL)
1266    DollarString(String),
1267    /// Raw string: r"..." or r'...' (BigQuery, Spark, Databricks)
1268    /// In raw strings, backslashes are literal and not escape characters.
1269    /// When converting to a regular string, backslashes must be doubled.
1270    RawString(String),
1271}
1272
1273impl fmt::Display for Literal {
1274    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1275        match self {
1276            Literal::String(s) => write!(f, "'{}'", s),
1277            Literal::Number(n) => write!(f, "{}", n),
1278            Literal::HexString(h) => write!(f, "X'{}'", h),
1279            Literal::HexNumber(h) => write!(f, "0x{}", h),
1280            Literal::BitString(b) => write!(f, "B'{}'", b),
1281            Literal::ByteString(b) => write!(f, "b'{}'", b),
1282            Literal::NationalString(s) => write!(f, "N'{}'", s),
1283            Literal::Date(d) => write!(f, "DATE '{}'", d),
1284            Literal::Time(t) => write!(f, "TIME '{}'", t),
1285            Literal::Timestamp(ts) => write!(f, "TIMESTAMP '{}'", ts),
1286            Literal::Datetime(dt) => write!(f, "DATETIME '{}'", dt),
1287            Literal::TripleQuotedString(s, q) => {
1288                write!(f, "{0}{0}{0}{1}{0}{0}{0}", q, s)
1289            }
1290            Literal::EscapeString(s) => write!(f, "E'{}'", s),
1291            Literal::DollarString(s) => write!(f, "$${}$$", s),
1292            Literal::RawString(s) => write!(f, "r'{}'", s),
1293        }
1294    }
1295}
1296
1297/// Boolean literal
1298#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1299#[cfg_attr(feature = "bindings", derive(TS))]
1300pub struct BooleanLiteral {
1301    pub value: bool,
1302}
1303
1304/// NULL literal
1305#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1306#[cfg_attr(feature = "bindings", derive(TS))]
1307pub struct Null;
1308
1309/// Represent a SQL identifier (table name, column name, alias, keyword-as-name, etc.).
1310///
1311/// The `quoted` flag indicates whether the identifier was originally delimited
1312/// (double-quoted, backtick-quoted, or bracket-quoted depending on the
1313/// dialect). The generator uses this flag to decide whether to emit quoting
1314/// characters.
1315#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1316#[cfg_attr(feature = "bindings", derive(TS))]
1317pub struct Identifier {
1318    /// The raw text of the identifier, without any quoting characters.
1319    pub name: String,
1320    /// Whether the identifier was quoted in the source SQL.
1321    pub quoted: bool,
1322    #[serde(default)]
1323    pub trailing_comments: Vec<String>,
1324}
1325
1326impl Identifier {
1327    pub fn new(name: impl Into<String>) -> Self {
1328        Self {
1329            name: name.into(),
1330            quoted: false,
1331            trailing_comments: Vec::new(),
1332        }
1333    }
1334
1335    pub fn quoted(name: impl Into<String>) -> Self {
1336        Self {
1337            name: name.into(),
1338            quoted: true,
1339            trailing_comments: Vec::new(),
1340        }
1341    }
1342
1343    pub fn empty() -> Self {
1344        Self {
1345            name: String::new(),
1346            quoted: false,
1347            trailing_comments: Vec::new(),
1348        }
1349    }
1350
1351    pub fn is_empty(&self) -> bool {
1352        self.name.is_empty()
1353    }
1354}
1355
1356impl fmt::Display for Identifier {
1357    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1358        if self.quoted {
1359            write!(f, "\"{}\"", self.name)
1360        } else {
1361            write!(f, "{}", self.name)
1362        }
1363    }
1364}
1365
1366/// Represent a column reference, optionally qualified by a table name.
1367///
1368/// Renders as `name` when unqualified, or `table.name` when qualified.
1369/// Use [`Expression::column()`] or [`Expression::qualified_column()`] for
1370/// convenient construction.
1371#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1372#[cfg_attr(feature = "bindings", derive(TS))]
1373pub struct Column {
1374    /// The column name.
1375    pub name: Identifier,
1376    /// Optional table qualifier (e.g. `t` in `t.col`).
1377    pub table: Option<Identifier>,
1378    /// Oracle-style join marker (+) for outer joins
1379    #[serde(default)]
1380    pub join_mark: bool,
1381    /// Trailing comments that appeared after this column reference
1382    #[serde(default)]
1383    pub trailing_comments: Vec<String>,
1384}
1385
1386impl fmt::Display for Column {
1387    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1388        if let Some(table) = &self.table {
1389            write!(f, "{}.{}", table, self.name)
1390        } else {
1391            write!(f, "{}", self.name)
1392        }
1393    }
1394}
1395
1396/// Represent a table reference with optional schema and catalog qualifiers.
1397///
1398/// Renders as `name`, `schema.name`, or `catalog.schema.name` depending on
1399/// which qualifiers are present. Supports aliases, column alias lists,
1400/// time-travel clauses (Snowflake, BigQuery), table hints (TSQL), and
1401/// several other dialect-specific extensions.
1402#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1403#[cfg_attr(feature = "bindings", derive(TS))]
1404pub struct TableRef {
1405    /// The unqualified table name.
1406    pub name: Identifier,
1407    /// Optional schema qualifier (e.g. `public` in `public.users`).
1408    pub schema: Option<Identifier>,
1409    /// Optional catalog qualifier (e.g. `mydb` in `mydb.public.users`).
1410    pub catalog: Option<Identifier>,
1411    /// Optional table alias (e.g. `t` in `FROM users AS t`).
1412    pub alias: Option<Identifier>,
1413    /// Whether AS keyword was explicitly used for the alias
1414    #[serde(default)]
1415    pub alias_explicit_as: bool,
1416    /// Column aliases for table alias: AS t(c1, c2)
1417    #[serde(default)]
1418    pub column_aliases: Vec<Identifier>,
1419    /// Trailing comments that appeared after this table reference
1420    #[serde(default)]
1421    pub trailing_comments: Vec<String>,
1422    /// Snowflake time travel: BEFORE (STATEMENT => ...) or AT (TIMESTAMP => ...)
1423    #[serde(default)]
1424    pub when: Option<Box<HistoricalData>>,
1425    /// PostgreSQL ONLY modifier: prevents scanning child tables in inheritance hierarchy
1426    #[serde(default)]
1427    pub only: bool,
1428    /// ClickHouse FINAL modifier: forces final aggregation for MergeTree tables
1429    #[serde(default)]
1430    pub final_: bool,
1431    /// TABLESAMPLE clause attached to this table reference (DuckDB, BigQuery)
1432    #[serde(default, skip_serializing_if = "Option::is_none")]
1433    pub table_sample: Option<Box<Sample>>,
1434    /// TSQL table hints: WITH (TABLOCK, INDEX(myindex), ...)
1435    #[serde(default)]
1436    pub hints: Vec<Expression>,
1437    /// TSQL: FOR SYSTEM_TIME temporal clause
1438    /// Contains the full clause text, e.g., "FOR SYSTEM_TIME BETWEEN c AND d"
1439    #[serde(default, skip_serializing_if = "Option::is_none")]
1440    pub system_time: Option<String>,
1441    /// MySQL: PARTITION(p0, p1, ...) hint for reading from specific partitions
1442    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1443    pub partitions: Vec<Identifier>,
1444    /// Snowflake IDENTIFIER() function: dynamic table name from string/variable
1445    /// When set, this is used instead of the name field
1446    #[serde(default, skip_serializing_if = "Option::is_none")]
1447    pub identifier_func: Option<Box<Expression>>,
1448    /// Snowflake CHANGES clause: CHANGES (INFORMATION => ...) AT (...) END (...)
1449    #[serde(default, skip_serializing_if = "Option::is_none")]
1450    pub changes: Option<Box<Changes>>,
1451    /// Time travel version clause: FOR VERSION AS OF / FOR TIMESTAMP AS OF (Presto/Trino, BigQuery, Databricks)
1452    #[serde(default, skip_serializing_if = "Option::is_none")]
1453    pub version: Option<Box<Version>>,
1454}
1455
1456impl TableRef {
1457    pub fn new(name: impl Into<String>) -> Self {
1458        Self {
1459            name: Identifier::new(name),
1460            schema: None,
1461            catalog: None,
1462            alias: None,
1463            alias_explicit_as: false,
1464            column_aliases: Vec::new(),
1465            trailing_comments: Vec::new(),
1466            when: None,
1467            only: false,
1468            final_: false,
1469            table_sample: None,
1470            hints: Vec::new(),
1471            system_time: None,
1472            partitions: Vec::new(),
1473            identifier_func: None,
1474            changes: None,
1475            version: None,
1476        }
1477    }
1478
1479    /// Create with a schema qualifier.
1480    pub fn new_with_schema(name: impl Into<String>, schema: impl Into<String>) -> Self {
1481        let mut t = Self::new(name);
1482        t.schema = Some(Identifier::new(schema));
1483        t
1484    }
1485
1486    /// Create with catalog and schema qualifiers.
1487    pub fn new_with_catalog(
1488        name: impl Into<String>,
1489        schema: impl Into<String>,
1490        catalog: impl Into<String>,
1491    ) -> Self {
1492        let mut t = Self::new(name);
1493        t.schema = Some(Identifier::new(schema));
1494        t.catalog = Some(Identifier::new(catalog));
1495        t
1496    }
1497
1498    /// Create from an Identifier, preserving the quoted flag
1499    pub fn from_identifier(name: Identifier) -> Self {
1500        Self {
1501            name,
1502            schema: None,
1503            catalog: None,
1504            alias: None,
1505            alias_explicit_as: false,
1506            column_aliases: Vec::new(),
1507            trailing_comments: Vec::new(),
1508            when: None,
1509            only: false,
1510            final_: false,
1511            table_sample: None,
1512            hints: Vec::new(),
1513            system_time: None,
1514            partitions: Vec::new(),
1515            identifier_func: None,
1516            changes: None,
1517            version: None,
1518        }
1519    }
1520
1521    pub fn with_alias(mut self, alias: impl Into<String>) -> Self {
1522        self.alias = Some(Identifier::new(alias));
1523        self
1524    }
1525
1526    pub fn with_schema(mut self, schema: impl Into<String>) -> Self {
1527        self.schema = Some(Identifier::new(schema));
1528        self
1529    }
1530}
1531
1532/// Represent a wildcard star expression (`*`, `table.*`).
1533///
1534/// Supports the EXCEPT/EXCLUDE, REPLACE, and RENAME modifiers found in
1535/// DuckDB, BigQuery, and Snowflake (e.g. `SELECT * EXCEPT (id) FROM t`).
1536#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1537#[cfg_attr(feature = "bindings", derive(TS))]
1538pub struct Star {
1539    /// Optional table qualifier (e.g. `t` in `t.*`).
1540    pub table: Option<Identifier>,
1541    /// EXCLUDE / EXCEPT columns (DuckDB, BigQuery, Snowflake)
1542    pub except: Option<Vec<Identifier>>,
1543    /// REPLACE expressions (BigQuery, Snowflake)
1544    pub replace: Option<Vec<Alias>>,
1545    /// RENAME columns (Snowflake)
1546    pub rename: Option<Vec<(Identifier, Identifier)>>,
1547    /// Trailing comments that appeared after the star
1548    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1549    pub trailing_comments: Vec<String>,
1550}
1551
1552/// Represent a complete SELECT statement.
1553///
1554/// This is the most feature-rich AST node, covering the full surface area of
1555/// SELECT syntax across 30+ SQL dialects. Fields that are `Option` or empty
1556/// `Vec` are omitted from the generated SQL when absent.
1557///
1558/// # Key Fields
1559///
1560/// - `expressions` -- the select-list (columns, `*`, computed expressions).
1561/// - `from` -- the FROM clause. `None` for `SELECT 1` style queries.
1562/// - `joins` -- zero or more JOIN clauses, each with a [`JoinKind`].
1563/// - `where_clause` -- the WHERE predicate.
1564/// - `group_by` -- GROUP BY, including ROLLUP/CUBE/GROUPING SETS.
1565/// - `having` -- HAVING predicate.
1566/// - `order_by` -- ORDER BY with ASC/DESC and NULLS FIRST/LAST.
1567/// - `limit` / `offset` / `fetch` -- result set limiting.
1568/// - `with` -- Common Table Expressions (CTEs).
1569/// - `distinct` / `distinct_on` -- DISTINCT and PostgreSQL DISTINCT ON.
1570/// - `windows` -- named window definitions (WINDOW w AS ...).
1571///
1572/// Dialect-specific extensions are supported via fields like `prewhere`
1573/// (ClickHouse), `qualify` (Snowflake/BigQuery/DuckDB), `connect` (Oracle
1574/// CONNECT BY), `for_xml` (TSQL), and `settings` (ClickHouse).
1575#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1576#[cfg_attr(feature = "bindings", derive(TS))]
1577pub struct Select {
1578    /// The select-list: columns, expressions, aliases, and wildcards.
1579    pub expressions: Vec<Expression>,
1580    /// The FROM clause, containing one or more table sources.
1581    pub from: Option<From>,
1582    /// JOIN clauses applied after the FROM source.
1583    pub joins: Vec<Join>,
1584    pub lateral_views: Vec<LateralView>,
1585    /// ClickHouse PREWHERE clause
1586    #[serde(default, skip_serializing_if = "Option::is_none")]
1587    pub prewhere: Option<Expression>,
1588    pub where_clause: Option<Where>,
1589    pub group_by: Option<GroupBy>,
1590    pub having: Option<Having>,
1591    pub qualify: Option<Qualify>,
1592    pub order_by: Option<OrderBy>,
1593    pub distribute_by: Option<DistributeBy>,
1594    pub cluster_by: Option<ClusterBy>,
1595    pub sort_by: Option<SortBy>,
1596    pub limit: Option<Limit>,
1597    pub offset: Option<Offset>,
1598    /// ClickHouse LIMIT BY clause expressions
1599    #[serde(default, skip_serializing_if = "Option::is_none")]
1600    pub limit_by: Option<Vec<Expression>>,
1601    pub fetch: Option<Fetch>,
1602    pub distinct: bool,
1603    pub distinct_on: Option<Vec<Expression>>,
1604    pub top: Option<Top>,
1605    pub with: Option<With>,
1606    pub sample: Option<Sample>,
1607    /// ClickHouse SETTINGS clause (e.g., SETTINGS max_threads = 4)
1608    #[serde(default, skip_serializing_if = "Option::is_none")]
1609    pub settings: Option<Vec<Expression>>,
1610    /// ClickHouse FORMAT clause (e.g., FORMAT PrettyCompact)
1611    #[serde(default, skip_serializing_if = "Option::is_none")]
1612    pub format: Option<Expression>,
1613    pub windows: Option<Vec<NamedWindow>>,
1614    pub hint: Option<Hint>,
1615    /// Oracle CONNECT BY clause for hierarchical queries
1616    pub connect: Option<Connect>,
1617    /// SELECT ... INTO table_name for creating tables
1618    pub into: Option<SelectInto>,
1619    /// FOR UPDATE/SHARE locking clauses
1620    #[serde(default)]
1621    pub locks: Vec<Lock>,
1622    /// T-SQL FOR XML clause options (PATH, RAW, AUTO, EXPLICIT, BINARY BASE64, ELEMENTS XSINIL, etc.)
1623    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1624    pub for_xml: Vec<Expression>,
1625    /// Leading comments before the statement
1626    #[serde(default)]
1627    pub leading_comments: Vec<String>,
1628    /// Comments that appear after SELECT keyword (before expressions)
1629    /// e.g., SELECT /*hint*/ col -> post_select_comments: ["/*hint*/"]
1630    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1631    pub post_select_comments: Vec<String>,
1632    /// BigQuery SELECT AS STRUCT / SELECT AS VALUE kind
1633    #[serde(default, skip_serializing_if = "Option::is_none")]
1634    pub kind: Option<String>,
1635    /// MySQL operation modifiers (HIGH_PRIORITY, STRAIGHT_JOIN, SQL_CALC_FOUND_ROWS, etc.)
1636    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1637    pub operation_modifiers: Vec<String>,
1638    /// Whether QUALIFY appears after WINDOW (DuckDB) vs before (Snowflake/BigQuery default)
1639    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
1640    pub qualify_after_window: bool,
1641    /// TSQL OPTION clause (e.g., OPTION(LABEL = 'foo'))
1642    #[serde(default, skip_serializing_if = "Option::is_none")]
1643    pub option: Option<String>,
1644}
1645
1646impl Select {
1647    pub fn new() -> Self {
1648        Self {
1649            expressions: Vec::new(),
1650            from: None,
1651            joins: Vec::new(),
1652            lateral_views: Vec::new(),
1653            prewhere: None,
1654            where_clause: None,
1655            group_by: None,
1656            having: None,
1657            qualify: None,
1658            order_by: None,
1659            distribute_by: None,
1660            cluster_by: None,
1661            sort_by: None,
1662            limit: None,
1663            offset: None,
1664            limit_by: None,
1665            fetch: None,
1666            distinct: false,
1667            distinct_on: None,
1668            top: None,
1669            with: None,
1670            sample: None,
1671            settings: None,
1672            format: None,
1673            windows: None,
1674            hint: None,
1675            connect: None,
1676            into: None,
1677            locks: Vec::new(),
1678            for_xml: Vec::new(),
1679            leading_comments: Vec::new(),
1680            post_select_comments: Vec::new(),
1681            kind: None,
1682            operation_modifiers: Vec::new(),
1683            qualify_after_window: false,
1684            option: None,
1685        }
1686    }
1687
1688    /// Add a column to select
1689    pub fn column(mut self, expr: Expression) -> Self {
1690        self.expressions.push(expr);
1691        self
1692    }
1693
1694    /// Set the FROM clause
1695    pub fn from(mut self, table: Expression) -> Self {
1696        self.from = Some(From {
1697            expressions: vec![table],
1698        });
1699        self
1700    }
1701
1702    /// Add a WHERE clause
1703    pub fn where_(mut self, condition: Expression) -> Self {
1704        self.where_clause = Some(Where { this: condition });
1705        self
1706    }
1707
1708    /// Set DISTINCT
1709    pub fn distinct(mut self) -> Self {
1710        self.distinct = true;
1711        self
1712    }
1713
1714    /// Add a JOIN
1715    pub fn join(mut self, join: Join) -> Self {
1716        self.joins.push(join);
1717        self
1718    }
1719
1720    /// Set ORDER BY
1721    pub fn order_by(mut self, expressions: Vec<Ordered>) -> Self {
1722        self.order_by = Some(OrderBy { expressions, siblings: false });
1723        self
1724    }
1725
1726    /// Set LIMIT
1727    pub fn limit(mut self, n: Expression) -> Self {
1728        self.limit = Some(Limit { this: n, percent: false });
1729        self
1730    }
1731
1732    /// Set OFFSET
1733    pub fn offset(mut self, n: Expression) -> Self {
1734        self.offset = Some(Offset { this: n, rows: None });
1735        self
1736    }
1737}
1738
1739impl Default for Select {
1740    fn default() -> Self {
1741        Self::new()
1742    }
1743}
1744
1745/// Represent a UNION set operation between two query expressions.
1746///
1747/// When `all` is true, duplicate rows are preserved (UNION ALL).
1748/// ORDER BY, LIMIT, and OFFSET can be applied to the combined result.
1749/// Supports DuckDB's BY NAME modifier and BigQuery's CORRESPONDING modifier.
1750#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1751#[cfg_attr(feature = "bindings", derive(TS))]
1752pub struct Union {
1753    /// The left-hand query operand.
1754    pub left: Expression,
1755    /// The right-hand query operand.
1756    pub right: Expression,
1757    /// Whether UNION ALL (true) or UNION (false, which deduplicates).
1758    pub all: bool,
1759    /// Whether DISTINCT was explicitly specified
1760    #[serde(default)]
1761    pub distinct: bool,
1762    /// Optional WITH clause
1763    pub with: Option<With>,
1764    /// ORDER BY applied to entire UNION result
1765    pub order_by: Option<OrderBy>,
1766    /// LIMIT applied to entire UNION result
1767    pub limit: Option<Box<Expression>>,
1768    /// OFFSET applied to entire UNION result
1769    pub offset: Option<Box<Expression>>,
1770    /// DISTRIBUTE BY clause (Hive/Spark)
1771    #[serde(default, skip_serializing_if = "Option::is_none")]
1772    pub distribute_by: Option<DistributeBy>,
1773    /// SORT BY clause (Hive/Spark)
1774    #[serde(default, skip_serializing_if = "Option::is_none")]
1775    pub sort_by: Option<SortBy>,
1776    /// CLUSTER BY clause (Hive/Spark)
1777    #[serde(default, skip_serializing_if = "Option::is_none")]
1778    pub cluster_by: Option<ClusterBy>,
1779    /// DuckDB BY NAME modifier
1780    #[serde(default)]
1781    pub by_name: bool,
1782    /// BigQuery: Set operation side (LEFT, RIGHT, FULL)
1783    #[serde(default, skip_serializing_if = "Option::is_none")]
1784    pub side: Option<String>,
1785    /// BigQuery: Set operation kind (INNER)
1786    #[serde(default, skip_serializing_if = "Option::is_none")]
1787    pub kind: Option<String>,
1788    /// BigQuery: CORRESPONDING modifier
1789    #[serde(default)]
1790    pub corresponding: bool,
1791    /// BigQuery: STRICT modifier (before CORRESPONDING)
1792    #[serde(default)]
1793    pub strict: bool,
1794    /// BigQuery: BY (columns) after CORRESPONDING
1795    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1796    pub on_columns: Vec<Expression>,
1797}
1798
1799/// Represent an INTERSECT set operation between two query expressions.
1800///
1801/// Returns only rows that appear in both operands. When `all` is true,
1802/// duplicates are preserved according to their multiplicity.
1803#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1804#[cfg_attr(feature = "bindings", derive(TS))]
1805pub struct Intersect {
1806    /// The left-hand query operand.
1807    pub left: Expression,
1808    /// The right-hand query operand.
1809    pub right: Expression,
1810    /// Whether INTERSECT ALL (true) or INTERSECT (false, which deduplicates).
1811    pub all: bool,
1812    /// Whether DISTINCT was explicitly specified
1813    #[serde(default)]
1814    pub distinct: bool,
1815    /// Optional WITH clause
1816    pub with: Option<With>,
1817    /// ORDER BY applied to entire INTERSECT result
1818    pub order_by: Option<OrderBy>,
1819    /// LIMIT applied to entire INTERSECT result
1820    pub limit: Option<Box<Expression>>,
1821    /// OFFSET applied to entire INTERSECT result
1822    pub offset: Option<Box<Expression>>,
1823    /// DISTRIBUTE BY clause (Hive/Spark)
1824    #[serde(default, skip_serializing_if = "Option::is_none")]
1825    pub distribute_by: Option<DistributeBy>,
1826    /// SORT BY clause (Hive/Spark)
1827    #[serde(default, skip_serializing_if = "Option::is_none")]
1828    pub sort_by: Option<SortBy>,
1829    /// CLUSTER BY clause (Hive/Spark)
1830    #[serde(default, skip_serializing_if = "Option::is_none")]
1831    pub cluster_by: Option<ClusterBy>,
1832    /// DuckDB BY NAME modifier
1833    #[serde(default)]
1834    pub by_name: bool,
1835    /// BigQuery: Set operation side (LEFT, RIGHT, FULL)
1836    #[serde(default, skip_serializing_if = "Option::is_none")]
1837    pub side: Option<String>,
1838    /// BigQuery: Set operation kind (INNER)
1839    #[serde(default, skip_serializing_if = "Option::is_none")]
1840    pub kind: Option<String>,
1841    /// BigQuery: CORRESPONDING modifier
1842    #[serde(default)]
1843    pub corresponding: bool,
1844    /// BigQuery: STRICT modifier (before CORRESPONDING)
1845    #[serde(default)]
1846    pub strict: bool,
1847    /// BigQuery: BY (columns) after CORRESPONDING
1848    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1849    pub on_columns: Vec<Expression>,
1850}
1851
1852/// Represent an EXCEPT (MINUS) set operation between two query expressions.
1853///
1854/// Returns rows from the left operand that do not appear in the right operand.
1855/// When `all` is true, duplicates are subtracted according to their multiplicity.
1856#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1857#[cfg_attr(feature = "bindings", derive(TS))]
1858pub struct Except {
1859    /// The left-hand query operand.
1860    pub left: Expression,
1861    /// The right-hand query operand (rows to subtract).
1862    pub right: Expression,
1863    /// Whether EXCEPT ALL (true) or EXCEPT (false, which deduplicates).
1864    pub all: bool,
1865    /// Whether DISTINCT was explicitly specified
1866    #[serde(default)]
1867    pub distinct: bool,
1868    /// Optional WITH clause
1869    pub with: Option<With>,
1870    /// ORDER BY applied to entire EXCEPT result
1871    pub order_by: Option<OrderBy>,
1872    /// LIMIT applied to entire EXCEPT result
1873    pub limit: Option<Box<Expression>>,
1874    /// OFFSET applied to entire EXCEPT result
1875    pub offset: Option<Box<Expression>>,
1876    /// DISTRIBUTE BY clause (Hive/Spark)
1877    #[serde(default, skip_serializing_if = "Option::is_none")]
1878    pub distribute_by: Option<DistributeBy>,
1879    /// SORT BY clause (Hive/Spark)
1880    #[serde(default, skip_serializing_if = "Option::is_none")]
1881    pub sort_by: Option<SortBy>,
1882    /// CLUSTER BY clause (Hive/Spark)
1883    #[serde(default, skip_serializing_if = "Option::is_none")]
1884    pub cluster_by: Option<ClusterBy>,
1885    /// DuckDB BY NAME modifier
1886    #[serde(default)]
1887    pub by_name: bool,
1888    /// BigQuery: Set operation side (LEFT, RIGHT, FULL)
1889    #[serde(default, skip_serializing_if = "Option::is_none")]
1890    pub side: Option<String>,
1891    /// BigQuery: Set operation kind (INNER)
1892    #[serde(default, skip_serializing_if = "Option::is_none")]
1893    pub kind: Option<String>,
1894    /// BigQuery: CORRESPONDING modifier
1895    #[serde(default)]
1896    pub corresponding: bool,
1897    /// BigQuery: STRICT modifier (before CORRESPONDING)
1898    #[serde(default)]
1899    pub strict: bool,
1900    /// BigQuery: BY (columns) after CORRESPONDING
1901    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1902    pub on_columns: Vec<Expression>,
1903}
1904
1905/// INTO clause for SELECT INTO statements
1906#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1907#[cfg_attr(feature = "bindings", derive(TS))]
1908pub struct SelectInto {
1909    /// Target table or variable (used when single target)
1910    pub this: Expression,
1911    /// Whether TEMPORARY keyword was used
1912    #[serde(default)]
1913    pub temporary: bool,
1914    /// Whether UNLOGGED keyword was used (PostgreSQL)
1915    #[serde(default)]
1916    pub unlogged: bool,
1917    /// Whether BULK COLLECT INTO was used (Oracle PL/SQL)
1918    #[serde(default)]
1919    pub bulk_collect: bool,
1920    /// Multiple target variables (Oracle PL/SQL: BULK COLLECT INTO v1, v2)
1921    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1922    pub expressions: Vec<Expression>,
1923}
1924
1925/// Represent a parenthesized subquery expression.
1926///
1927/// A subquery wraps an inner query (typically a SELECT, UNION, etc.) in
1928/// parentheses and optionally applies an alias, column aliases, ORDER BY,
1929/// LIMIT, and OFFSET. The `modifiers_inside` flag controls whether the
1930/// modifiers are rendered inside or outside the parentheses.
1931///
1932/// Subqueries appear in many SQL contexts: FROM clauses, WHERE IN/EXISTS,
1933/// scalar subqueries in select-lists, and derived tables.
1934#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1935#[cfg_attr(feature = "bindings", derive(TS))]
1936pub struct Subquery {
1937    /// The inner query expression.
1938    pub this: Expression,
1939    /// Optional alias for the derived table.
1940    pub alias: Option<Identifier>,
1941    /// Optional column aliases: AS t(c1, c2)
1942    pub column_aliases: Vec<Identifier>,
1943    /// ORDER BY clause (for parenthesized queries)
1944    pub order_by: Option<OrderBy>,
1945    /// LIMIT clause
1946    pub limit: Option<Limit>,
1947    /// OFFSET clause
1948    pub offset: Option<Offset>,
1949    /// DISTRIBUTE BY clause (Hive/Spark)
1950    #[serde(default, skip_serializing_if = "Option::is_none")]
1951    pub distribute_by: Option<DistributeBy>,
1952    /// SORT BY clause (Hive/Spark)
1953    #[serde(default, skip_serializing_if = "Option::is_none")]
1954    pub sort_by: Option<SortBy>,
1955    /// CLUSTER BY clause (Hive/Spark)
1956    #[serde(default, skip_serializing_if = "Option::is_none")]
1957    pub cluster_by: Option<ClusterBy>,
1958    /// Whether this is a LATERAL subquery (can reference earlier tables in FROM)
1959    #[serde(default)]
1960    pub lateral: bool,
1961    /// Whether modifiers (ORDER BY, LIMIT, OFFSET) should be generated inside the parentheses
1962    /// true: (SELECT 1 LIMIT 1)  - modifiers inside
1963    /// false: (SELECT 1) LIMIT 1 - modifiers outside
1964    #[serde(default)]
1965    pub modifiers_inside: bool,
1966    /// Trailing comments after the closing paren
1967    #[serde(default)]
1968    pub trailing_comments: Vec<String>,
1969}
1970
1971/// Pipe operator expression: query |> transform
1972///
1973/// Used in DataFusion and BigQuery pipe syntax:
1974///   FROM t |> WHERE x > 1 |> SELECT x, y |> ORDER BY x |> LIMIT 10
1975#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1976#[cfg_attr(feature = "bindings", derive(TS))]
1977pub struct PipeOperator {
1978    /// The input query/expression (left side of |>)
1979    pub this: Expression,
1980    /// The piped operation (right side of |>)
1981    pub expression: Expression,
1982}
1983
1984/// VALUES table constructor: VALUES (1, 'a'), (2, 'b')
1985#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1986#[cfg_attr(feature = "bindings", derive(TS))]
1987pub struct Values {
1988    /// The rows of values
1989    pub expressions: Vec<Tuple>,
1990    /// Optional alias for the table
1991    pub alias: Option<Identifier>,
1992    /// Optional column aliases: AS t(c1, c2)
1993    pub column_aliases: Vec<Identifier>,
1994}
1995
1996/// PIVOT operation - supports both standard and DuckDB simplified syntax
1997///
1998/// Standard syntax (in FROM clause):
1999///   table PIVOT(agg_func [AS alias], ... FOR column IN (value [AS alias], ...))
2000///   table UNPIVOT(value_col FOR name_col IN (col1, col2, ...))
2001///
2002/// DuckDB simplified syntax (statement-level):
2003///   PIVOT table ON columns [IN (...)] USING agg_func [AS alias], ... [GROUP BY ...]
2004///   UNPIVOT table ON columns INTO NAME name_col VALUE val_col
2005#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2006#[cfg_attr(feature = "bindings", derive(TS))]
2007pub struct Pivot {
2008    /// Source table/expression
2009    pub this: Expression,
2010    /// For standard PIVOT: the aggregation function(s) (first is primary)
2011    /// For DuckDB simplified: unused (use `using` instead)
2012    #[serde(default)]
2013    pub expressions: Vec<Expression>,
2014    /// For standard PIVOT: the FOR...IN clause(s) as In expressions
2015    #[serde(default)]
2016    pub fields: Vec<Expression>,
2017    /// For standard: unused. For DuckDB simplified: the USING aggregation functions
2018    #[serde(default)]
2019    pub using: Vec<Expression>,
2020    /// GROUP BY clause (used in both standard inside-parens and DuckDB simplified)
2021    #[serde(default)]
2022    pub group: Option<Box<Expression>>,
2023    /// Whether this is an UNPIVOT (vs PIVOT)
2024    #[serde(default)]
2025    pub unpivot: bool,
2026    /// For DuckDB UNPIVOT: INTO NAME col VALUE col
2027    #[serde(default)]
2028    pub into: Option<Box<Expression>>,
2029    /// Optional alias
2030    #[serde(default)]
2031    pub alias: Option<Identifier>,
2032    /// Include/exclude nulls (for UNPIVOT)
2033    #[serde(default)]
2034    pub include_nulls: Option<bool>,
2035    /// Default on null value (Snowflake)
2036    #[serde(default)]
2037    pub default_on_null: Option<Box<Expression>>,
2038    /// WITH clause (CTEs)
2039    #[serde(default, skip_serializing_if = "Option::is_none")]
2040    pub with: Option<With>,
2041}
2042
2043/// UNPIVOT operation
2044#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2045#[cfg_attr(feature = "bindings", derive(TS))]
2046pub struct Unpivot {
2047    pub this: Expression,
2048    pub value_column: Identifier,
2049    pub name_column: Identifier,
2050    pub columns: Vec<Expression>,
2051    pub alias: Option<Identifier>,
2052    /// Whether the value_column was parenthesized in the original SQL
2053    #[serde(default)]
2054    pub value_column_parenthesized: bool,
2055    /// INCLUDE NULLS (true), EXCLUDE NULLS (false), or not specified (None)
2056    #[serde(default)]
2057    pub include_nulls: Option<bool>,
2058    /// Additional value columns when parenthesized (e.g., (first_half_sales, second_half_sales))
2059    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2060    pub extra_value_columns: Vec<Identifier>,
2061}
2062
2063/// PIVOT alias for aliasing pivot expressions
2064/// The alias can be an identifier or an expression (for Oracle/BigQuery string concatenation aliases)
2065#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2066#[cfg_attr(feature = "bindings", derive(TS))]
2067pub struct PivotAlias {
2068    pub this: Expression,
2069    pub alias: Expression,
2070}
2071
2072/// PREWHERE clause (ClickHouse) - early filtering before WHERE
2073#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2074#[cfg_attr(feature = "bindings", derive(TS))]
2075pub struct PreWhere {
2076    pub this: Expression,
2077}
2078
2079/// STREAM definition (Snowflake) - for change data capture
2080#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2081#[cfg_attr(feature = "bindings", derive(TS))]
2082pub struct Stream {
2083    pub this: Expression,
2084    #[serde(skip_serializing_if = "Option::is_none")]
2085    pub on: Option<Expression>,
2086    #[serde(skip_serializing_if = "Option::is_none")]
2087    pub show_initial_rows: Option<bool>,
2088}
2089
2090/// USING DATA clause for data import statements
2091#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2092#[cfg_attr(feature = "bindings", derive(TS))]
2093pub struct UsingData {
2094    pub this: Expression,
2095}
2096
2097/// XML Namespace declaration
2098#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2099#[cfg_attr(feature = "bindings", derive(TS))]
2100pub struct XmlNamespace {
2101    pub this: Expression,
2102    #[serde(skip_serializing_if = "Option::is_none")]
2103    pub alias: Option<Identifier>,
2104}
2105
2106/// ROW FORMAT clause for Hive/Spark
2107#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2108#[cfg_attr(feature = "bindings", derive(TS))]
2109pub struct RowFormat {
2110    pub delimited: bool,
2111    pub fields_terminated_by: Option<String>,
2112    pub collection_items_terminated_by: Option<String>,
2113    pub map_keys_terminated_by: Option<String>,
2114    pub lines_terminated_by: Option<String>,
2115    pub null_defined_as: Option<String>,
2116}
2117
2118/// Directory insert for INSERT OVERWRITE DIRECTORY (Hive/Spark)
2119#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2120#[cfg_attr(feature = "bindings", derive(TS))]
2121pub struct DirectoryInsert {
2122    pub local: bool,
2123    pub path: String,
2124    pub row_format: Option<RowFormat>,
2125    /// STORED AS clause (e.g., TEXTFILE, ORC, PARQUET)
2126    #[serde(default)]
2127    pub stored_as: Option<String>,
2128}
2129
2130/// INSERT statement
2131#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2132#[cfg_attr(feature = "bindings", derive(TS))]
2133pub struct Insert {
2134    pub table: TableRef,
2135    pub columns: Vec<Identifier>,
2136    pub values: Vec<Vec<Expression>>,
2137    pub query: Option<Expression>,
2138    /// INSERT OVERWRITE for Hive/Spark
2139    pub overwrite: bool,
2140    /// PARTITION clause for Hive/Spark
2141    pub partition: Vec<(Identifier, Option<Expression>)>,
2142    /// INSERT OVERWRITE DIRECTORY for Hive/Spark
2143    #[serde(default)]
2144    pub directory: Option<DirectoryInsert>,
2145    /// RETURNING clause (PostgreSQL, SQLite)
2146    #[serde(default)]
2147    pub returning: Vec<Expression>,
2148    /// OUTPUT clause (TSQL)
2149    #[serde(default)]
2150    pub output: Option<OutputClause>,
2151    /// ON CONFLICT clause (PostgreSQL, SQLite)
2152    #[serde(default)]
2153    pub on_conflict: Option<Box<Expression>>,
2154    /// Leading comments before the statement
2155    #[serde(default)]
2156    pub leading_comments: Vec<String>,
2157    /// IF EXISTS clause (Hive)
2158    #[serde(default)]
2159    pub if_exists: bool,
2160    /// WITH clause (CTEs)
2161    #[serde(default)]
2162    pub with: Option<With>,
2163    /// INSERT IGNORE (MySQL) - ignore duplicate key errors
2164    #[serde(default)]
2165    pub ignore: bool,
2166    /// Source alias for VALUES clause (MySQL): VALUES (1, 2) AS new_data
2167    #[serde(default)]
2168    pub source_alias: Option<Identifier>,
2169    /// Table alias (PostgreSQL): INSERT INTO table AS t(...)
2170    #[serde(default)]
2171    pub alias: Option<Identifier>,
2172    /// Whether the alias uses explicit AS keyword
2173    #[serde(default)]
2174    pub alias_explicit_as: bool,
2175    /// DEFAULT VALUES (PostgreSQL): INSERT INTO t DEFAULT VALUES
2176    #[serde(default)]
2177    pub default_values: bool,
2178    /// BY NAME modifier (DuckDB): INSERT INTO x BY NAME SELECT ...
2179    #[serde(default)]
2180    pub by_name: bool,
2181    /// SQLite conflict action: INSERT OR ABORT|FAIL|IGNORE|REPLACE|ROLLBACK INTO ...
2182    #[serde(default, skip_serializing_if = "Option::is_none")]
2183    pub conflict_action: Option<String>,
2184    /// MySQL/SQLite REPLACE INTO statement (treat like INSERT)
2185    #[serde(default)]
2186    pub is_replace: bool,
2187    /// Oracle-style hint: INSERT /*+ APPEND */ INTO ...
2188    #[serde(default, skip_serializing_if = "Option::is_none")]
2189    pub hint: Option<Hint>,
2190    /// REPLACE WHERE clause (Databricks): INSERT INTO a REPLACE WHERE cond VALUES ...
2191    #[serde(default)]
2192    pub replace_where: Option<Box<Expression>>,
2193    /// Source table (Hive/Spark): INSERT OVERWRITE TABLE target TABLE source
2194    #[serde(default)]
2195    pub source: Option<Box<Expression>>,
2196    /// ClickHouse: INSERT INTO FUNCTION func_name(...) - the function call
2197    #[serde(default, skip_serializing_if = "Option::is_none")]
2198    pub function_target: Option<Box<Expression>>,
2199    /// ClickHouse: PARTITION BY expr
2200    #[serde(default, skip_serializing_if = "Option::is_none")]
2201    pub partition_by: Option<Box<Expression>>,
2202    /// ClickHouse: SETTINGS key = val, ...
2203    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2204    pub settings: Vec<Expression>,
2205}
2206
2207/// OUTPUT clause (TSQL) - used in INSERT, UPDATE, DELETE
2208#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2209#[cfg_attr(feature = "bindings", derive(TS))]
2210pub struct OutputClause {
2211    /// Columns/expressions to output
2212    pub columns: Vec<Expression>,
2213    /// Optional INTO target table or table variable
2214    #[serde(default)]
2215    pub into_table: Option<Expression>,
2216}
2217
2218/// UPDATE statement
2219#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2220#[cfg_attr(feature = "bindings", derive(TS))]
2221pub struct Update {
2222    pub table: TableRef,
2223    /// Additional tables for multi-table UPDATE (MySQL syntax)
2224    #[serde(default)]
2225    pub extra_tables: Vec<TableRef>,
2226    /// JOINs attached to the table list (MySQL multi-table syntax)
2227    #[serde(default)]
2228    pub table_joins: Vec<Join>,
2229    pub set: Vec<(Identifier, Expression)>,
2230    pub from_clause: Option<From>,
2231    /// JOINs after FROM clause (PostgreSQL, Snowflake, SQL Server syntax)
2232    #[serde(default)]
2233    pub from_joins: Vec<Join>,
2234    pub where_clause: Option<Where>,
2235    /// RETURNING clause (PostgreSQL, SQLite)
2236    #[serde(default)]
2237    pub returning: Vec<Expression>,
2238    /// OUTPUT clause (TSQL)
2239    #[serde(default)]
2240    pub output: Option<OutputClause>,
2241    /// WITH clause (CTEs)
2242    #[serde(default)]
2243    pub with: Option<With>,
2244    /// Leading comments before the statement
2245    #[serde(default)]
2246    pub leading_comments: Vec<String>,
2247    /// LIMIT clause (MySQL)
2248    #[serde(default)]
2249    pub limit: Option<Expression>,
2250    /// ORDER BY clause (MySQL)
2251    #[serde(default)]
2252    pub order_by: Option<OrderBy>,
2253    /// Whether FROM clause appears before SET (Snowflake syntax)
2254    #[serde(default)]
2255    pub from_before_set: bool,
2256}
2257
2258/// DELETE statement
2259#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2260#[cfg_attr(feature = "bindings", derive(TS))]
2261pub struct Delete {
2262    pub table: TableRef,
2263    /// ClickHouse: ON CLUSTER clause for distributed DDL
2264    #[serde(default, skip_serializing_if = "Option::is_none")]
2265    pub on_cluster: Option<OnCluster>,
2266    /// Optional alias for the table
2267    pub alias: Option<Identifier>,
2268    /// Whether the alias was declared with explicit AS keyword
2269    #[serde(default)]
2270    pub alias_explicit_as: bool,
2271    /// PostgreSQL/DuckDB USING clause - additional tables to join
2272    pub using: Vec<TableRef>,
2273    pub where_clause: Option<Where>,
2274    /// OUTPUT clause (TSQL)
2275    #[serde(default)]
2276    pub output: Option<OutputClause>,
2277    /// Leading comments before the statement
2278    #[serde(default)]
2279    pub leading_comments: Vec<String>,
2280    /// WITH clause (CTEs)
2281    #[serde(default)]
2282    pub with: Option<With>,
2283    /// LIMIT clause (MySQL)
2284    #[serde(default)]
2285    pub limit: Option<Expression>,
2286    /// ORDER BY clause (MySQL)
2287    #[serde(default)]
2288    pub order_by: Option<OrderBy>,
2289    /// RETURNING clause (PostgreSQL)
2290    #[serde(default)]
2291    pub returning: Vec<Expression>,
2292    /// MySQL multi-table DELETE: DELETE t1, t2 FROM ... or DELETE FROM t1, t2 USING ...
2293    /// These are the target tables to delete from
2294    #[serde(default)]
2295    pub tables: Vec<TableRef>,
2296    /// True if tables were after FROM keyword (DELETE FROM t1, t2 USING syntax)
2297    /// False if tables were before FROM keyword (DELETE t1, t2 FROM syntax)
2298    #[serde(default)]
2299    pub tables_from_using: bool,
2300    /// JOINs in MySQL multi-table DELETE: DELETE t1 FROM t1 LEFT JOIN t2 ...
2301    #[serde(default)]
2302    pub joins: Vec<Join>,
2303    /// FORCE INDEX hint (MySQL): DELETE FROM t FORCE INDEX (idx)
2304    #[serde(default)]
2305    pub force_index: Option<String>,
2306    /// BigQuery-style DELETE without FROM keyword: DELETE table WHERE ...
2307    #[serde(default)]
2308    pub no_from: bool,
2309}
2310
2311/// COPY statement (Snowflake, PostgreSQL, DuckDB, TSQL)
2312#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2313#[cfg_attr(feature = "bindings", derive(TS))]
2314pub struct CopyStmt {
2315    /// Target table or query
2316    pub this: Expression,
2317    /// True for FROM (loading into table), false for TO (exporting)
2318    pub kind: bool,
2319    /// Source/destination file(s) or stage
2320    pub files: Vec<Expression>,
2321    /// Copy parameters
2322    #[serde(default)]
2323    pub params: Vec<CopyParameter>,
2324    /// Credentials for external access
2325    #[serde(default)]
2326    pub credentials: Option<Box<Credentials>>,
2327    /// Whether the INTO keyword was used (COPY INTO vs COPY)
2328    #[serde(default)]
2329    pub is_into: bool,
2330    /// Whether parameters are wrapped in WITH (...) syntax
2331    #[serde(default)]
2332    pub with_wrapped: bool,
2333}
2334
2335/// COPY parameter (e.g., FILE_FORMAT = CSV or FORMAT PARQUET)
2336#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2337#[cfg_attr(feature = "bindings", derive(TS))]
2338pub struct CopyParameter {
2339    pub name: String,
2340    pub value: Option<Expression>,
2341    pub values: Vec<Expression>,
2342    /// Whether the parameter used = sign (TSQL: KEY = VALUE vs DuckDB: KEY VALUE)
2343    #[serde(default)]
2344    pub eq: bool,
2345}
2346
2347/// Credentials for external access (S3, Azure, etc.)
2348#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2349#[cfg_attr(feature = "bindings", derive(TS))]
2350pub struct Credentials {
2351    pub credentials: Vec<(String, String)>,
2352    pub encryption: Option<String>,
2353    pub storage: Option<String>,
2354}
2355
2356/// PUT statement (Snowflake)
2357#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2358#[cfg_attr(feature = "bindings", derive(TS))]
2359pub struct PutStmt {
2360    /// Source file path
2361    pub source: String,
2362    /// Whether source was quoted in the original SQL
2363    #[serde(default)]
2364    pub source_quoted: bool,
2365    /// Target stage
2366    pub target: Expression,
2367    /// PUT parameters
2368    #[serde(default)]
2369    pub params: Vec<CopyParameter>,
2370}
2371
2372/// Stage reference (Snowflake) - @stage_name or @namespace.stage/path
2373#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2374#[cfg_attr(feature = "bindings", derive(TS))]
2375pub struct StageReference {
2376    /// Stage name including @ prefix (e.g., "@mystage", "@namespace.mystage")
2377    pub name: String,
2378    /// Optional path within the stage (e.g., "/path/to/file.csv")
2379    #[serde(default)]
2380    pub path: Option<String>,
2381    /// Optional FILE_FORMAT parameter
2382    #[serde(default)]
2383    pub file_format: Option<Expression>,
2384    /// Optional PATTERN parameter
2385    #[serde(default)]
2386    pub pattern: Option<String>,
2387    /// Whether the stage reference was originally quoted (e.g., '@mystage')
2388    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
2389    pub quoted: bool,
2390}
2391
2392/// Historical data / Time travel (Snowflake) - BEFORE (STATEMENT => ...) or AT (TIMESTAMP => ...)
2393#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2394#[cfg_attr(feature = "bindings", derive(TS))]
2395pub struct HistoricalData {
2396    /// The time travel kind: "BEFORE", "AT", or "END" (as an Identifier expression)
2397    pub this: Box<Expression>,
2398    /// The time travel type: "STATEMENT", "TIMESTAMP", "OFFSET", "STREAM", or "VERSION"
2399    pub kind: String,
2400    /// The expression value (e.g., the statement ID or timestamp)
2401    pub expression: Box<Expression>,
2402}
2403
2404/// Represent an aliased expression (`expr AS name`).
2405///
2406/// Used for column aliases in select-lists, table aliases on subqueries,
2407/// and column alias lists on table-valued expressions (e.g. `AS t(c1, c2)`).
2408#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2409#[cfg_attr(feature = "bindings", derive(TS))]
2410pub struct Alias {
2411    /// The expression being aliased.
2412    pub this: Expression,
2413    /// The alias name (required for simple aliases, optional when only column aliases provided)
2414    pub alias: Identifier,
2415    /// Optional column aliases for table-valued functions: AS t(col1, col2) or AS (col1, col2)
2416    #[serde(default)]
2417    pub column_aliases: Vec<Identifier>,
2418    /// Comments that appeared between the expression and AS keyword
2419    #[serde(default)]
2420    pub pre_alias_comments: Vec<String>,
2421    /// Trailing comments that appeared after the alias
2422    #[serde(default)]
2423    pub trailing_comments: Vec<String>,
2424}
2425
2426impl Alias {
2427    /// Create a simple alias
2428    pub fn new(this: Expression, alias: Identifier) -> Self {
2429        Self {
2430            this,
2431            alias,
2432            column_aliases: Vec::new(),
2433            pre_alias_comments: Vec::new(),
2434            trailing_comments: Vec::new(),
2435        }
2436    }
2437
2438    /// Create an alias with column aliases only (no table alias name)
2439    pub fn with_columns(this: Expression, column_aliases: Vec<Identifier>) -> Self {
2440        Self {
2441            this,
2442            alias: Identifier::empty(),
2443            column_aliases,
2444            pre_alias_comments: Vec::new(),
2445            trailing_comments: Vec::new(),
2446        }
2447    }
2448}
2449
2450/// Represent a type cast expression.
2451///
2452/// Covers both the standard `CAST(expr AS type)` syntax and the PostgreSQL
2453/// shorthand `expr::type`. Also used as the payload for `TryCast` and
2454/// `SafeCast` variants. Supports optional FORMAT (BigQuery) and DEFAULT ON
2455/// CONVERSION ERROR (Oracle) clauses.
2456#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2457#[cfg_attr(feature = "bindings", derive(TS))]
2458pub struct Cast {
2459    /// The expression being cast.
2460    pub this: Expression,
2461    /// The target data type.
2462    pub to: DataType,
2463    #[serde(default)]
2464    pub trailing_comments: Vec<String>,
2465    /// Whether PostgreSQL `::` syntax was used (true) vs CAST() function (false)
2466    #[serde(default)]
2467    pub double_colon_syntax: bool,
2468    /// FORMAT clause for BigQuery: CAST(x AS STRING FORMAT 'format_string')
2469    #[serde(skip_serializing_if = "Option::is_none", default)]
2470    pub format: Option<Box<Expression>>,
2471    /// DEFAULT value ON CONVERSION ERROR (Oracle): CAST(x AS type DEFAULT val ON CONVERSION ERROR)
2472    #[serde(skip_serializing_if = "Option::is_none", default)]
2473    pub default: Option<Box<Expression>>,
2474}
2475
2476///// COLLATE expression: expr COLLATE 'collation_name' or expr COLLATE collation_name
2477#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2478#[cfg_attr(feature = "bindings", derive(TS))]
2479pub struct CollationExpr {
2480    pub this: Expression,
2481    pub collation: String,
2482    /// True if the collation was single-quoted in the original SQL (string literal)
2483    #[serde(default)]
2484    pub quoted: bool,
2485    /// True if the collation was double-quoted in the original SQL (identifier)
2486    #[serde(default)]
2487    pub double_quoted: bool,
2488}
2489
2490/// Represent a CASE expression (both simple and searched forms).
2491///
2492/// When `operand` is `Some`, this is a simple CASE (`CASE x WHEN 1 THEN ...`).
2493/// When `operand` is `None`, this is a searched CASE (`CASE WHEN x > 0 THEN ...`).
2494/// Each entry in `whens` is a `(condition, result)` pair.
2495#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2496#[cfg_attr(feature = "bindings", derive(TS))]
2497pub struct Case {
2498    /// The operand for simple CASE, or `None` for searched CASE.
2499    pub operand: Option<Expression>,
2500    /// Pairs of (WHEN condition, THEN result).
2501    pub whens: Vec<(Expression, Expression)>,
2502    /// Optional ELSE result.
2503    pub else_: Option<Expression>,
2504}
2505
2506/// Represent a binary operation (two operands separated by an operator).
2507///
2508/// This is the shared payload struct for all binary operator variants in the
2509/// [`Expression`] enum: arithmetic (`Add`, `Sub`, `Mul`, `Div`, `Mod`),
2510/// comparison (`Eq`, `Neq`, `Lt`, `Gt`, etc.), logical (`And`, `Or`),
2511/// bitwise, and dialect-specific operators. Comment fields enable round-trip
2512/// preservation of inline comments around operators.
2513#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2514#[cfg_attr(feature = "bindings", derive(TS))]
2515pub struct BinaryOp {
2516    pub left: Expression,
2517    pub right: Expression,
2518    /// Comments after the left operand (before the operator)
2519    #[serde(default)]
2520    pub left_comments: Vec<String>,
2521    /// Comments after the operator (before the right operand)
2522    #[serde(default)]
2523    pub operator_comments: Vec<String>,
2524    /// Comments after the right operand
2525    #[serde(default)]
2526    pub trailing_comments: Vec<String>,
2527}
2528
2529impl BinaryOp {
2530    pub fn new(left: Expression, right: Expression) -> Self {
2531        Self {
2532            left,
2533            right,
2534            left_comments: Vec::new(),
2535            operator_comments: Vec::new(),
2536            trailing_comments: Vec::new(),
2537        }
2538    }
2539}
2540
2541/// LIKE/ILIKE operation with optional ESCAPE clause and quantifier (ANY/ALL)
2542#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2543#[cfg_attr(feature = "bindings", derive(TS))]
2544pub struct LikeOp {
2545    pub left: Expression,
2546    pub right: Expression,
2547    /// ESCAPE character/expression
2548    #[serde(default)]
2549    pub escape: Option<Expression>,
2550    /// Quantifier: ANY, ALL, or SOME
2551    #[serde(default)]
2552    pub quantifier: Option<String>,
2553}
2554
2555impl LikeOp {
2556    pub fn new(left: Expression, right: Expression) -> Self {
2557        Self {
2558            left,
2559            right,
2560            escape: None,
2561            quantifier: None,
2562        }
2563    }
2564
2565    pub fn with_escape(left: Expression, right: Expression, escape: Expression) -> Self {
2566        Self {
2567            left,
2568            right,
2569            escape: Some(escape),
2570            quantifier: None,
2571        }
2572    }
2573}
2574
2575/// Represent a unary operation (single operand with a prefix operator).
2576///
2577/// Shared payload for `Not`, `Neg`, and `BitwiseNot` variants.
2578#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2579#[cfg_attr(feature = "bindings", derive(TS))]
2580pub struct UnaryOp {
2581    /// The operand expression.
2582    pub this: Expression,
2583}
2584
2585impl UnaryOp {
2586    pub fn new(this: Expression) -> Self {
2587        Self { this }
2588    }
2589}
2590
2591/// Represent an IN predicate (`x IN (1, 2, 3)` or `x IN (SELECT ...)`).
2592///
2593/// Either `expressions` (a value list) or `query` (a subquery) is populated,
2594/// but not both. When `not` is true, the predicate is `NOT IN`.
2595#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2596#[cfg_attr(feature = "bindings", derive(TS))]
2597pub struct In {
2598    /// The expression being tested.
2599    pub this: Expression,
2600    /// The value list (mutually exclusive with `query`).
2601    pub expressions: Vec<Expression>,
2602    /// A subquery (mutually exclusive with `expressions`).
2603    pub query: Option<Expression>,
2604    /// Whether this is NOT IN.
2605    pub not: bool,
2606    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
2607    pub global: bool,
2608    /// BigQuery: IN UNNEST(expr)
2609    #[serde(default, skip_serializing_if = "Option::is_none")]
2610    pub unnest: Option<Box<Expression>>,
2611}
2612
2613/// Represent a BETWEEN predicate (`x BETWEEN low AND high`).
2614#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2615#[cfg_attr(feature = "bindings", derive(TS))]
2616pub struct Between {
2617    /// The expression being tested.
2618    pub this: Expression,
2619    /// The lower bound.
2620    pub low: Expression,
2621    /// The upper bound.
2622    pub high: Expression,
2623    /// Whether this is NOT BETWEEN.
2624    pub not: bool,
2625}
2626
2627/// IS NULL predicate
2628#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2629#[cfg_attr(feature = "bindings", derive(TS))]
2630pub struct IsNull {
2631    pub this: Expression,
2632    pub not: bool,
2633    /// Whether this was the postfix form (ISNULL/NOTNULL) vs standard (IS NULL/IS NOT NULL)
2634    #[serde(default)]
2635    pub postfix_form: bool,
2636}
2637
2638/// IS TRUE / IS FALSE predicate
2639#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2640#[cfg_attr(feature = "bindings", derive(TS))]
2641pub struct IsTrueFalse {
2642    pub this: Expression,
2643    pub not: bool,
2644}
2645
2646/// IS JSON predicate (SQL standard)
2647/// Checks if a value is valid JSON
2648#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2649#[cfg_attr(feature = "bindings", derive(TS))]
2650pub struct IsJson {
2651    pub this: Expression,
2652    /// JSON type: VALUE, SCALAR, OBJECT, or ARRAY (None = just IS JSON)
2653    pub json_type: Option<String>,
2654    /// Key uniqueness constraint
2655    pub unique_keys: Option<JsonUniqueKeys>,
2656    /// Whether IS NOT JSON
2657    pub negated: bool,
2658}
2659
2660/// JSON unique keys constraint variants
2661#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2662#[cfg_attr(feature = "bindings", derive(TS))]
2663pub enum JsonUniqueKeys {
2664    /// WITH UNIQUE KEYS
2665    With,
2666    /// WITHOUT UNIQUE KEYS
2667    Without,
2668    /// UNIQUE KEYS (shorthand for WITH UNIQUE KEYS)
2669    Shorthand,
2670}
2671
2672/// Represent an EXISTS predicate (`EXISTS (SELECT ...)` or `NOT EXISTS (...)`).
2673#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2674#[cfg_attr(feature = "bindings", derive(TS))]
2675pub struct Exists {
2676    /// The subquery expression.
2677    pub this: Expression,
2678    /// Whether this is NOT EXISTS.
2679    pub not: bool,
2680}
2681
2682/// Represent a scalar function call (e.g. `UPPER(name)`, `COALESCE(a, b)`).
2683///
2684/// This is the generic function node. Well-known aggregates, window functions,
2685/// and built-in functions each have their own dedicated `Expression` variants
2686/// (e.g. `Count`, `Sum`, `WindowFunction`). Functions that the parser does
2687/// not recognize as built-ins are represented with this struct.
2688#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2689#[cfg_attr(feature = "bindings", derive(TS))]
2690pub struct Function {
2691    /// The function name, as originally written (may be schema-qualified).
2692    pub name: String,
2693    /// Positional arguments to the function.
2694    pub args: Vec<Expression>,
2695    /// Whether DISTINCT was specified inside the call (e.g. `COUNT(DISTINCT x)`).
2696    pub distinct: bool,
2697    #[serde(default)]
2698    pub trailing_comments: Vec<String>,
2699    /// Whether this function uses bracket syntax (e.g., MAP[keys, values])
2700    #[serde(default)]
2701    pub use_bracket_syntax: bool,
2702    /// Whether this function was called without parentheses (e.g., CURRENT_TIMESTAMP vs CURRENT_TIMESTAMP())
2703    #[serde(default)]
2704    pub no_parens: bool,
2705    /// Whether the function name was quoted (e.g., `p.d.UdF` in BigQuery)
2706    #[serde(default)]
2707    pub quoted: bool,
2708}
2709
2710impl Default for Function {
2711    fn default() -> Self {
2712        Self {
2713            name: String::new(),
2714            args: Vec::new(),
2715            distinct: false,
2716            trailing_comments: Vec::new(),
2717            use_bracket_syntax: false,
2718            no_parens: false,
2719            quoted: false,
2720        }
2721    }
2722}
2723
2724impl Function {
2725    pub fn new(name: impl Into<String>, args: Vec<Expression>) -> Self {
2726        Self {
2727            name: name.into(),
2728            args,
2729            distinct: false,
2730            trailing_comments: Vec::new(),
2731            use_bracket_syntax: false,
2732            no_parens: false,
2733            quoted: false,
2734        }
2735    }
2736}
2737
2738/// Represent a named aggregate function call with optional FILTER, ORDER BY, and LIMIT.
2739///
2740/// This struct is used for aggregate function calls that are not covered by
2741/// one of the dedicated typed variants (e.g. `Count`, `Sum`). It supports
2742/// SQL:2003 FILTER (WHERE ...) clauses, ordered-set aggregates, and
2743/// IGNORE NULLS / RESPECT NULLS modifiers.
2744#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
2745#[cfg_attr(feature = "bindings", derive(TS))]
2746pub struct AggregateFunction {
2747    /// The aggregate function name (e.g. "JSON_AGG", "XMLAGG").
2748    pub name: String,
2749    /// Positional arguments.
2750    pub args: Vec<Expression>,
2751    /// Whether DISTINCT was specified.
2752    pub distinct: bool,
2753    /// Optional FILTER (WHERE ...) clause applied to the aggregate.
2754    pub filter: Option<Expression>,
2755    /// ORDER BY inside aggregate (e.g., JSON_AGG(x ORDER BY y))
2756    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2757    pub order_by: Vec<Ordered>,
2758    /// LIMIT inside aggregate (e.g., ARRAY_CONCAT_AGG(x LIMIT 2))
2759    #[serde(default, skip_serializing_if = "Option::is_none")]
2760    pub limit: Option<Box<Expression>>,
2761    /// IGNORE NULLS / RESPECT NULLS
2762    #[serde(default, skip_serializing_if = "Option::is_none")]
2763    pub ignore_nulls: Option<bool>,
2764}
2765
2766/// Represent a window function call with its OVER clause.
2767///
2768/// The inner `this` expression is typically a window-specific expression
2769/// (e.g. `RowNumber`, `Rank`, `Lead`) or an aggregate used as a window
2770/// function.  The `over` field carries the PARTITION BY, ORDER BY, and
2771/// frame specification.
2772#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2773#[cfg_attr(feature = "bindings", derive(TS))]
2774pub struct WindowFunction {
2775    /// The function expression (e.g. ROW_NUMBER(), SUM(amount)).
2776    pub this: Expression,
2777    /// The OVER clause defining the window partitioning, ordering, and frame.
2778    pub over: Over,
2779    /// Oracle KEEP clause: KEEP (DENSE_RANK FIRST|LAST ORDER BY ...)
2780    #[serde(default, skip_serializing_if = "Option::is_none")]
2781    pub keep: Option<Keep>,
2782}
2783
2784/// Oracle KEEP clause for aggregate functions
2785/// Syntax: aggregate_function KEEP (DENSE_RANK FIRST|LAST ORDER BY column [ASC|DESC])
2786#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2787#[cfg_attr(feature = "bindings", derive(TS))]
2788pub struct Keep {
2789    /// true = FIRST, false = LAST
2790    pub first: bool,
2791    /// ORDER BY clause inside KEEP
2792    pub order_by: Vec<Ordered>,
2793}
2794
2795/// WITHIN GROUP clause (for ordered-set aggregate functions)
2796#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2797#[cfg_attr(feature = "bindings", derive(TS))]
2798pub struct WithinGroup {
2799    /// The aggregate function (LISTAGG, PERCENTILE_CONT, etc.)
2800    pub this: Expression,
2801    /// The ORDER BY clause within the group
2802    pub order_by: Vec<Ordered>,
2803}
2804
2805/// Represent the FROM clause of a SELECT statement.
2806///
2807/// Contains one or more table sources (tables, subqueries, table-valued
2808/// functions, etc.). Multiple entries represent comma-separated implicit joins.
2809#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2810#[cfg_attr(feature = "bindings", derive(TS))]
2811pub struct From {
2812    /// The table source expressions.
2813    pub expressions: Vec<Expression>,
2814}
2815
2816/// Represent a JOIN clause between two table sources.
2817///
2818/// The join condition can be specified via `on` (ON predicate) or `using`
2819/// (USING column list), but not both. The `kind` field determines the join
2820/// type (INNER, LEFT, CROSS, etc.).
2821#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2822#[cfg_attr(feature = "bindings", derive(TS))]
2823pub struct Join {
2824    /// The right-hand table expression being joined.
2825    pub this: Expression,
2826    /// The ON condition (mutually exclusive with `using`).
2827    pub on: Option<Expression>,
2828    /// The USING column list (mutually exclusive with `on`).
2829    pub using: Vec<Identifier>,
2830    /// The join type (INNER, LEFT, RIGHT, FULL, CROSS, etc.).
2831    pub kind: JoinKind,
2832    /// Whether INNER keyword was explicitly used (INNER JOIN vs JOIN)
2833    pub use_inner_keyword: bool,
2834    /// Whether OUTER keyword was explicitly used (LEFT OUTER JOIN vs LEFT JOIN)
2835    pub use_outer_keyword: bool,
2836    /// Whether the ON/USING condition was deferred (assigned right-to-left for chained JOINs)
2837    pub deferred_condition: bool,
2838    /// TSQL join hint: LOOP, HASH, MERGE (e.g., INNER LOOP JOIN)
2839    #[serde(default, skip_serializing_if = "Option::is_none")]
2840    pub join_hint: Option<String>,
2841    /// Snowflake ASOF JOIN match condition (MATCH_CONDITION clause)
2842    #[serde(default, skip_serializing_if = "Option::is_none")]
2843    pub match_condition: Option<Expression>,
2844    /// PIVOT/UNPIVOT operations that follow this join (Oracle/TSQL syntax)
2845    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2846    pub pivots: Vec<Expression>,
2847}
2848
2849/// Enumerate all supported SQL join types.
2850///
2851/// Covers the standard join types (INNER, LEFT, RIGHT, FULL, CROSS, NATURAL)
2852/// as well as dialect-specific variants: SEMI/ANTI joins, LATERAL joins,
2853/// CROSS/OUTER APPLY (TSQL), ASOF joins (DuckDB/Snowflake), ARRAY joins
2854/// (ClickHouse), STRAIGHT_JOIN (MySQL), and implicit comma-joins.
2855#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2856#[cfg_attr(feature = "bindings", derive(TS))]
2857pub enum JoinKind {
2858    Inner,
2859    Left,
2860    Right,
2861    Full,
2862    Outer,  // Standalone OUTER JOIN (without LEFT/RIGHT/FULL)
2863    Cross,
2864    Natural,
2865    NaturalLeft,
2866    NaturalRight,
2867    NaturalFull,
2868    Semi,
2869    Anti,
2870    // Directional SEMI/ANTI joins
2871    LeftSemi,
2872    LeftAnti,
2873    RightSemi,
2874    RightAnti,
2875    // SQL Server specific
2876    CrossApply,
2877    OuterApply,
2878    // Time-series specific
2879    AsOf,
2880    AsOfLeft,
2881    AsOfRight,
2882    // Lateral join
2883    Lateral,
2884    LeftLateral,
2885    // MySQL specific
2886    Straight,
2887    // Implicit join (comma-separated tables: FROM a, b)
2888    Implicit,
2889    // ClickHouse ARRAY JOIN
2890    Array,
2891    LeftArray,
2892}
2893
2894impl Default for JoinKind {
2895    fn default() -> Self {
2896        JoinKind::Inner
2897    }
2898}
2899
2900/// Parenthesized table expression with joins
2901/// Represents: (tbl1 CROSS JOIN tbl2) or ((SELECT 1) CROSS JOIN (SELECT 2))
2902#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2903#[cfg_attr(feature = "bindings", derive(TS))]
2904pub struct JoinedTable {
2905    /// The left-hand side table expression
2906    pub left: Expression,
2907    /// The joins applied to the left table
2908    pub joins: Vec<Join>,
2909    /// LATERAL VIEW clauses (Hive/Spark)
2910    pub lateral_views: Vec<LateralView>,
2911    /// Optional alias for the joined table expression
2912    pub alias: Option<Identifier>,
2913}
2914
2915/// Represent a WHERE clause containing a boolean filter predicate.
2916#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2917#[cfg_attr(feature = "bindings", derive(TS))]
2918pub struct Where {
2919    /// The filter predicate expression.
2920    pub this: Expression,
2921}
2922
2923/// Represent a GROUP BY clause with optional ALL/DISTINCT and WITH TOTALS modifiers.
2924///
2925/// The `expressions` list may contain plain columns, ordinal positions,
2926/// ROLLUP/CUBE/GROUPING SETS expressions, or the special empty-set `()`.
2927#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2928#[cfg_attr(feature = "bindings", derive(TS))]
2929pub struct GroupBy {
2930    /// The grouping expressions.
2931    pub expressions: Vec<Expression>,
2932    /// GROUP BY modifier: Some(true) = ALL, Some(false) = DISTINCT, None = no modifier
2933    #[serde(default)]
2934    pub all: Option<bool>,
2935    /// ClickHouse: WITH TOTALS modifier
2936    #[serde(default)]
2937    pub totals: bool,
2938}
2939
2940/// Represent a HAVING clause containing a predicate over aggregate results.
2941#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2942#[cfg_attr(feature = "bindings", derive(TS))]
2943pub struct Having {
2944    /// The filter predicate, typically involving aggregate functions.
2945    pub this: Expression,
2946}
2947
2948/// Represent an ORDER BY clause containing one or more sort specifications.
2949#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2950#[cfg_attr(feature = "bindings", derive(TS))]
2951pub struct OrderBy {
2952    /// The sort specifications, each with direction and null ordering.
2953    pub expressions: Vec<Ordered>,
2954    /// Whether this is ORDER SIBLINGS BY (Oracle hierarchical queries)
2955    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
2956    pub siblings: bool,
2957}
2958
2959/// Represent an expression with sort direction and null ordering.
2960///
2961/// Used inside ORDER BY clauses, window frame ORDER BY, and index definitions.
2962/// When `desc` is false the sort is ascending. The `nulls_first` field
2963/// controls the NULLS FIRST / NULLS LAST modifier; `None` means unspecified
2964/// (database default).
2965#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2966#[cfg_attr(feature = "bindings", derive(TS))]
2967pub struct Ordered {
2968    /// The expression to sort by.
2969    pub this: Expression,
2970    /// Whether the sort direction is descending (true) or ascending (false).
2971    pub desc: bool,
2972    /// `Some(true)` = NULLS FIRST, `Some(false)` = NULLS LAST, `None` = unspecified.
2973    pub nulls_first: Option<bool>,
2974    /// Whether ASC was explicitly written (not just implied)
2975    #[serde(default)]
2976    pub explicit_asc: bool,
2977    /// ClickHouse WITH FILL clause
2978    #[serde(default, skip_serializing_if = "Option::is_none")]
2979    pub with_fill: Option<Box<WithFill>>,
2980}
2981
2982impl Ordered {
2983    pub fn asc(expr: Expression) -> Self {
2984        Self {
2985            this: expr,
2986            desc: false,
2987            nulls_first: None,
2988            explicit_asc: false,
2989            with_fill: None,
2990        }
2991    }
2992
2993    pub fn desc(expr: Expression) -> Self {
2994        Self {
2995            this: expr,
2996            desc: true,
2997            nulls_first: None,
2998            explicit_asc: false,
2999            with_fill: None,
3000        }
3001    }
3002}
3003
3004/// DISTRIBUTE BY clause (Hive/Spark)
3005/// Controls how rows are distributed across reducers
3006#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3007#[cfg_attr(feature = "bindings", derive(TS))]
3008#[cfg_attr(feature = "bindings", ts(export))]
3009pub struct DistributeBy {
3010    pub expressions: Vec<Expression>,
3011}
3012
3013/// CLUSTER BY clause (Hive/Spark)
3014/// Combines DISTRIBUTE BY and SORT BY on the same columns
3015#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3016#[cfg_attr(feature = "bindings", derive(TS))]
3017#[cfg_attr(feature = "bindings", ts(export))]
3018pub struct ClusterBy {
3019    pub expressions: Vec<Ordered>,
3020}
3021
3022/// SORT BY clause (Hive/Spark)
3023/// Sorts data within each reducer (local sort, not global)
3024#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3025#[cfg_attr(feature = "bindings", derive(TS))]
3026#[cfg_attr(feature = "bindings", ts(export))]
3027pub struct SortBy {
3028    pub expressions: Vec<Ordered>,
3029}
3030
3031/// LATERAL VIEW clause (Hive/Spark)
3032/// Used for unnesting arrays/maps with EXPLODE, POSEXPLODE, etc.
3033#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3034#[cfg_attr(feature = "bindings", derive(TS))]
3035#[cfg_attr(feature = "bindings", ts(export))]
3036pub struct LateralView {
3037    /// The table-generating function (EXPLODE, POSEXPLODE, etc.)
3038    pub this: Expression,
3039    /// Table alias for the generated table
3040    pub table_alias: Option<Identifier>,
3041    /// Column aliases for the generated columns
3042    pub column_aliases: Vec<Identifier>,
3043    /// OUTER keyword - preserve nulls when input is empty/null
3044    pub outer: bool,
3045}
3046
3047/// Query hint
3048#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3049#[cfg_attr(feature = "bindings", derive(TS))]
3050#[cfg_attr(feature = "bindings", ts(export))]
3051pub struct Hint {
3052    pub expressions: Vec<HintExpression>,
3053}
3054
3055/// Individual hint expression
3056#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3057#[cfg_attr(feature = "bindings", derive(TS))]
3058#[cfg_attr(feature = "bindings", ts(export))]
3059pub enum HintExpression {
3060    /// Function-style hint: USE_HASH(table)
3061    Function { name: String, args: Vec<Expression> },
3062    /// Simple identifier hint: PARALLEL
3063    Identifier(String),
3064    /// Raw hint text (unparsed)
3065    Raw(String),
3066}
3067
3068/// Pseudocolumn type
3069#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
3070#[cfg_attr(feature = "bindings", derive(TS))]
3071#[cfg_attr(feature = "bindings", ts(export))]
3072pub enum PseudocolumnType {
3073    Rownum,      // Oracle ROWNUM
3074    Rowid,       // Oracle ROWID
3075    Level,       // Oracle LEVEL (for CONNECT BY)
3076    Sysdate,     // Oracle SYSDATE
3077    ObjectId,    // Oracle OBJECT_ID
3078    ObjectValue, // Oracle OBJECT_VALUE
3079}
3080
3081impl PseudocolumnType {
3082    pub fn as_str(&self) -> &'static str {
3083        match self {
3084            PseudocolumnType::Rownum => "ROWNUM",
3085            PseudocolumnType::Rowid => "ROWID",
3086            PseudocolumnType::Level => "LEVEL",
3087            PseudocolumnType::Sysdate => "SYSDATE",
3088            PseudocolumnType::ObjectId => "OBJECT_ID",
3089            PseudocolumnType::ObjectValue => "OBJECT_VALUE",
3090        }
3091    }
3092
3093    pub fn from_str(s: &str) -> Option<Self> {
3094        match s.to_uppercase().as_str() {
3095            "ROWNUM" => Some(PseudocolumnType::Rownum),
3096            "ROWID" => Some(PseudocolumnType::Rowid),
3097            "LEVEL" => Some(PseudocolumnType::Level),
3098            "SYSDATE" => Some(PseudocolumnType::Sysdate),
3099            "OBJECT_ID" => Some(PseudocolumnType::ObjectId),
3100            "OBJECT_VALUE" => Some(PseudocolumnType::ObjectValue),
3101            _ => None,
3102        }
3103    }
3104}
3105
3106/// Pseudocolumn expression (Oracle ROWNUM, ROWID, LEVEL, etc.)
3107/// These are special identifiers that should not be quoted
3108#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3109#[cfg_attr(feature = "bindings", derive(TS))]
3110#[cfg_attr(feature = "bindings", ts(export))]
3111pub struct Pseudocolumn {
3112    pub kind: PseudocolumnType,
3113}
3114
3115impl Pseudocolumn {
3116    pub fn rownum() -> Self {
3117        Self { kind: PseudocolumnType::Rownum }
3118    }
3119
3120    pub fn rowid() -> Self {
3121        Self { kind: PseudocolumnType::Rowid }
3122    }
3123
3124    pub fn level() -> Self {
3125        Self { kind: PseudocolumnType::Level }
3126    }
3127}
3128
3129/// Oracle CONNECT BY clause for hierarchical queries
3130#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3131#[cfg_attr(feature = "bindings", derive(TS))]
3132#[cfg_attr(feature = "bindings", ts(export))]
3133pub struct Connect {
3134    /// START WITH condition (optional, can come before or after CONNECT BY)
3135    pub start: Option<Expression>,
3136    /// CONNECT BY condition (required, contains PRIOR references)
3137    pub connect: Expression,
3138    /// NOCYCLE keyword to prevent infinite loops
3139    pub nocycle: bool,
3140}
3141
3142/// Oracle PRIOR expression - references parent row's value in CONNECT BY
3143#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3144#[cfg_attr(feature = "bindings", derive(TS))]
3145#[cfg_attr(feature = "bindings", ts(export))]
3146pub struct Prior {
3147    pub this: Expression,
3148}
3149
3150/// Oracle CONNECT_BY_ROOT function - returns root row's column value
3151#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3152#[cfg_attr(feature = "bindings", derive(TS))]
3153#[cfg_attr(feature = "bindings", ts(export))]
3154pub struct ConnectByRoot {
3155    pub this: Expression,
3156}
3157
3158/// MATCH_RECOGNIZE clause for row pattern matching (Oracle/Snowflake/Presto/Trino)
3159#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3160#[cfg_attr(feature = "bindings", derive(TS))]
3161#[cfg_attr(feature = "bindings", ts(export))]
3162pub struct MatchRecognize {
3163    /// Source table/expression
3164    pub this: Option<Box<Expression>>,
3165    /// PARTITION BY expressions
3166    pub partition_by: Option<Vec<Expression>>,
3167    /// ORDER BY expressions
3168    pub order_by: Option<Vec<Ordered>>,
3169    /// MEASURES definitions
3170    pub measures: Option<Vec<MatchRecognizeMeasure>>,
3171    /// Row semantics (ONE ROW PER MATCH, ALL ROWS PER MATCH, etc.)
3172    pub rows: Option<MatchRecognizeRows>,
3173    /// AFTER MATCH SKIP behavior
3174    pub after: Option<MatchRecognizeAfter>,
3175    /// PATTERN definition (stored as raw string for complex regex patterns)
3176    pub pattern: Option<String>,
3177    /// DEFINE clauses (pattern variable definitions)
3178    pub define: Option<Vec<(Identifier, Expression)>>,
3179    /// Optional alias for the result
3180    pub alias: Option<Identifier>,
3181    /// Whether AS keyword was explicitly present before alias
3182    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
3183    pub alias_explicit_as: bool,
3184}
3185
3186/// MEASURES expression with optional RUNNING/FINAL semantics
3187#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3188#[cfg_attr(feature = "bindings", derive(TS))]
3189#[cfg_attr(feature = "bindings", ts(export))]
3190pub struct MatchRecognizeMeasure {
3191    /// The measure expression
3192    pub this: Expression,
3193    /// RUNNING or FINAL semantics (Snowflake-specific)
3194    pub window_frame: Option<MatchRecognizeSemantics>,
3195}
3196
3197/// Semantics for MEASURES in MATCH_RECOGNIZE
3198#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
3199#[cfg_attr(feature = "bindings", derive(TS))]
3200#[cfg_attr(feature = "bindings", ts(export))]
3201pub enum MatchRecognizeSemantics {
3202    Running,
3203    Final,
3204}
3205
3206/// Row output semantics for MATCH_RECOGNIZE
3207#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
3208#[cfg_attr(feature = "bindings", derive(TS))]
3209#[cfg_attr(feature = "bindings", ts(export))]
3210pub enum MatchRecognizeRows {
3211    OneRowPerMatch,
3212    AllRowsPerMatch,
3213    AllRowsPerMatchShowEmptyMatches,
3214    AllRowsPerMatchOmitEmptyMatches,
3215    AllRowsPerMatchWithUnmatchedRows,
3216}
3217
3218/// AFTER MATCH SKIP behavior
3219#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3220#[cfg_attr(feature = "bindings", derive(TS))]
3221#[cfg_attr(feature = "bindings", ts(export))]
3222pub enum MatchRecognizeAfter {
3223    PastLastRow,
3224    ToNextRow,
3225    ToFirst(Identifier),
3226    ToLast(Identifier),
3227}
3228
3229/// Represent a LIMIT clause that restricts the number of returned rows.
3230#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3231#[cfg_attr(feature = "bindings", derive(TS))]
3232pub struct Limit {
3233    /// The limit count expression.
3234    pub this: Expression,
3235    /// Whether PERCENT modifier is present (DuckDB: LIMIT 10 PERCENT)
3236    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
3237    pub percent: bool,
3238}
3239
3240/// OFFSET clause
3241#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3242#[cfg_attr(feature = "bindings", derive(TS))]
3243pub struct Offset {
3244    pub this: Expression,
3245    /// Whether ROW/ROWS keyword was used (SQL standard syntax)
3246    #[serde(skip_serializing_if = "Option::is_none", default)]
3247    pub rows: Option<bool>,
3248}
3249
3250/// TOP clause (SQL Server)
3251#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3252#[cfg_attr(feature = "bindings", derive(TS))]
3253pub struct Top {
3254    pub this: Expression,
3255    pub percent: bool,
3256    pub with_ties: bool,
3257    /// Whether the expression was parenthesized: TOP (10) vs TOP 10
3258    #[serde(default)]
3259    pub parenthesized: bool,
3260}
3261
3262/// FETCH FIRST/NEXT clause (SQL standard)
3263#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3264#[cfg_attr(feature = "bindings", derive(TS))]
3265pub struct Fetch {
3266    /// FIRST or NEXT
3267    pub direction: String,
3268    /// Count expression (optional)
3269    pub count: Option<Expression>,
3270    /// PERCENT modifier
3271    pub percent: bool,
3272    /// ROWS or ROW keyword present
3273    pub rows: bool,
3274    /// WITH TIES modifier
3275    pub with_ties: bool,
3276}
3277
3278/// Represent a QUALIFY clause for filtering on window function results.
3279///
3280/// Supported by Snowflake, BigQuery, DuckDB, and Databricks. The predicate
3281/// typically references a window function (e.g.
3282/// `QUALIFY ROW_NUMBER() OVER (PARTITION BY id ORDER BY ts DESC) = 1`).
3283#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3284#[cfg_attr(feature = "bindings", derive(TS))]
3285pub struct Qualify {
3286    /// The filter predicate over window function results.
3287    pub this: Expression,
3288}
3289
3290/// SAMPLE / TABLESAMPLE clause
3291#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3292#[cfg_attr(feature = "bindings", derive(TS))]
3293pub struct Sample {
3294    pub method: SampleMethod,
3295    pub size: Expression,
3296    pub seed: Option<Expression>,
3297    /// ClickHouse OFFSET expression after SAMPLE size
3298    #[serde(default)]
3299    pub offset: Option<Expression>,
3300    /// Whether the unit comes after the size (e.g., "100 ROWS" vs "ROW 100")
3301    pub unit_after_size: bool,
3302    /// Whether the keyword was SAMPLE (true) or TABLESAMPLE (false)
3303    #[serde(default)]
3304    pub use_sample_keyword: bool,
3305    /// Whether the method was explicitly specified (BERNOULLI, SYSTEM, etc.)
3306    #[serde(default)]
3307    pub explicit_method: bool,
3308    /// Whether the method keyword appeared before the size (TABLESAMPLE BERNOULLI (10))
3309    #[serde(default)]
3310    pub method_before_size: bool,
3311    /// Whether SEED keyword was used (true) or REPEATABLE (false)
3312    #[serde(default)]
3313    pub use_seed_keyword: bool,
3314    /// BUCKET numerator for Hive bucket sampling (BUCKET 1 OUT OF 5)
3315    pub bucket_numerator: Option<Box<Expression>>,
3316    /// BUCKET denominator (the 5 in BUCKET 1 OUT OF 5)
3317    pub bucket_denominator: Option<Box<Expression>>,
3318    /// BUCKET field for ON clause (BUCKET 1 OUT OF 5 ON x)
3319    pub bucket_field: Option<Box<Expression>>,
3320    /// Whether this is a DuckDB USING SAMPLE clause (vs SAMPLE/TABLESAMPLE)
3321    #[serde(default)]
3322    pub is_using_sample: bool,
3323    /// Whether the unit was explicitly PERCENT (vs ROWS)
3324    #[serde(default)]
3325    pub is_percent: bool,
3326    /// Whether to suppress method output (for cross-dialect transpilation)
3327    #[serde(default)]
3328    pub suppress_method_output: bool,
3329}
3330
3331/// Sample method
3332#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
3333#[cfg_attr(feature = "bindings", derive(TS))]
3334pub enum SampleMethod {
3335    Bernoulli,
3336    System,
3337    Block,
3338    Row,
3339    Percent,
3340    /// Hive bucket sampling
3341    Bucket,
3342    /// DuckDB reservoir sampling
3343    Reservoir,
3344}
3345
3346/// Named window definition (WINDOW w AS (...))
3347#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3348#[cfg_attr(feature = "bindings", derive(TS))]
3349pub struct NamedWindow {
3350    pub name: Identifier,
3351    pub spec: Over,
3352}
3353
3354/// Represent a WITH clause containing one or more Common Table Expressions (CTEs).
3355///
3356/// When `recursive` is true, the clause is `WITH RECURSIVE`, enabling CTEs
3357/// that reference themselves. Each CTE is defined in the `ctes` vector and
3358/// can be referenced by name in subsequent CTEs and in the main query body.
3359#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3360#[cfg_attr(feature = "bindings", derive(TS))]
3361pub struct With {
3362    /// The list of CTE definitions, in order.
3363    pub ctes: Vec<Cte>,
3364    /// Whether the WITH RECURSIVE keyword was used.
3365    pub recursive: bool,
3366    /// Leading comments before the statement
3367    #[serde(default)]
3368    pub leading_comments: Vec<String>,
3369    /// SEARCH/CYCLE clause for recursive CTEs (PostgreSQL)
3370    #[serde(default, skip_serializing_if = "Option::is_none")]
3371    pub search: Option<Box<Expression>>,
3372}
3373
3374/// Represent a single Common Table Expression definition.
3375///
3376/// A CTE has a name (`alias`), an optional column list, and a body query.
3377/// The `materialized` field maps to PostgreSQL's `MATERIALIZED` /
3378/// `NOT MATERIALIZED` hints. ClickHouse supports an inverted syntax where
3379/// the expression comes before the alias (`alias_first`).
3380#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3381#[cfg_attr(feature = "bindings", derive(TS))]
3382pub struct Cte {
3383    /// The CTE name.
3384    pub alias: Identifier,
3385    /// The CTE body (typically a SELECT, UNION, etc.).
3386    pub this: Expression,
3387    /// Optional column alias list: `cte_name(c1, c2) AS (...)`.
3388    pub columns: Vec<Identifier>,
3389    /// `Some(true)` = MATERIALIZED, `Some(false)` = NOT MATERIALIZED, `None` = unspecified.
3390    pub materialized: Option<bool>,
3391    /// USING KEY (columns) for DuckDB recursive CTEs
3392    #[serde(default, skip_serializing_if = "Vec::is_empty")]
3393    pub key_expressions: Vec<Identifier>,
3394    /// ClickHouse supports expression-first WITH items: WITH <expr> AS <alias>
3395    #[serde(default)]
3396    pub alias_first: bool,
3397}
3398
3399/// Window specification
3400#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3401#[cfg_attr(feature = "bindings", derive(TS))]
3402pub struct WindowSpec {
3403    pub partition_by: Vec<Expression>,
3404    pub order_by: Vec<Ordered>,
3405    pub frame: Option<WindowFrame>,
3406}
3407
3408/// OVER clause
3409#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3410#[cfg_attr(feature = "bindings", derive(TS))]
3411pub struct Over {
3412    /// Named window reference (e.g., OVER w or OVER (w ORDER BY x))
3413    pub window_name: Option<Identifier>,
3414    pub partition_by: Vec<Expression>,
3415    pub order_by: Vec<Ordered>,
3416    pub frame: Option<WindowFrame>,
3417    pub alias: Option<Identifier>,
3418}
3419
3420/// Window frame
3421#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3422#[cfg_attr(feature = "bindings", derive(TS))]
3423pub struct WindowFrame {
3424    pub kind: WindowFrameKind,
3425    pub start: WindowFrameBound,
3426    pub end: Option<WindowFrameBound>,
3427    pub exclude: Option<WindowFrameExclude>,
3428    /// Original text of the frame kind keyword (preserves input case, e.g. "range")
3429    #[serde(default, skip_serializing_if = "Option::is_none")]
3430    pub kind_text: Option<String>,
3431    /// Original text of the start bound side keyword (e.g. "preceding")
3432    #[serde(default, skip_serializing_if = "Option::is_none")]
3433    pub start_side_text: Option<String>,
3434    /// Original text of the end bound side keyword
3435    #[serde(default, skip_serializing_if = "Option::is_none")]
3436    pub end_side_text: Option<String>,
3437}
3438
3439#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
3440#[cfg_attr(feature = "bindings", derive(TS))]
3441pub enum WindowFrameKind {
3442    Rows,
3443    Range,
3444    Groups,
3445}
3446
3447/// EXCLUDE clause for window frames
3448#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
3449#[cfg_attr(feature = "bindings", derive(TS))]
3450pub enum WindowFrameExclude {
3451    CurrentRow,
3452    Group,
3453    Ties,
3454    NoOthers,
3455}
3456
3457#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3458#[cfg_attr(feature = "bindings", derive(TS))]
3459pub enum WindowFrameBound {
3460    CurrentRow,
3461    UnboundedPreceding,
3462    UnboundedFollowing,
3463    Preceding(Box<Expression>),
3464    Following(Box<Expression>),
3465    /// Bare PRECEDING without value (inverted syntax: just "PRECEDING")
3466    BarePreceding,
3467    /// Bare FOLLOWING without value (inverted syntax: just "FOLLOWING")
3468    BareFollowing,
3469    /// Bare numeric bound without PRECEDING/FOLLOWING (e.g., RANGE BETWEEN 1 AND 3)
3470    Value(Box<Expression>),
3471}
3472
3473/// Struct field with optional OPTIONS clause (BigQuery) and COMMENT (Spark/Databricks)
3474#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3475#[cfg_attr(feature = "bindings", derive(TS))]
3476pub struct StructField {
3477    pub name: String,
3478    pub data_type: DataType,
3479    #[serde(default, skip_serializing_if = "Vec::is_empty")]
3480    pub options: Vec<Expression>,
3481    #[serde(default, skip_serializing_if = "Option::is_none")]
3482    pub comment: Option<String>,
3483}
3484
3485impl StructField {
3486    /// Create a new struct field without options
3487    pub fn new(name: String, data_type: DataType) -> Self {
3488        Self { name, data_type, options: Vec::new(), comment: None }
3489    }
3490
3491    /// Create a new struct field with options
3492    pub fn with_options(name: String, data_type: DataType, options: Vec<Expression>) -> Self {
3493        Self { name, data_type, options, comment: None }
3494    }
3495
3496    /// Create a new struct field with options and comment
3497    pub fn with_options_and_comment(name: String, data_type: DataType, options: Vec<Expression>, comment: Option<String>) -> Self {
3498        Self { name, data_type, options, comment }
3499    }
3500}
3501
3502/// Enumerate all SQL data types recognized by the parser.
3503///
3504/// Covers standard SQL types (BOOLEAN, INT, VARCHAR, TIMESTAMP, etc.) as well
3505/// as dialect-specific types (JSONB, VECTOR, OBJECT, etc.). Parametric types
3506/// like ARRAY, MAP, and STRUCT are represented with nested [`DataType`] fields.
3507///
3508/// This enum is used in CAST expressions, column definitions, function return
3509/// types, and anywhere a data type specification appears in SQL.
3510///
3511/// Types that do not match any known variant fall through to `Custom { name }`,
3512/// preserving the original type name for round-trip fidelity.
3513#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3514#[cfg_attr(feature = "bindings", derive(TS))]
3515#[serde(tag = "data_type", rename_all = "snake_case")]
3516pub enum DataType {
3517    // Numeric
3518    Boolean,
3519    TinyInt { length: Option<u32> },
3520    SmallInt { length: Option<u32> },
3521    /// Int type with optional length. `integer_spelling` indicates whether the original
3522    /// type was spelled as `INTEGER` (true) vs `INT` (false), used for certain dialects
3523    /// like Databricks that preserve the original spelling in specific contexts (e.g., ?:: syntax).
3524    Int { length: Option<u32>, #[serde(default, skip_serializing_if = "std::ops::Not::not")] integer_spelling: bool },
3525    BigInt { length: Option<u32> },
3526    /// Float type with optional precision and scale. `real_spelling` indicates whether the original
3527    /// type was spelled as `REAL` (true) vs `FLOAT` (false), used for dialects like Redshift that
3528    /// preserve the original spelling.
3529    Float { precision: Option<u32>, scale: Option<u32>, #[serde(default, skip_serializing_if = "std::ops::Not::not")] real_spelling: bool },
3530    Double { precision: Option<u32>, scale: Option<u32> },
3531    Decimal { precision: Option<u32>, scale: Option<u32> },
3532
3533    // String
3534    Char { length: Option<u32> },
3535    /// VarChar type with optional length. `parenthesized_length` indicates whether the length
3536    /// was wrapped in extra parentheses (Hive: `VARCHAR((50))` inside STRUCT definitions).
3537    VarChar { length: Option<u32>, #[serde(default, skip_serializing_if = "std::ops::Not::not")] parenthesized_length: bool },
3538    /// String type with optional max length (BigQuery STRING(n))
3539    String { length: Option<u32> },
3540    Text,
3541
3542    // Binary
3543    Binary { length: Option<u32> },
3544    VarBinary { length: Option<u32> },
3545    Blob,
3546
3547    // Bit
3548    Bit { length: Option<u32> },
3549    VarBit { length: Option<u32> },
3550
3551    // Date/Time
3552    Date,
3553    Time { precision: Option<u32>, #[serde(default)] timezone: bool },
3554    Timestamp { precision: Option<u32>, timezone: bool },
3555    Interval {
3556        unit: Option<String>,
3557        /// For range intervals like INTERVAL DAY TO HOUR
3558        #[serde(default, skip_serializing_if = "Option::is_none")]
3559        to: Option<String>,
3560    },
3561
3562    // JSON
3563    Json,
3564    JsonB,
3565
3566    // UUID
3567    Uuid,
3568
3569    // Array
3570    Array {
3571        element_type: Box<DataType>,
3572        /// Optional dimension size for PostgreSQL (e.g., [3] in INT[3])
3573        #[serde(default, skip_serializing_if = "Option::is_none")]
3574        dimension: Option<u32>,
3575    },
3576
3577    /// List type (Materialize): INT LIST, TEXT LIST LIST
3578    /// Uses postfix LIST syntax instead of ARRAY<T>
3579    List {
3580        element_type: Box<DataType>,
3581    },
3582
3583    // Struct/Map
3584    // nested: true means parenthesized syntax STRUCT(name TYPE, ...) (DuckDB/Presto/ROW)
3585    // nested: false means angle-bracket syntax STRUCT<name TYPE, ...> (BigQuery)
3586    Struct { fields: Vec<StructField>, nested: bool },
3587    Map { key_type: Box<DataType>, value_type: Box<DataType> },
3588
3589    // Enum type (DuckDB): ENUM('RED', 'GREEN', 'BLUE')
3590    Enum { values: Vec<String>, #[serde(default, skip_serializing_if = "Vec::is_empty")] assignments: Vec<Option<String>> },
3591
3592    // Set type (MySQL): SET('a', 'b', 'c')
3593    Set { values: Vec<String> },
3594
3595    // Union type (DuckDB): UNION(num INT, str TEXT)
3596    Union { fields: Vec<(String, DataType)> },
3597
3598    // Vector (Snowflake / SingleStore)
3599    Vector { #[serde(default)] element_type: Option<Box<DataType>>, dimension: Option<u32> },
3600
3601    // Object (Snowflake structured type)
3602    // fields: Vec of (field_name, field_type, not_null)
3603    Object { fields: Vec<(String, DataType, bool)>, modifier: Option<String> },
3604
3605    // Custom/User-defined
3606    Custom { name: String },
3607
3608    // Spatial types
3609    Geometry {
3610        subtype: Option<String>,
3611        srid: Option<u32>,
3612    },
3613    Geography {
3614        subtype: Option<String>,
3615        srid: Option<u32>,
3616    },
3617
3618    // Character Set (for CONVERT USING in MySQL)
3619    // Renders as CHAR CHARACTER SET {name} in cast target
3620    CharacterSet { name: String },
3621
3622    // Unknown
3623    Unknown,
3624}
3625
3626/// Array expression
3627#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3628#[cfg_attr(feature = "bindings", derive(TS))]
3629#[cfg_attr(feature = "bindings", ts(rename = "SqlArray"))]
3630pub struct Array {
3631    pub expressions: Vec<Expression>,
3632}
3633
3634/// Struct expression
3635#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3636#[cfg_attr(feature = "bindings", derive(TS))]
3637pub struct Struct {
3638    pub fields: Vec<(Option<String>, Expression)>,
3639}
3640
3641/// Tuple expression
3642#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3643#[cfg_attr(feature = "bindings", derive(TS))]
3644pub struct Tuple {
3645    pub expressions: Vec<Expression>,
3646}
3647
3648/// Interval expression
3649#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3650#[cfg_attr(feature = "bindings", derive(TS))]
3651pub struct Interval {
3652    /// The value expression (e.g., '1', 5, column_ref)
3653    pub this: Option<Expression>,
3654    /// The unit specification (optional - can be None, a simple unit, a span, or an expression)
3655    pub unit: Option<IntervalUnitSpec>,
3656}
3657
3658/// Specification for interval unit - can be a simple unit, a span (HOUR TO SECOND), or an expression
3659#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3660#[cfg_attr(feature = "bindings", derive(TS))]
3661#[serde(tag = "type", rename_all = "snake_case")]
3662pub enum IntervalUnitSpec {
3663    /// Simple interval unit (YEAR, MONTH, DAY, etc.)
3664    Simple {
3665        unit: IntervalUnit,
3666        /// Whether to use plural form (e.g., DAYS vs DAY)
3667        use_plural: bool,
3668    },
3669    /// Interval span (e.g., HOUR TO SECOND)
3670    Span(IntervalSpan),
3671    /// Expression-based interval span for Oracle (e.g., DAY(9) TO SECOND(3))
3672    /// The start and end can be expressions like function calls with precision
3673    ExprSpan(IntervalSpanExpr),
3674    /// Expression as unit (e.g., CURRENT_DATE, CAST(GETDATE() AS DATE))
3675    Expr(Box<Expression>),
3676}
3677
3678/// Interval span for ranges like HOUR TO SECOND
3679#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3680#[cfg_attr(feature = "bindings", derive(TS))]
3681pub struct IntervalSpan {
3682    /// Start unit (e.g., HOUR)
3683    pub this: IntervalUnit,
3684    /// End unit (e.g., SECOND)
3685    pub expression: IntervalUnit,
3686}
3687
3688/// Expression-based interval span for Oracle (e.g., DAY(9) TO SECOND(3))
3689/// Unlike IntervalSpan, this uses expressions to represent units with optional precision
3690#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3691#[cfg_attr(feature = "bindings", derive(TS))]
3692pub struct IntervalSpanExpr {
3693    /// Start unit expression (e.g., Var("DAY") or Anonymous("DAY", [9]))
3694    pub this: Box<Expression>,
3695    /// End unit expression (e.g., Var("SECOND") or Anonymous("SECOND", [3]))
3696    pub expression: Box<Expression>,
3697}
3698
3699#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
3700#[cfg_attr(feature = "bindings", derive(TS))]
3701pub enum IntervalUnit {
3702    Year,
3703    Quarter,
3704    Month,
3705    Week,
3706    Day,
3707    Hour,
3708    Minute,
3709    Second,
3710    Millisecond,
3711    Microsecond,
3712}
3713
3714/// SQL Command (COMMIT, ROLLBACK, BEGIN, etc.)
3715#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3716#[cfg_attr(feature = "bindings", derive(TS))]
3717pub struct Command {
3718    /// The command text (e.g., "ROLLBACK", "COMMIT", "BEGIN")
3719    pub this: String,
3720}
3721
3722/// EXEC/EXECUTE statement (TSQL stored procedure call)
3723/// Syntax: EXEC [schema.]procedure_name [@param=value, ...]
3724#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3725#[cfg_attr(feature = "bindings", derive(TS))]
3726pub struct ExecuteStatement {
3727    /// The procedure name (can be qualified: schema.proc_name)
3728    pub this: Expression,
3729    /// Named parameters: @param=value pairs
3730    #[serde(default)]
3731    pub parameters: Vec<ExecuteParameter>,
3732}
3733
3734/// Named parameter in EXEC statement: @name=value
3735#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3736#[cfg_attr(feature = "bindings", derive(TS))]
3737pub struct ExecuteParameter {
3738    /// Parameter name (including @)
3739    pub name: String,
3740    /// Parameter value
3741    pub value: Expression,
3742}
3743
3744/// KILL statement (MySQL/MariaDB)
3745/// KILL [CONNECTION | QUERY] <id>
3746#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3747#[cfg_attr(feature = "bindings", derive(TS))]
3748pub struct Kill {
3749    /// The target (process ID or connection ID)
3750    pub this: Expression,
3751    /// Optional kind: "CONNECTION" or "QUERY"
3752    pub kind: Option<String>,
3753}
3754
3755/// Raw/unparsed SQL
3756#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3757#[cfg_attr(feature = "bindings", derive(TS))]
3758pub struct Raw {
3759    pub sql: String,
3760}
3761
3762// ============================================================================
3763// Function expression types
3764// ============================================================================
3765
3766/// Generic unary function (takes a single argument)
3767#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3768#[cfg_attr(feature = "bindings", derive(TS))]
3769pub struct UnaryFunc {
3770    pub this: Expression,
3771    /// Original function name for round-trip preservation (e.g., CHAR_LENGTH vs LENGTH)
3772    #[serde(skip_serializing_if = "Option::is_none", default)]
3773    pub original_name: Option<String>,
3774}
3775
3776impl UnaryFunc {
3777    /// Create a new UnaryFunc with no original_name
3778    pub fn new(this: Expression) -> Self {
3779        Self { this, original_name: None }
3780    }
3781
3782    /// Create a new UnaryFunc with an original name for round-trip preservation
3783    pub fn with_name(this: Expression, name: String) -> Self {
3784        Self { this, original_name: Some(name) }
3785    }
3786}
3787
3788/// CHAR/CHR function with multiple args and optional USING charset
3789/// e.g., CHAR(77, 77.3, '77.3' USING utf8mb4)
3790/// e.g., CHR(187 USING NCHAR_CS) -- Oracle
3791#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3792#[cfg_attr(feature = "bindings", derive(TS))]
3793pub struct CharFunc {
3794    pub args: Vec<Expression>,
3795    #[serde(skip_serializing_if = "Option::is_none", default)]
3796    pub charset: Option<String>,
3797    /// Original function name (CHAR or CHR), defaults to CHAR
3798    #[serde(skip_serializing_if = "Option::is_none", default)]
3799    pub name: Option<String>,
3800}
3801
3802/// Generic binary function (takes two arguments)
3803#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3804#[cfg_attr(feature = "bindings", derive(TS))]
3805pub struct BinaryFunc {
3806    pub this: Expression,
3807    pub expression: Expression,
3808    /// Original function name for round-trip preservation (e.g., NVL vs IFNULL)
3809    #[serde(skip_serializing_if = "Option::is_none", default)]
3810    pub original_name: Option<String>,
3811}
3812
3813/// Variable argument function
3814#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3815#[cfg_attr(feature = "bindings", derive(TS))]
3816pub struct VarArgFunc {
3817    pub expressions: Vec<Expression>,
3818    /// Original function name for round-trip preservation (e.g., COALESCE vs IFNULL)
3819    #[serde(skip_serializing_if = "Option::is_none", default)]
3820    pub original_name: Option<String>,
3821}
3822
3823/// CONCAT_WS function
3824#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3825#[cfg_attr(feature = "bindings", derive(TS))]
3826pub struct ConcatWs {
3827    pub separator: Expression,
3828    pub expressions: Vec<Expression>,
3829}
3830
3831/// SUBSTRING function
3832#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3833#[cfg_attr(feature = "bindings", derive(TS))]
3834pub struct SubstringFunc {
3835    pub this: Expression,
3836    pub start: Expression,
3837    pub length: Option<Expression>,
3838    /// Whether SQL standard FROM/FOR syntax was used (true) vs comma-separated (false)
3839    #[serde(default)]
3840    pub from_for_syntax: bool,
3841}
3842
3843/// OVERLAY function - OVERLAY(string PLACING replacement FROM position [FOR length])
3844#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3845#[cfg_attr(feature = "bindings", derive(TS))]
3846pub struct OverlayFunc {
3847    pub this: Expression,
3848    pub replacement: Expression,
3849    pub from: Expression,
3850    pub length: Option<Expression>,
3851}
3852
3853/// TRIM function
3854#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3855#[cfg_attr(feature = "bindings", derive(TS))]
3856pub struct TrimFunc {
3857    pub this: Expression,
3858    pub characters: Option<Expression>,
3859    pub position: TrimPosition,
3860    /// Whether SQL standard syntax was used (TRIM(BOTH chars FROM str)) vs function syntax (TRIM(str))
3861    #[serde(default)]
3862    pub sql_standard_syntax: bool,
3863    /// Whether the position was explicitly specified (BOTH/LEADING/TRAILING) vs defaulted
3864    #[serde(default)]
3865    pub position_explicit: bool,
3866}
3867
3868#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
3869#[cfg_attr(feature = "bindings", derive(TS))]
3870pub enum TrimPosition {
3871    Both,
3872    Leading,
3873    Trailing,
3874}
3875
3876/// REPLACE function
3877#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3878#[cfg_attr(feature = "bindings", derive(TS))]
3879pub struct ReplaceFunc {
3880    pub this: Expression,
3881    pub old: Expression,
3882    pub new: Expression,
3883}
3884
3885/// LEFT/RIGHT function
3886#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3887#[cfg_attr(feature = "bindings", derive(TS))]
3888pub struct LeftRightFunc {
3889    pub this: Expression,
3890    pub length: Expression,
3891}
3892
3893/// REPEAT function
3894#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3895#[cfg_attr(feature = "bindings", derive(TS))]
3896pub struct RepeatFunc {
3897    pub this: Expression,
3898    pub times: Expression,
3899}
3900
3901/// LPAD/RPAD function
3902#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3903#[cfg_attr(feature = "bindings", derive(TS))]
3904pub struct PadFunc {
3905    pub this: Expression,
3906    pub length: Expression,
3907    pub fill: Option<Expression>,
3908}
3909
3910/// SPLIT function
3911#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3912#[cfg_attr(feature = "bindings", derive(TS))]
3913pub struct SplitFunc {
3914    pub this: Expression,
3915    pub delimiter: Expression,
3916}
3917
3918/// REGEXP_LIKE function
3919#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3920#[cfg_attr(feature = "bindings", derive(TS))]
3921pub struct RegexpFunc {
3922    pub this: Expression,
3923    pub pattern: Expression,
3924    pub flags: Option<Expression>,
3925}
3926
3927/// REGEXP_REPLACE function
3928#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3929#[cfg_attr(feature = "bindings", derive(TS))]
3930pub struct RegexpReplaceFunc {
3931    pub this: Expression,
3932    pub pattern: Expression,
3933    pub replacement: Expression,
3934    pub flags: Option<Expression>,
3935}
3936
3937/// REGEXP_EXTRACT function
3938#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3939#[cfg_attr(feature = "bindings", derive(TS))]
3940pub struct RegexpExtractFunc {
3941    pub this: Expression,
3942    pub pattern: Expression,
3943    pub group: Option<Expression>,
3944}
3945
3946/// ROUND function
3947#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3948#[cfg_attr(feature = "bindings", derive(TS))]
3949pub struct RoundFunc {
3950    pub this: Expression,
3951    pub decimals: Option<Expression>,
3952}
3953
3954/// FLOOR function with optional scale and time unit (Druid: FLOOR(time TO unit))
3955#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3956#[cfg_attr(feature = "bindings", derive(TS))]
3957pub struct FloorFunc {
3958    pub this: Expression,
3959    pub scale: Option<Expression>,
3960    /// Time unit for Druid-style FLOOR(time TO unit) syntax
3961    #[serde(skip_serializing_if = "Option::is_none", default)]
3962    pub to: Option<Expression>,
3963}
3964
3965/// CEIL function with optional decimals and time unit (Druid: CEIL(time TO unit))
3966#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3967#[cfg_attr(feature = "bindings", derive(TS))]
3968pub struct CeilFunc {
3969    pub this: Expression,
3970    #[serde(skip_serializing_if = "Option::is_none", default)]
3971    pub decimals: Option<Expression>,
3972    /// Time unit for Druid-style CEIL(time TO unit) syntax
3973    #[serde(skip_serializing_if = "Option::is_none", default)]
3974    pub to: Option<Expression>,
3975}
3976
3977/// LOG function
3978#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3979#[cfg_attr(feature = "bindings", derive(TS))]
3980pub struct LogFunc {
3981    pub this: Expression,
3982    pub base: Option<Expression>,
3983}
3984
3985/// CURRENT_DATE (no arguments)
3986#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3987#[cfg_attr(feature = "bindings", derive(TS))]
3988pub struct CurrentDate;
3989
3990/// CURRENT_TIME
3991#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3992#[cfg_attr(feature = "bindings", derive(TS))]
3993pub struct CurrentTime {
3994    pub precision: Option<u32>,
3995}
3996
3997/// CURRENT_TIMESTAMP
3998#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3999#[cfg_attr(feature = "bindings", derive(TS))]
4000pub struct CurrentTimestamp {
4001    pub precision: Option<u32>,
4002    /// If true, generate SYSDATE instead of CURRENT_TIMESTAMP (Oracle-specific)
4003    #[serde(default)]
4004    pub sysdate: bool,
4005}
4006
4007/// CURRENT_TIMESTAMP_LTZ - Snowflake local timezone timestamp
4008#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4009#[cfg_attr(feature = "bindings", derive(TS))]
4010pub struct CurrentTimestampLTZ {
4011    pub precision: Option<u32>,
4012}
4013
4014/// AT TIME ZONE expression for timezone conversion
4015#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4016#[cfg_attr(feature = "bindings", derive(TS))]
4017pub struct AtTimeZone {
4018    /// The expression to convert
4019    pub this: Expression,
4020    /// The target timezone
4021    pub zone: Expression,
4022}
4023
4024/// DATE_ADD / DATE_SUB function
4025#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4026#[cfg_attr(feature = "bindings", derive(TS))]
4027pub struct DateAddFunc {
4028    pub this: Expression,
4029    pub interval: Expression,
4030    pub unit: IntervalUnit,
4031}
4032
4033/// DATEDIFF function
4034#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4035#[cfg_attr(feature = "bindings", derive(TS))]
4036pub struct DateDiffFunc {
4037    pub this: Expression,
4038    pub expression: Expression,
4039    pub unit: Option<IntervalUnit>,
4040}
4041
4042/// DATE_TRUNC function
4043#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4044#[cfg_attr(feature = "bindings", derive(TS))]
4045pub struct DateTruncFunc {
4046    pub this: Expression,
4047    pub unit: DateTimeField,
4048}
4049
4050/// EXTRACT function
4051#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4052#[cfg_attr(feature = "bindings", derive(TS))]
4053pub struct ExtractFunc {
4054    pub this: Expression,
4055    pub field: DateTimeField,
4056}
4057
4058#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4059#[cfg_attr(feature = "bindings", derive(TS))]
4060pub enum DateTimeField {
4061    Year,
4062    Month,
4063    Day,
4064    Hour,
4065    Minute,
4066    Second,
4067    Millisecond,
4068    Microsecond,
4069    DayOfWeek,
4070    DayOfYear,
4071    Week,
4072    /// Week with a modifier like WEEK(monday), WEEK(sunday)
4073    WeekWithModifier(String),
4074    Quarter,
4075    Epoch,
4076    Timezone,
4077    TimezoneHour,
4078    TimezoneMinute,
4079    Date,
4080    Time,
4081    /// Custom datetime field for dialect-specific or arbitrary fields
4082    Custom(String),
4083}
4084
4085/// TO_DATE function
4086#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4087#[cfg_attr(feature = "bindings", derive(TS))]
4088pub struct ToDateFunc {
4089    pub this: Expression,
4090    pub format: Option<Expression>,
4091}
4092
4093/// TO_TIMESTAMP function
4094#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4095#[cfg_attr(feature = "bindings", derive(TS))]
4096pub struct ToTimestampFunc {
4097    pub this: Expression,
4098    pub format: Option<Expression>,
4099}
4100
4101/// IF function
4102#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4103#[cfg_attr(feature = "bindings", derive(TS))]
4104pub struct IfFunc {
4105    pub condition: Expression,
4106    pub true_value: Expression,
4107    pub false_value: Option<Expression>,
4108    /// Original function name (IF, IFF, IIF) for round-trip preservation
4109    #[serde(skip_serializing_if = "Option::is_none", default)]
4110    pub original_name: Option<String>,
4111}
4112
4113/// NVL2 function
4114#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4115#[cfg_attr(feature = "bindings", derive(TS))]
4116pub struct Nvl2Func {
4117    pub this: Expression,
4118    pub true_value: Expression,
4119    pub false_value: Expression,
4120}
4121
4122// ============================================================================
4123// Typed Aggregate Function types
4124// ============================================================================
4125
4126/// Generic aggregate function base type
4127#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4128#[cfg_attr(feature = "bindings", derive(TS))]
4129pub struct AggFunc {
4130    pub this: Expression,
4131    pub distinct: bool,
4132    pub filter: Option<Expression>,
4133    pub order_by: Vec<Ordered>,
4134    /// Original function name (case-preserving) when parsed from SQL
4135    #[serde(skip_serializing_if = "Option::is_none", default)]
4136    pub name: Option<String>,
4137    /// IGNORE NULLS (true) or RESPECT NULLS (false), None if not specified
4138    #[serde(skip_serializing_if = "Option::is_none", default)]
4139    pub ignore_nulls: Option<bool>,
4140    /// HAVING MAX/MIN expr inside aggregate (BigQuery syntax)
4141    /// e.g., ANY_VALUE(fruit HAVING MAX sold) - (expression, is_max: true for MAX, false for MIN)
4142    #[serde(skip_serializing_if = "Option::is_none", default)]
4143    pub having_max: Option<(Box<Expression>, bool)>,
4144    /// LIMIT inside aggregate (e.g., ARRAY_AGG(x ORDER BY y LIMIT 2))
4145    #[serde(skip_serializing_if = "Option::is_none", default)]
4146    pub limit: Option<Box<Expression>>,
4147}
4148
4149/// COUNT function with optional star
4150#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4151#[cfg_attr(feature = "bindings", derive(TS))]
4152pub struct CountFunc {
4153    pub this: Option<Expression>,
4154    pub star: bool,
4155    pub distinct: bool,
4156    pub filter: Option<Expression>,
4157    /// IGNORE NULLS (true) or RESPECT NULLS (false)
4158    #[serde(default, skip_serializing_if = "Option::is_none")]
4159    pub ignore_nulls: Option<bool>,
4160    /// Original function name for case preservation (e.g., "count" or "COUNT")
4161    #[serde(default, skip_serializing_if = "Option::is_none")]
4162    pub original_name: Option<String>,
4163}
4164
4165/// GROUP_CONCAT function (MySQL style)
4166#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4167#[cfg_attr(feature = "bindings", derive(TS))]
4168pub struct GroupConcatFunc {
4169    pub this: Expression,
4170    pub separator: Option<Expression>,
4171    pub order_by: Option<Vec<Ordered>>,
4172    pub distinct: bool,
4173    pub filter: Option<Expression>,
4174}
4175
4176/// STRING_AGG function (PostgreSQL/Standard SQL)
4177#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4178#[cfg_attr(feature = "bindings", derive(TS))]
4179pub struct StringAggFunc {
4180    pub this: Expression,
4181    #[serde(default)]
4182    pub separator: Option<Expression>,
4183    #[serde(default)]
4184    pub order_by: Option<Vec<Ordered>>,
4185    #[serde(default)]
4186    pub distinct: bool,
4187    #[serde(default)]
4188    pub filter: Option<Expression>,
4189    /// BigQuery LIMIT inside STRING_AGG
4190    #[serde(default, skip_serializing_if = "Option::is_none")]
4191    pub limit: Option<Box<Expression>>,
4192}
4193
4194/// LISTAGG function (Oracle style)
4195#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4196#[cfg_attr(feature = "bindings", derive(TS))]
4197pub struct ListAggFunc {
4198    pub this: Expression,
4199    pub separator: Option<Expression>,
4200    pub on_overflow: Option<ListAggOverflow>,
4201    pub order_by: Option<Vec<Ordered>>,
4202    pub distinct: bool,
4203    pub filter: Option<Expression>,
4204}
4205
4206/// LISTAGG ON OVERFLOW behavior
4207#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4208#[cfg_attr(feature = "bindings", derive(TS))]
4209pub enum ListAggOverflow {
4210    Error,
4211    Truncate {
4212        filler: Option<Expression>,
4213        with_count: bool,
4214    },
4215}
4216
4217/// SUM_IF / COUNT_IF function
4218#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4219#[cfg_attr(feature = "bindings", derive(TS))]
4220pub struct SumIfFunc {
4221    pub this: Expression,
4222    pub condition: Expression,
4223    pub filter: Option<Expression>,
4224}
4225
4226/// APPROX_PERCENTILE function
4227#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4228#[cfg_attr(feature = "bindings", derive(TS))]
4229pub struct ApproxPercentileFunc {
4230    pub this: Expression,
4231    pub percentile: Expression,
4232    pub accuracy: Option<Expression>,
4233    pub filter: Option<Expression>,
4234}
4235
4236/// PERCENTILE_CONT / PERCENTILE_DISC function
4237#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4238#[cfg_attr(feature = "bindings", derive(TS))]
4239pub struct PercentileFunc {
4240    pub this: Expression,
4241    pub percentile: Expression,
4242    pub order_by: Option<Vec<Ordered>>,
4243    pub filter: Option<Expression>,
4244}
4245
4246// ============================================================================
4247// Typed Window Function types
4248// ============================================================================
4249
4250/// ROW_NUMBER function (no arguments)
4251#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4252#[cfg_attr(feature = "bindings", derive(TS))]
4253pub struct RowNumber;
4254
4255/// RANK function (DuckDB allows ORDER BY inside, Oracle allows hypothetical args with WITHIN GROUP)
4256#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4257#[cfg_attr(feature = "bindings", derive(TS))]
4258pub struct Rank {
4259    /// DuckDB: RANK(ORDER BY col) - order by inside function
4260    #[serde(default, skip_serializing_if = "Option::is_none")]
4261    pub order_by: Option<Vec<Ordered>>,
4262    /// Oracle hypothetical rank: RANK(val1, val2, ...) WITHIN GROUP (ORDER BY ...)
4263    #[serde(default, skip_serializing_if = "Vec::is_empty")]
4264    pub args: Vec<Expression>,
4265}
4266
4267/// DENSE_RANK function (Oracle allows hypothetical args with WITHIN GROUP)
4268#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4269#[cfg_attr(feature = "bindings", derive(TS))]
4270pub struct DenseRank {
4271    /// Oracle hypothetical rank: DENSE_RANK(val1, val2, ...) WITHIN GROUP (ORDER BY ...)
4272    #[serde(default, skip_serializing_if = "Vec::is_empty")]
4273    pub args: Vec<Expression>,
4274}
4275
4276/// NTILE function (DuckDB allows ORDER BY inside)
4277#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4278#[cfg_attr(feature = "bindings", derive(TS))]
4279pub struct NTileFunc {
4280    /// num_buckets is optional to support Databricks NTILE() without arguments
4281    #[serde(default, skip_serializing_if = "Option::is_none")]
4282    pub num_buckets: Option<Expression>,
4283    /// DuckDB: NTILE(n ORDER BY col) - order by inside function
4284    #[serde(default, skip_serializing_if = "Option::is_none")]
4285    pub order_by: Option<Vec<Ordered>>,
4286}
4287
4288/// LEAD / LAG function
4289#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4290#[cfg_attr(feature = "bindings", derive(TS))]
4291pub struct LeadLagFunc {
4292    pub this: Expression,
4293    pub offset: Option<Expression>,
4294    pub default: Option<Expression>,
4295    pub ignore_nulls: bool,
4296}
4297
4298/// FIRST_VALUE / LAST_VALUE function
4299#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4300#[cfg_attr(feature = "bindings", derive(TS))]
4301pub struct ValueFunc {
4302    pub this: Expression,
4303    /// None = not specified, Some(true) = IGNORE NULLS, Some(false) = RESPECT NULLS
4304    #[serde(default, skip_serializing_if = "Option::is_none")]
4305    pub ignore_nulls: Option<bool>,
4306}
4307
4308/// NTH_VALUE function
4309#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4310#[cfg_attr(feature = "bindings", derive(TS))]
4311pub struct NthValueFunc {
4312    pub this: Expression,
4313    pub offset: Expression,
4314    /// None = not specified, Some(true) = IGNORE NULLS, Some(false) = RESPECT NULLS
4315    #[serde(default, skip_serializing_if = "Option::is_none")]
4316    pub ignore_nulls: Option<bool>,
4317}
4318
4319/// PERCENT_RANK function (DuckDB allows ORDER BY inside, Oracle allows hypothetical args with WITHIN GROUP)
4320#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4321#[cfg_attr(feature = "bindings", derive(TS))]
4322pub struct PercentRank {
4323    /// DuckDB: PERCENT_RANK(ORDER BY col) - order by inside function
4324    #[serde(default, skip_serializing_if = "Option::is_none")]
4325    pub order_by: Option<Vec<Ordered>>,
4326    /// Oracle hypothetical rank: PERCENT_RANK(val1, val2, ...) WITHIN GROUP (ORDER BY ...)
4327    #[serde(default, skip_serializing_if = "Vec::is_empty")]
4328    pub args: Vec<Expression>,
4329}
4330
4331/// CUME_DIST function (DuckDB allows ORDER BY inside, Oracle allows hypothetical args with WITHIN GROUP)
4332#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4333#[cfg_attr(feature = "bindings", derive(TS))]
4334pub struct CumeDist {
4335    /// DuckDB: CUME_DIST(ORDER BY col) - order by inside function
4336    #[serde(default, skip_serializing_if = "Option::is_none")]
4337    pub order_by: Option<Vec<Ordered>>,
4338    /// Oracle hypothetical rank: CUME_DIST(val1, val2, ...) WITHIN GROUP (ORDER BY ...)
4339    #[serde(default, skip_serializing_if = "Vec::is_empty")]
4340    pub args: Vec<Expression>,
4341}
4342
4343// ============================================================================
4344// Additional String Function types
4345// ============================================================================
4346
4347/// POSITION/INSTR function
4348#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4349#[cfg_attr(feature = "bindings", derive(TS))]
4350pub struct PositionFunc {
4351    pub substring: Expression,
4352    pub string: Expression,
4353    pub start: Option<Expression>,
4354}
4355
4356// ============================================================================
4357// Additional Math Function types
4358// ============================================================================
4359
4360/// RANDOM function (no arguments)
4361#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4362#[cfg_attr(feature = "bindings", derive(TS))]
4363pub struct Random;
4364
4365/// RAND function (optional seed, or Teradata RANDOM(lower, upper))
4366#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4367#[cfg_attr(feature = "bindings", derive(TS))]
4368pub struct Rand {
4369    pub seed: Option<Box<Expression>>,
4370    /// Teradata RANDOM lower bound
4371    #[serde(default)]
4372    pub lower: Option<Box<Expression>>,
4373    /// Teradata RANDOM upper bound
4374    #[serde(default)]
4375    pub upper: Option<Box<Expression>>,
4376}
4377
4378/// TRUNCATE / TRUNC function
4379#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4380#[cfg_attr(feature = "bindings", derive(TS))]
4381pub struct TruncateFunc {
4382    pub this: Expression,
4383    pub decimals: Option<Expression>,
4384}
4385
4386/// PI function (no arguments)
4387#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4388#[cfg_attr(feature = "bindings", derive(TS))]
4389pub struct Pi;
4390
4391// ============================================================================
4392// Control Flow Function types
4393// ============================================================================
4394
4395/// DECODE function (Oracle style)
4396#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4397#[cfg_attr(feature = "bindings", derive(TS))]
4398pub struct DecodeFunc {
4399    pub this: Expression,
4400    pub search_results: Vec<(Expression, Expression)>,
4401    pub default: Option<Expression>,
4402}
4403
4404// ============================================================================
4405// Additional Date/Time Function types
4406// ============================================================================
4407
4408/// DATE_FORMAT / FORMAT_DATE function
4409#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4410#[cfg_attr(feature = "bindings", derive(TS))]
4411pub struct DateFormatFunc {
4412    pub this: Expression,
4413    pub format: Expression,
4414}
4415
4416/// FROM_UNIXTIME function
4417#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4418#[cfg_attr(feature = "bindings", derive(TS))]
4419pub struct FromUnixtimeFunc {
4420    pub this: Expression,
4421    pub format: Option<Expression>,
4422}
4423
4424/// UNIX_TIMESTAMP function
4425#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4426#[cfg_attr(feature = "bindings", derive(TS))]
4427pub struct UnixTimestampFunc {
4428    pub this: Option<Expression>,
4429    pub format: Option<Expression>,
4430}
4431
4432/// MAKE_DATE function
4433#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4434#[cfg_attr(feature = "bindings", derive(TS))]
4435pub struct MakeDateFunc {
4436    pub year: Expression,
4437    pub month: Expression,
4438    pub day: Expression,
4439}
4440
4441/// MAKE_TIMESTAMP function
4442#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4443#[cfg_attr(feature = "bindings", derive(TS))]
4444pub struct MakeTimestampFunc {
4445    pub year: Expression,
4446    pub month: Expression,
4447    pub day: Expression,
4448    pub hour: Expression,
4449    pub minute: Expression,
4450    pub second: Expression,
4451    pub timezone: Option<Expression>,
4452}
4453
4454/// LAST_DAY function with optional date part (for BigQuery granularity like WEEK(SUNDAY))
4455#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4456#[cfg_attr(feature = "bindings", derive(TS))]
4457pub struct LastDayFunc {
4458    pub this: Expression,
4459    /// Optional date part for granularity (e.g., MONTH, YEAR, WEEK(SUNDAY))
4460    #[serde(skip_serializing_if = "Option::is_none", default)]
4461    pub unit: Option<DateTimeField>,
4462}
4463
4464// ============================================================================
4465// Array Function types
4466// ============================================================================
4467
4468/// ARRAY constructor
4469#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4470#[cfg_attr(feature = "bindings", derive(TS))]
4471pub struct ArrayConstructor {
4472    pub expressions: Vec<Expression>,
4473    pub bracket_notation: bool,
4474    /// True if LIST keyword was used instead of ARRAY (DuckDB)
4475    pub use_list_keyword: bool,
4476}
4477
4478/// ARRAY_SORT function
4479#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4480#[cfg_attr(feature = "bindings", derive(TS))]
4481pub struct ArraySortFunc {
4482    pub this: Expression,
4483    pub comparator: Option<Expression>,
4484    pub desc: bool,
4485    pub nulls_first: Option<bool>,
4486}
4487
4488/// ARRAY_JOIN / ARRAY_TO_STRING function
4489#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4490#[cfg_attr(feature = "bindings", derive(TS))]
4491pub struct ArrayJoinFunc {
4492    pub this: Expression,
4493    pub separator: Expression,
4494    pub null_replacement: Option<Expression>,
4495}
4496
4497/// UNNEST function
4498#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4499#[cfg_attr(feature = "bindings", derive(TS))]
4500pub struct UnnestFunc {
4501    pub this: Expression,
4502    /// Additional arguments for multi-argument UNNEST (e.g., UNNEST(arr1, arr2))
4503    #[serde(default, skip_serializing_if = "Vec::is_empty")]
4504    pub expressions: Vec<Expression>,
4505    pub with_ordinality: bool,
4506    pub alias: Option<Identifier>,
4507    /// BigQuery: offset alias for WITH OFFSET AS <name>
4508    #[serde(default, skip_serializing_if = "Option::is_none")]
4509    pub offset_alias: Option<Identifier>,
4510}
4511
4512/// ARRAY_FILTER function (with lambda)
4513#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4514#[cfg_attr(feature = "bindings", derive(TS))]
4515pub struct ArrayFilterFunc {
4516    pub this: Expression,
4517    pub filter: Expression,
4518}
4519
4520/// ARRAY_TRANSFORM / TRANSFORM function (with lambda)
4521#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4522#[cfg_attr(feature = "bindings", derive(TS))]
4523pub struct ArrayTransformFunc {
4524    pub this: Expression,
4525    pub transform: Expression,
4526}
4527
4528/// SEQUENCE / GENERATE_SERIES function
4529#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4530#[cfg_attr(feature = "bindings", derive(TS))]
4531pub struct SequenceFunc {
4532    pub start: Expression,
4533    pub stop: Expression,
4534    pub step: Option<Expression>,
4535}
4536
4537// ============================================================================
4538// Struct Function types
4539// ============================================================================
4540
4541/// STRUCT constructor
4542#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4543#[cfg_attr(feature = "bindings", derive(TS))]
4544pub struct StructConstructor {
4545    pub fields: Vec<(Option<Identifier>, Expression)>,
4546}
4547
4548/// STRUCT_EXTRACT function
4549#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4550#[cfg_attr(feature = "bindings", derive(TS))]
4551pub struct StructExtractFunc {
4552    pub this: Expression,
4553    pub field: Identifier,
4554}
4555
4556/// NAMED_STRUCT function
4557#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4558#[cfg_attr(feature = "bindings", derive(TS))]
4559pub struct NamedStructFunc {
4560    pub pairs: Vec<(Expression, Expression)>,
4561}
4562
4563// ============================================================================
4564// Map Function types
4565// ============================================================================
4566
4567/// MAP constructor
4568#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4569#[cfg_attr(feature = "bindings", derive(TS))]
4570pub struct MapConstructor {
4571    pub keys: Vec<Expression>,
4572    pub values: Vec<Expression>,
4573    /// Whether curly brace syntax was used (`{'a': 1}`) vs MAP function (`MAP(...)`)
4574    #[serde(default)]
4575    pub curly_brace_syntax: bool,
4576    /// Whether MAP keyword was present (`MAP {'a': 1}`) vs bare curly braces (`{'a': 1}`)
4577    #[serde(default)]
4578    pub with_map_keyword: bool,
4579}
4580
4581/// TRANSFORM_KEYS / TRANSFORM_VALUES function
4582#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4583#[cfg_attr(feature = "bindings", derive(TS))]
4584pub struct TransformFunc {
4585    pub this: Expression,
4586    pub transform: Expression,
4587}
4588
4589// ============================================================================
4590// JSON Function types
4591// ============================================================================
4592
4593/// JSON_EXTRACT / JSON_EXTRACT_SCALAR function
4594#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4595#[cfg_attr(feature = "bindings", derive(TS))]
4596pub struct JsonExtractFunc {
4597    pub this: Expression,
4598    pub path: Expression,
4599    pub returning: Option<DataType>,
4600    /// True if parsed from -> or ->> operator syntax
4601    #[serde(default)]
4602    pub arrow_syntax: bool,
4603    /// True if parsed from #>> operator syntax (PostgreSQL JSONB path text extraction)
4604    #[serde(default)]
4605    pub hash_arrow_syntax: bool,
4606    /// Wrapper option: WITH/WITHOUT [CONDITIONAL|UNCONDITIONAL] [ARRAY] WRAPPER
4607    #[serde(default)]
4608    pub wrapper_option: Option<String>,
4609    /// Quotes handling: KEEP QUOTES or OMIT QUOTES
4610    #[serde(default)]
4611    pub quotes_option: Option<String>,
4612    /// ON SCALAR STRING flag
4613    #[serde(default)]
4614    pub on_scalar_string: bool,
4615    /// Error handling: NULL ON ERROR, ERROR ON ERROR, etc.
4616    #[serde(default)]
4617    pub on_error: Option<String>,
4618}
4619
4620/// JSON path extraction
4621#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4622#[cfg_attr(feature = "bindings", derive(TS))]
4623pub struct JsonPathFunc {
4624    pub this: Expression,
4625    pub paths: Vec<Expression>,
4626}
4627
4628/// JSON_OBJECT function
4629#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4630#[cfg_attr(feature = "bindings", derive(TS))]
4631pub struct JsonObjectFunc {
4632    pub pairs: Vec<(Expression, Expression)>,
4633    pub null_handling: Option<JsonNullHandling>,
4634    #[serde(default)]
4635    pub with_unique_keys: bool,
4636    #[serde(default)]
4637    pub returning_type: Option<DataType>,
4638    #[serde(default)]
4639    pub format_json: bool,
4640    #[serde(default)]
4641    pub encoding: Option<String>,
4642    /// For JSON_OBJECT(*) syntax
4643    #[serde(default)]
4644    pub star: bool,
4645}
4646
4647/// JSON null handling options
4648#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4649#[cfg_attr(feature = "bindings", derive(TS))]
4650pub enum JsonNullHandling {
4651    NullOnNull,
4652    AbsentOnNull,
4653}
4654
4655/// JSON_SET / JSON_INSERT function
4656#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4657#[cfg_attr(feature = "bindings", derive(TS))]
4658pub struct JsonModifyFunc {
4659    pub this: Expression,
4660    pub path_values: Vec<(Expression, Expression)>,
4661}
4662
4663/// JSON_ARRAYAGG function
4664#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4665#[cfg_attr(feature = "bindings", derive(TS))]
4666pub struct JsonArrayAggFunc {
4667    pub this: Expression,
4668    pub order_by: Option<Vec<Ordered>>,
4669    pub null_handling: Option<JsonNullHandling>,
4670    pub filter: Option<Expression>,
4671}
4672
4673/// JSON_OBJECTAGG function
4674#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4675#[cfg_attr(feature = "bindings", derive(TS))]
4676pub struct JsonObjectAggFunc {
4677    pub key: Expression,
4678    pub value: Expression,
4679    pub null_handling: Option<JsonNullHandling>,
4680    pub filter: Option<Expression>,
4681}
4682
4683// ============================================================================
4684// Type Casting Function types
4685// ============================================================================
4686
4687/// CONVERT function (SQL Server style)
4688#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4689#[cfg_attr(feature = "bindings", derive(TS))]
4690pub struct ConvertFunc {
4691    pub this: Expression,
4692    pub to: DataType,
4693    pub style: Option<Expression>,
4694}
4695
4696// ============================================================================
4697// Additional Expression types
4698// ============================================================================
4699
4700/// Lambda expression
4701#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4702#[cfg_attr(feature = "bindings", derive(TS))]
4703pub struct LambdaExpr {
4704    pub parameters: Vec<Identifier>,
4705    pub body: Expression,
4706    /// True if using DuckDB's LAMBDA x : expr syntax (vs x -> expr)
4707    #[serde(default)]
4708    pub colon: bool,
4709    /// Optional type annotations for parameters (Snowflake: a int -> a + 1)
4710    /// Maps parameter index to data type
4711    #[serde(default)]
4712    pub parameter_types: Vec<Option<DataType>>,
4713}
4714
4715/// Parameter (parameterized queries)
4716#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4717#[cfg_attr(feature = "bindings", derive(TS))]
4718pub struct Parameter {
4719    pub name: Option<String>,
4720    pub index: Option<u32>,
4721    pub style: ParameterStyle,
4722    /// Whether the name was quoted (e.g., @"x" vs @x)
4723    #[serde(default)]
4724    pub quoted: bool,
4725    /// Optional secondary expression for ${kind:name} syntax (Hive hiveconf variables)
4726    #[serde(default)]
4727    pub expression: Option<String>,
4728}
4729
4730/// Parameter placeholder styles
4731#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4732#[cfg_attr(feature = "bindings", derive(TS))]
4733pub enum ParameterStyle {
4734    Question,        // ?
4735    Dollar,          // $1, $2
4736    DollarBrace,     // ${name} (Databricks, Hive template variables)
4737    Brace,           // {name} (Spark/Databricks widget/template variables)
4738    Colon,           // :name
4739    At,              // @name
4740    DoubleAt,        // @@name (system variables in MySQL/SQL Server)
4741    DoubleDollar,    // $$name
4742    Percent,         // %s, %(name)s (PostgreSQL psycopg2 style)
4743}
4744
4745/// Placeholder expression
4746#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4747#[cfg_attr(feature = "bindings", derive(TS))]
4748pub struct Placeholder {
4749    pub index: Option<u32>,
4750}
4751
4752/// Named argument in function call: name => value or name := value
4753#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4754#[cfg_attr(feature = "bindings", derive(TS))]
4755pub struct NamedArgument {
4756    pub name: Identifier,
4757    pub value: Expression,
4758    /// The separator used: `=>`, `:=`, or `=`
4759    pub separator: NamedArgSeparator,
4760}
4761
4762/// Separator style for named arguments
4763#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4764#[cfg_attr(feature = "bindings", derive(TS))]
4765pub enum NamedArgSeparator {
4766    /// `=>` (standard SQL, Snowflake, BigQuery)
4767    DArrow,
4768    /// `:=` (Oracle, MySQL)
4769    ColonEq,
4770    /// `=` (simple equals, some dialects)
4771    Eq,
4772}
4773
4774/// TABLE ref or MODEL ref used as a function argument (BigQuery)
4775/// e.g., GAP_FILL(TABLE device_data, ...) or ML.PREDICT(MODEL mydataset.mymodel, ...)
4776#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4777#[cfg_attr(feature = "bindings", derive(TS))]
4778pub struct TableArgument {
4779    /// The keyword prefix: "TABLE" or "MODEL"
4780    pub prefix: String,
4781    /// The table/model reference expression
4782    pub this: Expression,
4783}
4784
4785/// SQL Comment preservation
4786#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4787#[cfg_attr(feature = "bindings", derive(TS))]
4788pub struct SqlComment {
4789    pub text: String,
4790    pub is_block: bool,
4791}
4792
4793// ============================================================================
4794// Additional Predicate types
4795// ============================================================================
4796
4797/// SIMILAR TO expression
4798#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4799#[cfg_attr(feature = "bindings", derive(TS))]
4800pub struct SimilarToExpr {
4801    pub this: Expression,
4802    pub pattern: Expression,
4803    pub escape: Option<Expression>,
4804    pub not: bool,
4805}
4806
4807/// ANY / ALL quantified expression
4808#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4809#[cfg_attr(feature = "bindings", derive(TS))]
4810pub struct QuantifiedExpr {
4811    pub this: Expression,
4812    pub subquery: Expression,
4813    pub op: Option<QuantifiedOp>,
4814}
4815
4816/// Comparison operator for quantified expressions
4817#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4818#[cfg_attr(feature = "bindings", derive(TS))]
4819pub enum QuantifiedOp {
4820    Eq,
4821    Neq,
4822    Lt,
4823    Lte,
4824    Gt,
4825    Gte,
4826}
4827
4828/// OVERLAPS expression
4829/// Supports two forms:
4830/// 1. Simple binary: a OVERLAPS b (this, expression are set)
4831/// 2. Full ANSI: (a, b) OVERLAPS (c, d) (left_start, left_end, right_start, right_end are set)
4832#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4833#[cfg_attr(feature = "bindings", derive(TS))]
4834pub struct OverlapsExpr {
4835    /// Left operand for simple binary form
4836    #[serde(skip_serializing_if = "Option::is_none")]
4837    pub this: Option<Expression>,
4838    /// Right operand for simple binary form
4839    #[serde(skip_serializing_if = "Option::is_none")]
4840    pub expression: Option<Expression>,
4841    /// Left range start for full ANSI form
4842    #[serde(skip_serializing_if = "Option::is_none")]
4843    pub left_start: Option<Expression>,
4844    /// Left range end for full ANSI form
4845    #[serde(skip_serializing_if = "Option::is_none")]
4846    pub left_end: Option<Expression>,
4847    /// Right range start for full ANSI form
4848    #[serde(skip_serializing_if = "Option::is_none")]
4849    pub right_start: Option<Expression>,
4850    /// Right range end for full ANSI form
4851    #[serde(skip_serializing_if = "Option::is_none")]
4852    pub right_end: Option<Expression>,
4853}
4854
4855// ============================================================================
4856// Array/Struct/Map access
4857// ============================================================================
4858
4859/// Subscript access (array[index] or map[key])
4860#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4861#[cfg_attr(feature = "bindings", derive(TS))]
4862pub struct Subscript {
4863    pub this: Expression,
4864    pub index: Expression,
4865}
4866
4867/// Dot access (struct.field)
4868#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4869#[cfg_attr(feature = "bindings", derive(TS))]
4870pub struct DotAccess {
4871    pub this: Expression,
4872    pub field: Identifier,
4873}
4874
4875/// Method call (expr.method(args))
4876#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4877#[cfg_attr(feature = "bindings", derive(TS))]
4878pub struct MethodCall {
4879    pub this: Expression,
4880    pub method: Identifier,
4881    pub args: Vec<Expression>,
4882}
4883
4884/// Array slice (array[start:end])
4885#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4886#[cfg_attr(feature = "bindings", derive(TS))]
4887pub struct ArraySlice {
4888    pub this: Expression,
4889    pub start: Option<Expression>,
4890    pub end: Option<Expression>,
4891}
4892
4893// ============================================================================
4894// DDL (Data Definition Language) Statements
4895// ============================================================================
4896
4897/// ON COMMIT behavior for temporary tables
4898#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4899#[cfg_attr(feature = "bindings", derive(TS))]
4900pub enum OnCommit {
4901    /// ON COMMIT PRESERVE ROWS
4902    PreserveRows,
4903    /// ON COMMIT DELETE ROWS
4904    DeleteRows,
4905}
4906
4907/// CREATE TABLE statement
4908#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4909#[cfg_attr(feature = "bindings", derive(TS))]
4910pub struct CreateTable {
4911    pub name: TableRef,
4912    /// ClickHouse: ON CLUSTER clause for distributed DDL
4913    #[serde(default, skip_serializing_if = "Option::is_none")]
4914    pub on_cluster: Option<OnCluster>,
4915    pub columns: Vec<ColumnDef>,
4916    pub constraints: Vec<TableConstraint>,
4917    pub if_not_exists: bool,
4918    pub temporary: bool,
4919    pub or_replace: bool,
4920    /// Table modifier: DYNAMIC, ICEBERG, EXTERNAL, HYBRID (Snowflake)
4921    #[serde(default, skip_serializing_if = "Option::is_none")]
4922    pub table_modifier: Option<String>,
4923    pub as_select: Option<Expression>,
4924    /// Whether the AS SELECT was wrapped in parentheses
4925    #[serde(default)]
4926    pub as_select_parenthesized: bool,
4927    /// ON COMMIT behavior for temporary tables
4928    #[serde(default)]
4929    pub on_commit: Option<OnCommit>,
4930    /// Clone source table (e.g., CREATE TABLE t CLONE source_table)
4931    #[serde(default)]
4932    pub clone_source: Option<TableRef>,
4933    /// Time travel AT/BEFORE clause for CLONE (e.g., AT(TIMESTAMP => '...'))
4934    #[serde(default, skip_serializing_if = "Option::is_none")]
4935    pub clone_at_clause: Option<Expression>,
4936    /// Whether this is a COPY operation (BigQuery) vs CLONE (Snowflake/Databricks)
4937    #[serde(default)]
4938    pub is_copy: bool,
4939    /// Whether this is a SHALLOW CLONE (Databricks/Delta Lake)
4940    #[serde(default)]
4941    pub shallow_clone: bool,
4942    /// Leading comments before the statement
4943    #[serde(default)]
4944    pub leading_comments: Vec<String>,
4945    /// WITH properties (e.g., WITH (FORMAT='parquet'))
4946    #[serde(default)]
4947    pub with_properties: Vec<(String, String)>,
4948    /// Teradata: table options after name before columns (comma-separated)
4949    #[serde(default)]
4950    pub teradata_post_name_options: Vec<String>,
4951    /// Teradata: WITH DATA (true) or WITH NO DATA (false) after AS SELECT
4952    #[serde(default)]
4953    pub with_data: Option<bool>,
4954    /// Teradata: AND STATISTICS (true) or AND NO STATISTICS (false)
4955    #[serde(default)]
4956    pub with_statistics: Option<bool>,
4957    /// Teradata: Index specifications (NO PRIMARY INDEX, UNIQUE PRIMARY INDEX, etc.)
4958    #[serde(default)]
4959    pub teradata_indexes: Vec<TeradataIndex>,
4960    /// WITH clause (CTEs) - for CREATE TABLE ... AS WITH ... SELECT ...
4961    #[serde(default)]
4962    pub with_cte: Option<With>,
4963    /// Table properties like DEFAULT COLLATE (BigQuery)
4964    #[serde(default)]
4965    pub properties: Vec<Expression>,
4966    /// PostgreSQL PARTITION OF property (e.g., CREATE TABLE t PARTITION OF parent ...)
4967    #[serde(default, skip_serializing_if = "Option::is_none")]
4968    pub partition_of: Option<Expression>,
4969    /// TSQL: WITH(SYSTEM_VERSIONING=ON(...)) after column definitions
4970    #[serde(default)]
4971    pub post_table_properties: Vec<Expression>,
4972    /// MySQL table options after column definitions (ENGINE=val, AUTO_INCREMENT=val, etc.)
4973    #[serde(default)]
4974    pub mysql_table_options: Vec<(String, String)>,
4975    /// PostgreSQL INHERITS clause: INHERITS (parent1, parent2, ...)
4976    #[serde(default, skip_serializing_if = "Vec::is_empty")]
4977    pub inherits: Vec<TableRef>,
4978    /// TSQL ON filegroup or ON filegroup (partition_column) clause
4979    #[serde(default, skip_serializing_if = "Option::is_none")]
4980    pub on_property: Option<OnProperty>,
4981    /// Snowflake: COPY GRANTS clause to copy privileges from replaced table
4982    #[serde(default)]
4983    pub copy_grants: bool,
4984    /// Snowflake: USING TEMPLATE expression for schema inference
4985    #[serde(default, skip_serializing_if = "Option::is_none")]
4986    pub using_template: Option<Box<Expression>>,
4987    /// StarRocks: ROLLUP (r1(col1, col2), r2(col1))
4988    #[serde(default, skip_serializing_if = "Option::is_none")]
4989    pub rollup: Option<RollupProperty>,
4990}
4991
4992/// Teradata index specification for CREATE TABLE
4993#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4994#[cfg_attr(feature = "bindings", derive(TS))]
4995pub struct TeradataIndex {
4996    /// Index kind: NoPrimary, Primary, PrimaryAmp, Unique, UniquePrimary
4997    pub kind: TeradataIndexKind,
4998    /// Optional index name
4999    pub name: Option<String>,
5000    /// Optional column list
5001    pub columns: Vec<String>,
5002}
5003
5004/// Kind of Teradata index
5005#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5006#[cfg_attr(feature = "bindings", derive(TS))]
5007pub enum TeradataIndexKind {
5008    /// NO PRIMARY INDEX
5009    NoPrimary,
5010    /// PRIMARY INDEX
5011    Primary,
5012    /// PRIMARY AMP INDEX
5013    PrimaryAmp,
5014    /// UNIQUE INDEX
5015    Unique,
5016    /// UNIQUE PRIMARY INDEX
5017    UniquePrimary,
5018    /// INDEX (secondary, non-primary)
5019    Secondary,
5020}
5021
5022impl CreateTable {
5023    pub fn new(name: impl Into<String>) -> Self {
5024        Self {
5025            name: TableRef::new(name),
5026            on_cluster: None,
5027            columns: Vec::new(),
5028            constraints: Vec::new(),
5029            if_not_exists: false,
5030            temporary: false,
5031            or_replace: false,
5032            table_modifier: None,
5033            as_select: None,
5034            as_select_parenthesized: false,
5035            on_commit: None,
5036            clone_source: None,
5037            clone_at_clause: None,
5038            shallow_clone: false, is_copy: false,
5039            leading_comments: Vec::new(),
5040            with_properties: Vec::new(),
5041            teradata_post_name_options: Vec::new(),
5042            with_data: None,
5043            with_statistics: None,
5044            teradata_indexes: Vec::new(),
5045            with_cte: None,
5046            properties: Vec::new(),
5047            partition_of: None,
5048            post_table_properties: Vec::new(),
5049            mysql_table_options: Vec::new(),
5050            inherits: Vec::new(),
5051            on_property: None,
5052            copy_grants: false,
5053            using_template: None,
5054            rollup: None,
5055        }
5056    }
5057}
5058
5059/// Sort order for PRIMARY KEY ASC/DESC
5060#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
5061#[cfg_attr(feature = "bindings", derive(TS))]
5062pub enum SortOrder {
5063    Asc,
5064    Desc,
5065}
5066
5067/// Type of column constraint for tracking order
5068#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5069#[cfg_attr(feature = "bindings", derive(TS))]
5070pub enum ConstraintType {
5071    NotNull,
5072    Null,
5073    PrimaryKey,
5074    Unique,
5075    Default,
5076    AutoIncrement,
5077    Collate,
5078    Comment,
5079    References,
5080    Check,
5081    GeneratedAsIdentity,
5082    /// Snowflake: TAG (key='value', ...)
5083    Tags,
5084    /// Computed/generated column
5085    ComputedColumn,
5086    /// TSQL temporal: GENERATED ALWAYS AS ROW START|END
5087    GeneratedAsRow,
5088    /// MySQL: ON UPDATE expression
5089    OnUpdate,
5090    /// PATH constraint for XMLTABLE/JSON_TABLE columns
5091    Path,
5092    /// Redshift: ENCODE encoding_type
5093    Encode,
5094}
5095
5096/// Column definition in CREATE TABLE
5097#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5098#[cfg_attr(feature = "bindings", derive(TS))]
5099pub struct ColumnDef {
5100    pub name: Identifier,
5101    pub data_type: DataType,
5102    pub nullable: Option<bool>,
5103    pub default: Option<Expression>,
5104    pub primary_key: bool,
5105    /// Sort order for PRIMARY KEY (ASC/DESC)
5106    #[serde(default)]
5107    pub primary_key_order: Option<SortOrder>,
5108    pub unique: bool,
5109    /// PostgreSQL 15+: UNIQUE NULLS NOT DISTINCT
5110    #[serde(default)]
5111    pub unique_nulls_not_distinct: bool,
5112    pub auto_increment: bool,
5113    pub comment: Option<String>,
5114    pub constraints: Vec<ColumnConstraint>,
5115    /// Track original order of constraints for accurate regeneration
5116    #[serde(default)]
5117    pub constraint_order: Vec<ConstraintType>,
5118    /// Teradata: FORMAT 'pattern'
5119    #[serde(default)]
5120    pub format: Option<String>,
5121    /// Teradata: TITLE 'title'
5122    #[serde(default)]
5123    pub title: Option<String>,
5124    /// Teradata: INLINE LENGTH n
5125    #[serde(default)]
5126    pub inline_length: Option<u64>,
5127    /// Teradata: COMPRESS or COMPRESS (values) or COMPRESS 'value'
5128    #[serde(default)]
5129    pub compress: Option<Vec<Expression>>,
5130    /// Teradata: CHARACTER SET name
5131    #[serde(default)]
5132    pub character_set: Option<String>,
5133    /// Teradata: UPPERCASE
5134    #[serde(default)]
5135    pub uppercase: bool,
5136    /// Teradata: CASESPECIFIC / NOT CASESPECIFIC (None = not specified, Some(true) = CASESPECIFIC, Some(false) = NOT CASESPECIFIC)
5137    #[serde(default)]
5138    pub casespecific: Option<bool>,
5139    /// Snowflake: AUTOINCREMENT START value
5140    #[serde(default)]
5141    pub auto_increment_start: Option<Box<Expression>>,
5142    /// Snowflake: AUTOINCREMENT INCREMENT value
5143    #[serde(default)]
5144    pub auto_increment_increment: Option<Box<Expression>>,
5145    /// Snowflake: AUTOINCREMENT ORDER/NOORDER (true = ORDER, false = NOORDER, None = not specified)
5146    #[serde(default)]
5147    pub auto_increment_order: Option<bool>,
5148    /// MySQL: UNSIGNED modifier
5149    #[serde(default)]
5150    pub unsigned: bool,
5151    /// MySQL: ZEROFILL modifier
5152    #[serde(default)]
5153    pub zerofill: bool,
5154    /// MySQL: ON UPDATE expression (e.g., ON UPDATE CURRENT_TIMESTAMP)
5155    #[serde(default, skip_serializing_if = "Option::is_none")]
5156    pub on_update: Option<Expression>,
5157    /// Named constraint for UNIQUE (e.g., CONSTRAINT must_be_different UNIQUE)
5158    #[serde(default, skip_serializing_if = "Option::is_none")]
5159    pub unique_constraint_name: Option<String>,
5160    /// Named constraint for NOT NULL (e.g., CONSTRAINT present NOT NULL)
5161    #[serde(default, skip_serializing_if = "Option::is_none")]
5162    pub not_null_constraint_name: Option<String>,
5163    /// Named constraint for PRIMARY KEY (e.g., CONSTRAINT pk_name PRIMARY KEY)
5164    #[serde(default, skip_serializing_if = "Option::is_none")]
5165    pub primary_key_constraint_name: Option<String>,
5166    /// Named constraint for CHECK (e.g., CONSTRAINT chk_name CHECK(...))
5167    #[serde(default, skip_serializing_if = "Option::is_none")]
5168    pub check_constraint_name: Option<String>,
5169    /// BigQuery: OPTIONS (key=value, ...) on column
5170    #[serde(default, skip_serializing_if = "Vec::is_empty")]
5171    pub options: Vec<Expression>,
5172    /// SQLite: Column definition without explicit type
5173    #[serde(default)]
5174    pub no_type: bool,
5175    /// Redshift: ENCODE encoding_type (e.g., ZSTD, DELTA, LZO, etc.)
5176    #[serde(default, skip_serializing_if = "Option::is_none")]
5177    pub encoding: Option<String>,
5178    /// ClickHouse: CODEC(LZ4HC(9), ZSTD, DELTA)
5179    #[serde(default, skip_serializing_if = "Option::is_none")]
5180    pub codec: Option<String>,
5181    /// ClickHouse: EPHEMERAL [expr] modifier
5182    #[serde(default, skip_serializing_if = "Option::is_none")]
5183    pub ephemeral: Option<Option<Box<Expression>>>,
5184    /// ClickHouse: MATERIALIZED expr modifier
5185    #[serde(default, skip_serializing_if = "Option::is_none")]
5186    pub materialized_expr: Option<Box<Expression>>,
5187    /// ClickHouse: ALIAS expr modifier
5188    #[serde(default, skip_serializing_if = "Option::is_none")]
5189    pub alias_expr: Option<Box<Expression>>,
5190    /// ClickHouse: TTL expr modifier on columns
5191    #[serde(default, skip_serializing_if = "Option::is_none")]
5192    pub ttl_expr: Option<Box<Expression>>,
5193    /// TSQL: NOT FOR REPLICATION
5194    #[serde(default)]
5195    pub not_for_replication: bool,
5196}
5197
5198impl ColumnDef {
5199    pub fn new(name: impl Into<String>, data_type: DataType) -> Self {
5200        Self {
5201            name: Identifier::new(name),
5202            data_type,
5203            nullable: None,
5204            default: None,
5205            primary_key: false,
5206            primary_key_order: None,
5207            unique: false,
5208            unique_nulls_not_distinct: false,
5209            auto_increment: false,
5210            comment: None,
5211            constraints: Vec::new(),
5212            constraint_order: Vec::new(),
5213            format: None,
5214            title: None,
5215            inline_length: None,
5216            compress: None,
5217            character_set: None,
5218            uppercase: false,
5219            casespecific: None,
5220            auto_increment_start: None,
5221            auto_increment_increment: None,
5222            auto_increment_order: None,
5223            unsigned: false,
5224            zerofill: false,
5225            on_update: None,
5226            unique_constraint_name: None,
5227            not_null_constraint_name: None,
5228            primary_key_constraint_name: None,
5229            check_constraint_name: None,
5230            options: Vec::new(),
5231            no_type: false,
5232            encoding: None,
5233            codec: None,
5234            ephemeral: None,
5235            materialized_expr: None,
5236            alias_expr: None,
5237            ttl_expr: None,
5238            not_for_replication: false,
5239        }
5240    }
5241}
5242
5243/// Column-level constraint
5244#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5245#[cfg_attr(feature = "bindings", derive(TS))]
5246pub enum ColumnConstraint {
5247    NotNull,
5248    Null,
5249    Unique,
5250    PrimaryKey,
5251    Default(Expression),
5252    Check(Expression),
5253    References(ForeignKeyRef),
5254    GeneratedAsIdentity(GeneratedAsIdentity),
5255    Collate(Identifier),
5256    Comment(String),
5257    /// Snowflake: TAG (key='value', ...)
5258    Tags(Tags),
5259    /// Computed/generated column: GENERATED ALWAYS AS (expr) STORED|VIRTUAL (MySQL/PostgreSQL)
5260    /// or AS (expr) PERSISTED [NOT NULL] (TSQL)
5261    ComputedColumn(ComputedColumn),
5262    /// TSQL temporal: GENERATED ALWAYS AS ROW START|END [HIDDEN]
5263    GeneratedAsRow(GeneratedAsRow),
5264    /// PATH constraint for XMLTABLE/JSON_TABLE columns: PATH 'xpath'
5265    Path(Expression),
5266}
5267
5268/// Computed/generated column constraint
5269#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5270#[cfg_attr(feature = "bindings", derive(TS))]
5271pub struct ComputedColumn {
5272    /// The expression that computes the column value
5273    pub expression: Box<Expression>,
5274    /// PERSISTED (TSQL) or STORED (MySQL/PostgreSQL) = true; VIRTUAL = false; None = not specified
5275    #[serde(default)]
5276    pub persisted: bool,
5277    /// NOT NULL (TSQL computed columns)
5278    #[serde(default)]
5279    pub not_null: bool,
5280    /// The persistence keyword used: "STORED", "VIRTUAL", or "PERSISTED"
5281    /// When None, defaults to dialect-appropriate output
5282    #[serde(default)]
5283    pub persistence_kind: Option<String>,
5284    /// Optional data type for SingleStore: AS (expr) PERSISTED TYPE NOT NULL
5285    #[serde(default, skip_serializing_if = "Option::is_none")]
5286    pub data_type: Option<DataType>,
5287}
5288
5289/// TSQL temporal column constraint: GENERATED ALWAYS AS ROW START|END [HIDDEN]
5290#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5291#[cfg_attr(feature = "bindings", derive(TS))]
5292pub struct GeneratedAsRow {
5293    /// true = ROW START, false = ROW END
5294    pub start: bool,
5295    /// HIDDEN modifier
5296    #[serde(default)]
5297    pub hidden: bool,
5298}
5299
5300/// Generated identity column constraint
5301#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5302#[cfg_attr(feature = "bindings", derive(TS))]
5303pub struct GeneratedAsIdentity {
5304    /// True for ALWAYS, False for BY DEFAULT
5305    pub always: bool,
5306    /// ON NULL (only valid with BY DEFAULT)
5307    pub on_null: bool,
5308    /// START WITH value
5309    pub start: Option<Box<Expression>>,
5310    /// INCREMENT BY value
5311    pub increment: Option<Box<Expression>>,
5312    /// MINVALUE
5313    pub minvalue: Option<Box<Expression>>,
5314    /// MAXVALUE
5315    pub maxvalue: Option<Box<Expression>>,
5316    /// CYCLE option - Some(true) = CYCLE, Some(false) = NO CYCLE, None = not specified
5317    pub cycle: Option<bool>,
5318}
5319
5320/// Constraint modifiers (shared between table-level constraints)
5321#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
5322#[cfg_attr(feature = "bindings", derive(TS))]
5323pub struct ConstraintModifiers {
5324    /// ENFORCED / NOT ENFORCED
5325    pub enforced: Option<bool>,
5326    /// DEFERRABLE / NOT DEFERRABLE
5327    pub deferrable: Option<bool>,
5328    /// INITIALLY DEFERRED / INITIALLY IMMEDIATE
5329    pub initially_deferred: Option<bool>,
5330    /// NORELY (Oracle)
5331    pub norely: bool,
5332    /// RELY (Oracle)
5333    pub rely: bool,
5334    /// USING index type (MySQL): BTREE or HASH
5335    #[serde(default)]
5336    pub using: Option<String>,
5337    /// True if USING appeared before columns (MySQL: INDEX USING BTREE (col) vs INDEX (col) USING BTREE)
5338    #[serde(default)]
5339    pub using_before_columns: bool,
5340    /// MySQL index COMMENT 'text'
5341    #[serde(default, skip_serializing_if = "Option::is_none")]
5342    pub comment: Option<String>,
5343    /// MySQL index VISIBLE/INVISIBLE
5344    #[serde(default, skip_serializing_if = "Option::is_none")]
5345    pub visible: Option<bool>,
5346    /// MySQL ENGINE_ATTRIBUTE = 'value'
5347    #[serde(default, skip_serializing_if = "Option::is_none")]
5348    pub engine_attribute: Option<String>,
5349    /// MySQL WITH PARSER name
5350    #[serde(default, skip_serializing_if = "Option::is_none")]
5351    pub with_parser: Option<String>,
5352    /// PostgreSQL NOT VALID (constraint is not validated against existing data)
5353    #[serde(default)]
5354    pub not_valid: bool,
5355    /// TSQL CLUSTERED/NONCLUSTERED modifier
5356    #[serde(default, skip_serializing_if = "Option::is_none")]
5357    pub clustered: Option<String>,
5358    /// SQLite ON CONFLICT clause: ROLLBACK, ABORT, FAIL, IGNORE, or REPLACE
5359    #[serde(default, skip_serializing_if = "Option::is_none")]
5360    pub on_conflict: Option<String>,
5361    /// TSQL WITH options (e.g., PAD_INDEX=ON, STATISTICS_NORECOMPUTE=OFF)
5362    #[serde(default, skip_serializing_if = "Vec::is_empty")]
5363    pub with_options: Vec<(String, String)>,
5364    /// TSQL ON filegroup (e.g., ON [INDEX], ON [PRIMARY])
5365    #[serde(default, skip_serializing_if = "Option::is_none")]
5366    pub on_filegroup: Option<Identifier>,
5367}
5368
5369/// Table-level constraint
5370#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5371#[cfg_attr(feature = "bindings", derive(TS))]
5372pub enum TableConstraint {
5373    PrimaryKey {
5374        name: Option<Identifier>,
5375        columns: Vec<Identifier>,
5376        /// INCLUDE (columns) - non-key columns included in the index (PostgreSQL)
5377        #[serde(default)]
5378        include_columns: Vec<Identifier>,
5379        #[serde(default)]
5380        modifiers: ConstraintModifiers,
5381        /// Whether the CONSTRAINT keyword was used (vs MySQL's `PRIMARY KEY name (cols)` syntax)
5382        #[serde(default)]
5383        has_constraint_keyword: bool,
5384    },
5385    Unique {
5386        name: Option<Identifier>,
5387        columns: Vec<Identifier>,
5388        /// Whether columns are parenthesized (false for UNIQUE idx_name without parens)
5389        #[serde(default)]
5390        columns_parenthesized: bool,
5391        #[serde(default)]
5392        modifiers: ConstraintModifiers,
5393        /// Whether the CONSTRAINT keyword was used (vs MySQL's `UNIQUE name (cols)` syntax)
5394        #[serde(default)]
5395        has_constraint_keyword: bool,
5396        /// PostgreSQL 15+: NULLS NOT DISTINCT
5397        #[serde(default)]
5398        nulls_not_distinct: bool,
5399    },
5400    ForeignKey {
5401        name: Option<Identifier>,
5402        columns: Vec<Identifier>,
5403        #[serde(default)]
5404        references: Option<ForeignKeyRef>,
5405        /// ON DELETE action when REFERENCES is absent
5406        #[serde(default)]
5407        on_delete: Option<ReferentialAction>,
5408        /// ON UPDATE action when REFERENCES is absent
5409        #[serde(default)]
5410        on_update: Option<ReferentialAction>,
5411        #[serde(default)]
5412        modifiers: ConstraintModifiers,
5413    },
5414    Check {
5415        name: Option<Identifier>,
5416        expression: Expression,
5417        #[serde(default)]
5418        modifiers: ConstraintModifiers,
5419    },
5420    /// INDEX / KEY constraint (MySQL)
5421    Index {
5422        name: Option<Identifier>,
5423        columns: Vec<Identifier>,
5424        /// Index kind: UNIQUE, FULLTEXT, SPATIAL, etc.
5425        #[serde(default)]
5426        kind: Option<String>,
5427        #[serde(default)]
5428        modifiers: ConstraintModifiers,
5429        /// True if KEY keyword was used instead of INDEX
5430        #[serde(default)]
5431        use_key_keyword: bool,
5432        /// ClickHouse: indexed expression (instead of columns)
5433        #[serde(default, skip_serializing_if = "Option::is_none")]
5434        expression: Option<Box<Expression>>,
5435        /// ClickHouse: TYPE type_func(args)
5436        #[serde(default, skip_serializing_if = "Option::is_none")]
5437        index_type: Option<Box<Expression>>,
5438        /// ClickHouse: GRANULARITY n
5439        #[serde(default, skip_serializing_if = "Option::is_none")]
5440        granularity: Option<Box<Expression>>,
5441    },
5442    /// ClickHouse PROJECTION definition
5443    Projection {
5444        name: Identifier,
5445        expression: Expression,
5446    },
5447    /// PostgreSQL LIKE clause: LIKE source_table [INCLUDING|EXCLUDING options]
5448    Like {
5449        source: TableRef,
5450        /// Options as (INCLUDING|EXCLUDING, property) pairs
5451        options: Vec<(LikeOptionAction, String)>,
5452    },
5453    /// TSQL PERIOD FOR SYSTEM_TIME (start_col, end_col)
5454    PeriodForSystemTime {
5455        start_col: Identifier,
5456        end_col: Identifier,
5457    },
5458    /// PostgreSQL EXCLUDE constraint
5459    /// EXCLUDE [USING method] (element WITH operator, ...) [INCLUDE (cols)] [WHERE (expr)] [WITH (params)]
5460    Exclude {
5461        name: Option<Identifier>,
5462        /// Index access method (gist, btree, etc.)
5463        #[serde(default)]
5464        using: Option<String>,
5465        /// Elements: (expression, operator) pairs
5466        elements: Vec<ExcludeElement>,
5467        /// INCLUDE columns
5468        #[serde(default)]
5469        include_columns: Vec<Identifier>,
5470        /// WHERE predicate
5471        #[serde(default)]
5472        where_clause: Option<Box<Expression>>,
5473        /// WITH (storage_parameters)
5474        #[serde(default)]
5475        with_params: Vec<(String, String)>,
5476        /// USING INDEX TABLESPACE tablespace_name
5477        #[serde(default)]
5478        using_index_tablespace: Option<String>,
5479        #[serde(default)]
5480        modifiers: ConstraintModifiers,
5481    },
5482    /// Snowflake TAG clause: TAG (key='value', key2='value2')
5483    Tags(Tags),
5484    /// PostgreSQL table-level INITIALLY DEFERRED/INITIALLY IMMEDIATE
5485    /// This is a standalone clause at the end of the CREATE TABLE that sets the default
5486    /// for all deferrable constraints in the table
5487    InitiallyDeferred {
5488        /// true = INITIALLY DEFERRED, false = INITIALLY IMMEDIATE
5489        deferred: bool,
5490    },
5491}
5492
5493/// Element in an EXCLUDE constraint: expression WITH operator
5494#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5495#[cfg_attr(feature = "bindings", derive(TS))]
5496pub struct ExcludeElement {
5497    /// The column expression (may include operator class, ordering, nulls)
5498    pub expression: String,
5499    /// The operator (e.g., &&, =)
5500    pub operator: String,
5501}
5502
5503/// Action for LIKE clause options
5504#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
5505#[cfg_attr(feature = "bindings", derive(TS))]
5506pub enum LikeOptionAction {
5507    Including,
5508    Excluding,
5509}
5510
5511/// MATCH type for foreign keys
5512#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
5513#[cfg_attr(feature = "bindings", derive(TS))]
5514pub enum MatchType {
5515    Full,
5516    Partial,
5517    Simple,
5518}
5519
5520/// Foreign key reference
5521#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5522#[cfg_attr(feature = "bindings", derive(TS))]
5523pub struct ForeignKeyRef {
5524    pub table: TableRef,
5525    pub columns: Vec<Identifier>,
5526    pub on_delete: Option<ReferentialAction>,
5527    pub on_update: Option<ReferentialAction>,
5528    /// True if ON UPDATE appears before ON DELETE in the original SQL
5529    #[serde(default)]
5530    pub on_update_first: bool,
5531    /// MATCH clause (FULL, PARTIAL, SIMPLE)
5532    #[serde(default)]
5533    pub match_type: Option<MatchType>,
5534    /// True if MATCH appears after ON DELETE/ON UPDATE clauses
5535    #[serde(default)]
5536    pub match_after_actions: bool,
5537    /// CONSTRAINT name (e.g., CONSTRAINT fk_name REFERENCES ...)
5538    #[serde(default)]
5539    pub constraint_name: Option<String>,
5540    /// DEFERRABLE / NOT DEFERRABLE
5541    #[serde(default)]
5542    pub deferrable: Option<bool>,
5543    /// Snowflake: FOREIGN KEY REFERENCES (includes FOREIGN KEY keywords before REFERENCES)
5544    #[serde(default)]
5545    pub has_foreign_key_keywords: bool,
5546}
5547
5548/// Referential action for foreign keys
5549#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
5550#[cfg_attr(feature = "bindings", derive(TS))]
5551pub enum ReferentialAction {
5552    Cascade,
5553    SetNull,
5554    SetDefault,
5555    Restrict,
5556    NoAction,
5557}
5558
5559/// DROP TABLE statement
5560#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5561#[cfg_attr(feature = "bindings", derive(TS))]
5562pub struct DropTable {
5563    pub names: Vec<TableRef>,
5564    pub if_exists: bool,
5565    pub cascade: bool,
5566    /// Oracle: CASCADE CONSTRAINTS
5567    #[serde(default)]
5568    pub cascade_constraints: bool,
5569    /// Oracle: PURGE
5570    #[serde(default)]
5571    pub purge: bool,
5572}
5573
5574impl DropTable {
5575    pub fn new(name: impl Into<String>) -> Self {
5576        Self {
5577            names: vec![TableRef::new(name)],
5578            if_exists: false,
5579            cascade: false,
5580            cascade_constraints: false,
5581            purge: false,
5582        }
5583    }
5584}
5585
5586/// ALTER TABLE statement
5587#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5588#[cfg_attr(feature = "bindings", derive(TS))]
5589pub struct AlterTable {
5590    pub name: TableRef,
5591    pub actions: Vec<AlterTableAction>,
5592    /// IF EXISTS clause
5593    #[serde(default)]
5594    pub if_exists: bool,
5595    /// MySQL: ALGORITHM=INPLACE|COPY|DEFAULT|INSTANT
5596    #[serde(default, skip_serializing_if = "Option::is_none")]
5597    pub algorithm: Option<String>,
5598    /// MySQL: LOCK=NONE|SHARED|DEFAULT|EXCLUSIVE
5599    #[serde(default, skip_serializing_if = "Option::is_none")]
5600    pub lock: Option<String>,
5601    /// TSQL: WITH CHECK / WITH NOCHECK modifier before ADD CONSTRAINT
5602    #[serde(default, skip_serializing_if = "Option::is_none")]
5603    pub with_check: Option<String>,
5604    /// Hive: PARTITION clause before actions (e.g., ALTER TABLE x PARTITION(y=z) ADD COLUMN ...)
5605    #[serde(default, skip_serializing_if = "Option::is_none")]
5606    pub partition: Option<Vec<(Identifier, Expression)>>,
5607    /// ClickHouse: ON CLUSTER clause for distributed DDL
5608    #[serde(default, skip_serializing_if = "Option::is_none")]
5609    pub on_cluster: Option<OnCluster>,
5610}
5611
5612impl AlterTable {
5613    pub fn new(name: impl Into<String>) -> Self {
5614        Self {
5615            name: TableRef::new(name),
5616            actions: Vec::new(),
5617            if_exists: false,
5618            algorithm: None,
5619            lock: None,
5620            with_check: None,
5621            partition: None,
5622            on_cluster: None,
5623        }
5624    }
5625}
5626
5627/// Column position for ADD COLUMN (MySQL/MariaDB)
5628#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5629#[cfg_attr(feature = "bindings", derive(TS))]
5630pub enum ColumnPosition {
5631    First,
5632    After(Identifier),
5633}
5634
5635/// Actions for ALTER TABLE
5636#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5637#[cfg_attr(feature = "bindings", derive(TS))]
5638pub enum AlterTableAction {
5639    AddColumn {
5640        column: ColumnDef,
5641        if_not_exists: bool,
5642        position: Option<ColumnPosition>,
5643    },
5644    DropColumn {
5645        name: Identifier,
5646        if_exists: bool,
5647        cascade: bool,
5648    },
5649    RenameColumn {
5650        old_name: Identifier,
5651        new_name: Identifier,
5652        if_exists: bool,
5653    },
5654    AlterColumn {
5655        name: Identifier,
5656        action: AlterColumnAction,
5657        /// Whether this was parsed from MODIFY COLUMN syntax (MySQL)
5658        #[serde(default)]
5659        use_modify_keyword: bool,
5660    },
5661    RenameTable(TableRef),
5662    AddConstraint(TableConstraint),
5663    DropConstraint {
5664        name: Identifier,
5665        if_exists: bool,
5666    },
5667    /// DROP FOREIGN KEY action (Oracle/MySQL): ALTER TABLE t DROP FOREIGN KEY fk_name
5668    DropForeignKey {
5669        name: Identifier,
5670    },
5671    /// DROP PARTITION action (Hive/BigQuery)
5672    DropPartition {
5673        /// List of partitions to drop (each partition is a list of key=value pairs)
5674        partitions: Vec<Vec<(Identifier, Expression)>>,
5675        if_exists: bool,
5676    },
5677    /// ADD PARTITION action (Hive/Spark)
5678    AddPartition {
5679        /// The partition expression
5680        partition: Expression,
5681        if_not_exists: bool,
5682        location: Option<Expression>,
5683    },
5684    /// DELETE action (BigQuery): ALTER TABLE t DELETE WHERE condition
5685    Delete {
5686        where_clause: Expression,
5687    },
5688    /// SWAP WITH action (Snowflake): ALTER TABLE a SWAP WITH b
5689    SwapWith(TableRef),
5690    /// SET property action (Snowflake): ALTER TABLE t SET property=value
5691    SetProperty {
5692        properties: Vec<(String, Expression)>,
5693    },
5694    /// UNSET property action (Snowflake): ALTER TABLE t UNSET property
5695    UnsetProperty {
5696        properties: Vec<String>,
5697    },
5698    /// CLUSTER BY action (Snowflake): ALTER TABLE t CLUSTER BY (col1, col2)
5699    ClusterBy {
5700        expressions: Vec<Expression>,
5701    },
5702    /// SET TAG action (Snowflake): ALTER TABLE t SET TAG key='value'
5703    SetTag {
5704        expressions: Vec<(String, Expression)>,
5705    },
5706    /// UNSET TAG action (Snowflake): ALTER TABLE t UNSET TAG key1, key2
5707    UnsetTag {
5708        names: Vec<String>,
5709    },
5710    /// SET with parenthesized options (TSQL): ALTER TABLE t SET (SYSTEM_VERSIONING=ON, ...)
5711    SetOptions {
5712        expressions: Vec<Expression>,
5713    },
5714    /// ALTER INDEX action (MySQL): ALTER TABLE t ALTER INDEX i VISIBLE/INVISIBLE
5715    AlterIndex {
5716        name: Identifier,
5717        visible: bool,
5718    },
5719    /// PostgreSQL: ALTER TABLE t SET LOGGED/UNLOGGED/WITHOUT CLUSTER/WITHOUT OIDS/ACCESS METHOD/TABLESPACE
5720    SetAttribute {
5721        attribute: String,
5722    },
5723    /// Snowflake: ALTER TABLE t SET STAGE_FILE_FORMAT = (options)
5724    SetStageFileFormat {
5725        options: Option<Expression>,
5726    },
5727    /// Snowflake: ALTER TABLE t SET STAGE_COPY_OPTIONS = (options)
5728    SetStageCopyOptions {
5729        options: Option<Expression>,
5730    },
5731    /// Hive/Spark: ADD COLUMNS (col1 TYPE, col2 TYPE) [CASCADE]
5732    AddColumns {
5733        columns: Vec<ColumnDef>,
5734        cascade: bool,
5735    },
5736    /// Spark/Databricks: DROP COLUMNS (col1, col2, ...)
5737    DropColumns {
5738        names: Vec<Identifier>,
5739    },
5740    /// Hive/MySQL/SingleStore: CHANGE [COLUMN] old_name new_name [data_type] [COMMENT 'comment']
5741    /// In SingleStore, data_type can be omitted for simple column renames
5742    ChangeColumn {
5743        old_name: Identifier,
5744        new_name: Identifier,
5745        #[serde(default, skip_serializing_if = "Option::is_none")]
5746        data_type: Option<DataType>,
5747        comment: Option<String>,
5748        #[serde(default)]
5749        cascade: bool,
5750    },
5751    /// Redshift: ALTER TABLE t ALTER SORTKEY AUTO|NONE|(col1, col2)
5752    /// Also: ALTER TABLE t ALTER COMPOUND SORTKEY (col1, col2)
5753    AlterSortKey {
5754        /// AUTO or NONE keyword
5755        this: Option<String>,
5756        /// Column list for (col1, col2) syntax
5757        expressions: Vec<Expression>,
5758        /// Whether COMPOUND keyword was present
5759        compound: bool,
5760    },
5761    /// Redshift: ALTER TABLE t ALTER DISTSTYLE ALL|EVEN|AUTO|KEY
5762    /// Also: ALTER TABLE t ALTER DISTSTYLE KEY DISTKEY col
5763    /// Also: ALTER TABLE t ALTER DISTKEY col (shorthand for DISTSTYLE KEY DISTKEY col)
5764    AlterDistStyle {
5765        /// Distribution style: ALL, EVEN, AUTO, or KEY
5766        style: String,
5767        /// DISTKEY column (only when style is KEY)
5768        distkey: Option<Identifier>,
5769    },
5770    /// Redshift: ALTER TABLE t SET TABLE PROPERTIES ('a' = '5', 'b' = 'c')
5771    SetTableProperties {
5772        properties: Vec<(Expression, Expression)>,
5773    },
5774    /// Redshift: ALTER TABLE t SET LOCATION 's3://bucket/folder/'
5775    SetLocation {
5776        location: String,
5777    },
5778    /// Redshift: ALTER TABLE t SET FILE FORMAT AVRO
5779    SetFileFormat {
5780        format: String,
5781    },
5782    /// ClickHouse: ALTER TABLE t REPLACE PARTITION expr FROM source_table
5783    ReplacePartition {
5784        partition: Expression,
5785        source: Option<Box<Expression>>,
5786    },
5787}
5788
5789/// Actions for ALTER COLUMN
5790#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5791#[cfg_attr(feature = "bindings", derive(TS))]
5792pub enum AlterColumnAction {
5793    SetDataType {
5794        data_type: DataType,
5795        /// USING expression for type conversion (PostgreSQL)
5796        using: Option<Expression>,
5797        /// COLLATE clause (TSQL: ALTER COLUMN col TYPE COLLATE collation_name)
5798        #[serde(default, skip_serializing_if = "Option::is_none")]
5799        collate: Option<String>,
5800    },
5801    SetDefault(Expression),
5802    DropDefault,
5803    SetNotNull,
5804    DropNotNull,
5805    /// Set column comment
5806    Comment(String),
5807    /// MySQL: SET VISIBLE
5808    SetVisible,
5809    /// MySQL: SET INVISIBLE
5810    SetInvisible,
5811}
5812
5813/// CREATE INDEX statement
5814#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5815#[cfg_attr(feature = "bindings", derive(TS))]
5816pub struct CreateIndex {
5817    pub name: Identifier,
5818    pub table: TableRef,
5819    pub columns: Vec<IndexColumn>,
5820    pub unique: bool,
5821    pub if_not_exists: bool,
5822    pub using: Option<String>,
5823    /// TSQL CLUSTERED/NONCLUSTERED modifier
5824    #[serde(default)]
5825    pub clustered: Option<String>,
5826    /// PostgreSQL CONCURRENTLY modifier
5827    #[serde(default)]
5828    pub concurrently: bool,
5829    /// PostgreSQL WHERE clause for partial indexes
5830    #[serde(default)]
5831    pub where_clause: Option<Box<Expression>>,
5832    /// PostgreSQL INCLUDE columns
5833    #[serde(default, skip_serializing_if = "Vec::is_empty")]
5834    pub include_columns: Vec<Identifier>,
5835    /// TSQL WITH options (e.g., allow_page_locks=on)
5836    #[serde(default, skip_serializing_if = "Vec::is_empty")]
5837    pub with_options: Vec<(String, String)>,
5838    /// TSQL ON filegroup or partition scheme (e.g., ON PRIMARY, ON X([y]))
5839    #[serde(default)]
5840    pub on_filegroup: Option<String>,
5841}
5842
5843impl CreateIndex {
5844    pub fn new(name: impl Into<String>, table: impl Into<String>) -> Self {
5845        Self {
5846            name: Identifier::new(name),
5847            table: TableRef::new(table),
5848            columns: Vec::new(),
5849            unique: false,
5850            if_not_exists: false,
5851            using: None,
5852            clustered: None,
5853            concurrently: false,
5854            where_clause: None,
5855            include_columns: Vec::new(),
5856            with_options: Vec::new(),
5857            on_filegroup: None,
5858        }
5859    }
5860}
5861
5862/// Index column specification
5863#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5864#[cfg_attr(feature = "bindings", derive(TS))]
5865pub struct IndexColumn {
5866    pub column: Identifier,
5867    pub desc: bool,
5868    /// Explicit ASC keyword was present
5869    #[serde(default)]
5870    pub asc: bool,
5871    pub nulls_first: Option<bool>,
5872    /// PostgreSQL operator class (e.g., varchar_pattern_ops, public.gin_trgm_ops)
5873    #[serde(default, skip_serializing_if = "Option::is_none")]
5874    pub opclass: Option<String>,
5875}
5876
5877/// DROP INDEX statement
5878#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5879#[cfg_attr(feature = "bindings", derive(TS))]
5880pub struct DropIndex {
5881    pub name: Identifier,
5882    pub table: Option<TableRef>,
5883    pub if_exists: bool,
5884    /// PostgreSQL CONCURRENTLY modifier
5885    #[serde(default)]
5886    pub concurrently: bool,
5887}
5888
5889impl DropIndex {
5890    pub fn new(name: impl Into<String>) -> Self {
5891        Self {
5892            name: Identifier::new(name),
5893            table: None,
5894            if_exists: false,
5895            concurrently: false,
5896        }
5897    }
5898}
5899
5900/// View column definition with optional COMMENT and OPTIONS (BigQuery)
5901#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5902#[cfg_attr(feature = "bindings", derive(TS))]
5903pub struct ViewColumn {
5904    pub name: Identifier,
5905    pub comment: Option<String>,
5906    /// BigQuery: OPTIONS (key=value, ...) on column
5907    #[serde(default, skip_serializing_if = "Vec::is_empty")]
5908    pub options: Vec<Expression>,
5909}
5910
5911impl ViewColumn {
5912    pub fn new(name: impl Into<String>) -> Self {
5913        Self {
5914            name: Identifier::new(name),
5915            comment: None,
5916            options: Vec::new(),
5917        }
5918    }
5919
5920    pub fn with_comment(name: impl Into<String>, comment: impl Into<String>) -> Self {
5921        Self {
5922            name: Identifier::new(name),
5923            comment: Some(comment.into()),
5924            options: Vec::new(),
5925        }
5926    }
5927}
5928
5929/// CREATE VIEW statement
5930#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5931#[cfg_attr(feature = "bindings", derive(TS))]
5932pub struct CreateView {
5933    pub name: TableRef,
5934    pub columns: Vec<ViewColumn>,
5935    pub query: Expression,
5936    pub or_replace: bool,
5937    pub if_not_exists: bool,
5938    pub materialized: bool,
5939    pub temporary: bool,
5940    /// Snowflake: SECURE VIEW
5941    #[serde(default)]
5942    pub secure: bool,
5943    /// MySQL: ALGORITHM=UNDEFINED/MERGE/TEMPTABLE
5944    #[serde(skip_serializing_if = "Option::is_none")]
5945    pub algorithm: Option<String>,
5946    /// MySQL: DEFINER=user@host
5947    #[serde(skip_serializing_if = "Option::is_none")]
5948    pub definer: Option<String>,
5949    /// MySQL: SQL SECURITY DEFINER/INVOKER; Presto: SECURITY DEFINER/INVOKER
5950    #[serde(skip_serializing_if = "Option::is_none")]
5951    pub security: Option<FunctionSecurity>,
5952    /// True for MySQL-style "SQL SECURITY", false for Presto-style "SECURITY"
5953    #[serde(default = "default_true")]
5954    pub security_sql_style: bool,
5955    /// Whether the query was parenthesized: AS (SELECT ...)
5956    #[serde(default)]
5957    pub query_parenthesized: bool,
5958    /// Teradata: LOCKING mode (ROW, TABLE, DATABASE)
5959    #[serde(skip_serializing_if = "Option::is_none")]
5960    pub locking_mode: Option<String>,
5961    /// Teradata: LOCKING access type (ACCESS, READ, WRITE)
5962    #[serde(skip_serializing_if = "Option::is_none")]
5963    pub locking_access: Option<String>,
5964    /// Snowflake: COPY GRANTS
5965    #[serde(default)]
5966    pub copy_grants: bool,
5967    /// Snowflake: COMMENT = 'text'
5968    #[serde(skip_serializing_if = "Option::is_none", default)]
5969    pub comment: Option<String>,
5970    /// Snowflake: TAG (name='value', ...)
5971    #[serde(default)]
5972    pub tags: Vec<(String, String)>,
5973    /// BigQuery: OPTIONS (key=value, ...)
5974    #[serde(default)]
5975    pub options: Vec<Expression>,
5976    /// Doris: BUILD IMMEDIATE/DEFERRED for materialized views
5977    #[serde(skip_serializing_if = "Option::is_none", default)]
5978    pub build: Option<String>,
5979    /// Doris: REFRESH property for materialized views
5980    #[serde(skip_serializing_if = "Option::is_none", default)]
5981    pub refresh: Option<Box<RefreshTriggerProperty>>,
5982    /// Doris: Schema with typed column definitions for materialized views
5983    /// This is used instead of `columns` when the view has typed column definitions
5984    #[serde(skip_serializing_if = "Option::is_none", default)]
5985    pub schema: Option<Box<Schema>>,
5986    /// Doris: KEY (columns) for materialized views
5987    #[serde(skip_serializing_if = "Option::is_none", default)]
5988    pub unique_key: Option<Box<UniqueKeyProperty>>,
5989    /// Redshift: WITH NO SCHEMA BINDING
5990    #[serde(default)]
5991    pub no_schema_binding: bool,
5992    /// Redshift: AUTO REFRESH YES|NO for materialized views
5993    #[serde(skip_serializing_if = "Option::is_none", default)]
5994    pub auto_refresh: Option<bool>,
5995    /// ClickHouse: ON CLUSTER clause
5996    #[serde(default, skip_serializing_if = "Option::is_none")]
5997    pub on_cluster: Option<OnCluster>,
5998    /// ClickHouse: TO destination_table
5999    #[serde(default, skip_serializing_if = "Option::is_none")]
6000    pub to_table: Option<TableRef>,
6001    /// ClickHouse: Table properties (ENGINE, ORDER BY, SAMPLE, SETTINGS, TTL, etc.) for materialized views
6002    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6003    pub table_properties: Vec<Expression>,
6004}
6005
6006impl CreateView {
6007    pub fn new(name: impl Into<String>, query: Expression) -> Self {
6008        Self {
6009            name: TableRef::new(name),
6010            columns: Vec::new(),
6011            query,
6012            or_replace: false,
6013            if_not_exists: false,
6014            materialized: false,
6015            temporary: false,
6016            secure: false,
6017            algorithm: None,
6018            definer: None,
6019            security: None,
6020            security_sql_style: true,
6021            query_parenthesized: false,
6022            locking_mode: None,
6023            locking_access: None,
6024            copy_grants: false,
6025            comment: None,
6026            tags: Vec::new(),
6027            options: Vec::new(),
6028            build: None,
6029            refresh: None,
6030            schema: None,
6031            unique_key: None,
6032            no_schema_binding: false,
6033            auto_refresh: None,
6034            on_cluster: None,
6035            to_table: None,
6036            table_properties: Vec::new(),
6037        }
6038    }
6039}
6040
6041/// DROP VIEW statement
6042#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6043#[cfg_attr(feature = "bindings", derive(TS))]
6044pub struct DropView {
6045    pub name: TableRef,
6046    pub if_exists: bool,
6047    pub materialized: bool,
6048}
6049
6050impl DropView {
6051    pub fn new(name: impl Into<String>) -> Self {
6052        Self {
6053            name: TableRef::new(name),
6054            if_exists: false,
6055            materialized: false,
6056        }
6057    }
6058}
6059
6060/// TRUNCATE TABLE statement
6061#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6062#[cfg_attr(feature = "bindings", derive(TS))]
6063pub struct Truncate {
6064    /// Target of TRUNCATE (TABLE vs DATABASE)
6065    #[serde(default)]
6066    pub target: TruncateTarget,
6067    pub table: TableRef,
6068    /// ClickHouse: ON CLUSTER clause for distributed DDL
6069    #[serde(default, skip_serializing_if = "Option::is_none")]
6070    pub on_cluster: Option<OnCluster>,
6071    pub cascade: bool,
6072    /// Additional tables for multi-table TRUNCATE
6073    #[serde(default)]
6074    pub extra_tables: Vec<TruncateTableEntry>,
6075    /// RESTART IDENTITY or CONTINUE IDENTITY
6076    #[serde(default)]
6077    pub identity: Option<TruncateIdentity>,
6078    /// RESTRICT option (alternative to CASCADE)
6079    #[serde(default)]
6080    pub restrict: bool,
6081    /// Hive PARTITION clause: PARTITION(key=value, ...)
6082    #[serde(default, skip_serializing_if = "Option::is_none")]
6083    pub partition: Option<Box<Expression>>,
6084}
6085
6086/// A table entry in a TRUNCATE statement, with optional ONLY modifier and * suffix
6087#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6088#[cfg_attr(feature = "bindings", derive(TS))]
6089pub struct TruncateTableEntry {
6090    pub table: TableRef,
6091    /// Whether the table has a * suffix (inherit children)
6092    #[serde(default)]
6093    pub star: bool,
6094}
6095
6096/// TRUNCATE target type
6097#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6098#[cfg_attr(feature = "bindings", derive(TS))]
6099pub enum TruncateTarget {
6100    Table,
6101    Database,
6102}
6103
6104impl Default for TruncateTarget {
6105    fn default() -> Self {
6106        TruncateTarget::Table
6107    }
6108}
6109
6110/// TRUNCATE identity option
6111#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6112#[cfg_attr(feature = "bindings", derive(TS))]
6113pub enum TruncateIdentity {
6114    Restart,
6115    Continue,
6116}
6117
6118impl Truncate {
6119    pub fn new(table: impl Into<String>) -> Self {
6120        Self {
6121            target: TruncateTarget::Table,
6122            table: TableRef::new(table),
6123            on_cluster: None,
6124            cascade: false,
6125            extra_tables: Vec::new(),
6126            identity: None,
6127            restrict: false,
6128            partition: None,
6129        }
6130    }
6131}
6132
6133/// USE statement (USE database, USE ROLE, USE WAREHOUSE, USE CATALOG, USE SCHEMA)
6134#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6135#[cfg_attr(feature = "bindings", derive(TS))]
6136pub struct Use {
6137    /// The kind of object (DATABASE, SCHEMA, ROLE, WAREHOUSE, CATALOG, or None for default)
6138    pub kind: Option<UseKind>,
6139    /// The name of the object
6140    pub this: Identifier,
6141}
6142
6143/// Kind of USE statement
6144#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6145#[cfg_attr(feature = "bindings", derive(TS))]
6146pub enum UseKind {
6147    Database,
6148    Schema,
6149    Role,
6150    Warehouse,
6151    Catalog,
6152    /// Snowflake: USE SECONDARY ROLES ALL|NONE
6153    SecondaryRoles,
6154}
6155
6156/// SET variable statement
6157#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6158#[cfg_attr(feature = "bindings", derive(TS))]
6159pub struct SetStatement {
6160    /// The items being set
6161    pub items: Vec<SetItem>,
6162}
6163
6164/// A single SET item (variable assignment)
6165#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6166#[cfg_attr(feature = "bindings", derive(TS))]
6167pub struct SetItem {
6168    /// The variable name
6169    pub name: Expression,
6170    /// The value to set
6171    pub value: Expression,
6172    /// Kind: None for plain SET, Some("GLOBAL") for SET GLOBAL, etc.
6173    pub kind: Option<String>,
6174    /// Whether the SET item was parsed without an = sign (TSQL: SET KEY VALUE)
6175    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
6176    pub no_equals: bool,
6177}
6178
6179/// CACHE TABLE statement (Spark)
6180#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6181#[cfg_attr(feature = "bindings", derive(TS))]
6182pub struct Cache {
6183    /// The table to cache
6184    pub table: Identifier,
6185    /// LAZY keyword - defer caching until first use
6186    pub lazy: bool,
6187    /// Optional OPTIONS clause (key-value pairs)
6188    pub options: Vec<(Expression, Expression)>,
6189    /// Optional AS clause with query
6190    pub query: Option<Expression>,
6191}
6192
6193/// UNCACHE TABLE statement (Spark)
6194#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6195#[cfg_attr(feature = "bindings", derive(TS))]
6196pub struct Uncache {
6197    /// The table to uncache
6198    pub table: Identifier,
6199    /// IF EXISTS clause
6200    pub if_exists: bool,
6201}
6202
6203/// LOAD DATA statement (Hive)
6204#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6205#[cfg_attr(feature = "bindings", derive(TS))]
6206pub struct LoadData {
6207    /// LOCAL keyword - load from local filesystem
6208    pub local: bool,
6209    /// The path to load data from (INPATH value)
6210    pub inpath: String,
6211    /// Whether to overwrite existing data
6212    pub overwrite: bool,
6213    /// The target table
6214    pub table: Expression,
6215    /// Optional PARTITION clause with key-value pairs
6216    pub partition: Vec<(Identifier, Expression)>,
6217    /// Optional INPUTFORMAT clause
6218    pub input_format: Option<String>,
6219    /// Optional SERDE clause
6220    pub serde: Option<String>,
6221}
6222
6223/// PRAGMA statement (SQLite)
6224#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6225#[cfg_attr(feature = "bindings", derive(TS))]
6226pub struct Pragma {
6227    /// Optional schema prefix (e.g., "schema" in "schema.pragma_name")
6228    pub schema: Option<Identifier>,
6229    /// The pragma name
6230    pub name: Identifier,
6231    /// Optional value for assignment (PRAGMA name = value)
6232    pub value: Option<Expression>,
6233    /// Optional arguments for function-style pragmas (PRAGMA name(arg))
6234    pub args: Vec<Expression>,
6235}
6236
6237/// A privilege with optional column list for GRANT/REVOKE
6238/// Examples: SELECT, UPDATE(col1, col2), ALL(col1, col2, col3)
6239#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6240#[cfg_attr(feature = "bindings", derive(TS))]
6241pub struct Privilege {
6242    /// The privilege name (e.g., SELECT, INSERT, UPDATE, ALL)
6243    pub name: String,
6244    /// Optional column list for column-level privileges (e.g., UPDATE(col1, col2))
6245    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6246    pub columns: Vec<String>,
6247}
6248
6249/// Principal in GRANT/REVOKE (user, role, etc.)
6250#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6251#[cfg_attr(feature = "bindings", derive(TS))]
6252pub struct GrantPrincipal {
6253    /// The name of the principal
6254    pub name: Identifier,
6255    /// Whether prefixed with ROLE keyword
6256    pub is_role: bool,
6257    /// Whether prefixed with GROUP keyword (Redshift)
6258    #[serde(default)]
6259    pub is_group: bool,
6260}
6261
6262/// GRANT statement
6263#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6264#[cfg_attr(feature = "bindings", derive(TS))]
6265pub struct Grant {
6266    /// Privileges to grant (e.g., SELECT, INSERT, UPDATE(col1, col2))
6267    pub privileges: Vec<Privilege>,
6268    /// Object kind (TABLE, SCHEMA, FUNCTION, etc.)
6269    pub kind: Option<String>,
6270    /// The object to grant on
6271    pub securable: Identifier,
6272    /// Function parameter types (for FUNCTION kind)
6273    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6274    pub function_params: Vec<String>,
6275    /// The grantees
6276    pub principals: Vec<GrantPrincipal>,
6277    /// WITH GRANT OPTION
6278    pub grant_option: bool,
6279    /// TSQL: AS principal (the grantor role)
6280    #[serde(default, skip_serializing_if = "Option::is_none")]
6281    pub as_principal: Option<Identifier>,
6282}
6283
6284/// REVOKE statement
6285#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6286#[cfg_attr(feature = "bindings", derive(TS))]
6287pub struct Revoke {
6288    /// Privileges to revoke (e.g., SELECT, INSERT, UPDATE(col1, col2))
6289    pub privileges: Vec<Privilege>,
6290    /// Object kind (TABLE, SCHEMA, FUNCTION, etc.)
6291    pub kind: Option<String>,
6292    /// The object to revoke from
6293    pub securable: Identifier,
6294    /// Function parameter types (for FUNCTION kind)
6295    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6296    pub function_params: Vec<String>,
6297    /// The grantees
6298    pub principals: Vec<GrantPrincipal>,
6299    /// GRANT OPTION FOR
6300    pub grant_option: bool,
6301    /// CASCADE
6302    pub cascade: bool,
6303    /// RESTRICT
6304    #[serde(default)]
6305    pub restrict: bool,
6306}
6307
6308/// COMMENT ON statement
6309#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6310#[cfg_attr(feature = "bindings", derive(TS))]
6311pub struct Comment {
6312    /// The object being commented on
6313    pub this: Expression,
6314    /// The object kind (COLUMN, TABLE, DATABASE, etc.)
6315    pub kind: String,
6316    /// The comment text expression
6317    pub expression: Expression,
6318    /// IF EXISTS clause
6319    pub exists: bool,
6320    /// MATERIALIZED keyword
6321    pub materialized: bool,
6322}
6323
6324// ============================================================================
6325// Phase 4: Additional DDL Statements
6326// ============================================================================
6327
6328/// ALTER VIEW statement
6329#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6330#[cfg_attr(feature = "bindings", derive(TS))]
6331pub struct AlterView {
6332    pub name: TableRef,
6333    pub actions: Vec<AlterViewAction>,
6334    /// MySQL: ALGORITHM = MERGE|TEMPTABLE|UNDEFINED
6335    #[serde(default, skip_serializing_if = "Option::is_none")]
6336    pub algorithm: Option<String>,
6337    /// MySQL: DEFINER = 'user'@'host'
6338    #[serde(default, skip_serializing_if = "Option::is_none")]
6339    pub definer: Option<String>,
6340    /// MySQL: SQL SECURITY = DEFINER|INVOKER
6341    #[serde(default, skip_serializing_if = "Option::is_none")]
6342    pub sql_security: Option<String>,
6343    /// TSQL: WITH option (SCHEMABINDING, ENCRYPTION, VIEW_METADATA)
6344    #[serde(default, skip_serializing_if = "Option::is_none")]
6345    pub with_option: Option<String>,
6346    /// Hive: Column aliases with optional comments: (c1 COMMENT 'text', c2)
6347    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6348    pub columns: Vec<ViewColumn>,
6349}
6350
6351/// Actions for ALTER VIEW
6352#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6353#[cfg_attr(feature = "bindings", derive(TS))]
6354pub enum AlterViewAction {
6355    /// Rename the view
6356    Rename(TableRef),
6357    /// Change owner
6358    OwnerTo(Identifier),
6359    /// Set schema
6360    SetSchema(Identifier),
6361    /// Set authorization (Trino/Presto)
6362    SetAuthorization(String),
6363    /// Alter column
6364    AlterColumn {
6365        name: Identifier,
6366        action: AlterColumnAction,
6367    },
6368    /// Redefine view as query (SELECT, UNION, etc.)
6369    AsSelect(Box<Expression>),
6370    /// Hive: SET TBLPROPERTIES ('key'='value', ...)
6371    SetTblproperties(Vec<(String, String)>),
6372    /// Hive: UNSET TBLPROPERTIES ('key1', 'key2', ...)
6373    UnsetTblproperties(Vec<String>),
6374}
6375
6376impl AlterView {
6377    pub fn new(name: impl Into<String>) -> Self {
6378        Self {
6379            name: TableRef::new(name),
6380            actions: Vec::new(),
6381            algorithm: None,
6382            definer: None,
6383            sql_security: None,
6384            with_option: None,
6385            columns: Vec::new(),
6386        }
6387    }
6388}
6389
6390/// ALTER INDEX statement
6391#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6392#[cfg_attr(feature = "bindings", derive(TS))]
6393pub struct AlterIndex {
6394    pub name: Identifier,
6395    pub table: Option<TableRef>,
6396    pub actions: Vec<AlterIndexAction>,
6397}
6398
6399/// Actions for ALTER INDEX
6400#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6401#[cfg_attr(feature = "bindings", derive(TS))]
6402pub enum AlterIndexAction {
6403    /// Rename the index
6404    Rename(Identifier),
6405    /// Set tablespace
6406    SetTablespace(Identifier),
6407    /// Set visibility (MySQL)
6408    Visible(bool),
6409}
6410
6411impl AlterIndex {
6412    pub fn new(name: impl Into<String>) -> Self {
6413        Self {
6414            name: Identifier::new(name),
6415            table: None,
6416            actions: Vec::new(),
6417        }
6418    }
6419}
6420
6421/// CREATE SCHEMA statement
6422#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6423#[cfg_attr(feature = "bindings", derive(TS))]
6424pub struct CreateSchema {
6425    pub name: Identifier,
6426    pub if_not_exists: bool,
6427    pub authorization: Option<Identifier>,
6428    #[serde(default)]
6429    pub clone_from: Option<Identifier>,
6430    /// AT/BEFORE clause for time travel (Snowflake)
6431    #[serde(default)]
6432    pub at_clause: Option<Expression>,
6433    /// Schema properties like DEFAULT COLLATE
6434    #[serde(default)]
6435    pub properties: Vec<Expression>,
6436    /// Leading comments before the statement
6437    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6438    pub leading_comments: Vec<String>,
6439}
6440
6441impl CreateSchema {
6442    pub fn new(name: impl Into<String>) -> Self {
6443        Self {
6444            name: Identifier::new(name),
6445            if_not_exists: false,
6446            authorization: None,
6447            clone_from: None,
6448            at_clause: None,
6449            properties: Vec::new(),
6450            leading_comments: Vec::new(),
6451        }
6452    }
6453}
6454
6455/// DROP SCHEMA statement
6456#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6457#[cfg_attr(feature = "bindings", derive(TS))]
6458pub struct DropSchema {
6459    pub name: Identifier,
6460    pub if_exists: bool,
6461    pub cascade: bool,
6462}
6463
6464impl DropSchema {
6465    pub fn new(name: impl Into<String>) -> Self {
6466        Self {
6467            name: Identifier::new(name),
6468            if_exists: false,
6469            cascade: false,
6470        }
6471    }
6472}
6473
6474/// DROP NAMESPACE statement (Spark/Databricks - alias for DROP SCHEMA)
6475#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6476#[cfg_attr(feature = "bindings", derive(TS))]
6477pub struct DropNamespace {
6478    pub name: Identifier,
6479    pub if_exists: bool,
6480    pub cascade: bool,
6481}
6482
6483impl DropNamespace {
6484    pub fn new(name: impl Into<String>) -> Self {
6485        Self {
6486            name: Identifier::new(name),
6487            if_exists: false,
6488            cascade: false,
6489        }
6490    }
6491}
6492
6493/// CREATE DATABASE statement
6494#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6495#[cfg_attr(feature = "bindings", derive(TS))]
6496pub struct CreateDatabase {
6497    pub name: Identifier,
6498    pub if_not_exists: bool,
6499    pub options: Vec<DatabaseOption>,
6500    /// Snowflake CLONE source
6501    #[serde(default)]
6502    pub clone_from: Option<Identifier>,
6503    /// AT/BEFORE clause for time travel (Snowflake)
6504    #[serde(default)]
6505    pub at_clause: Option<Expression>,
6506}
6507
6508/// Database option
6509#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6510#[cfg_attr(feature = "bindings", derive(TS))]
6511pub enum DatabaseOption {
6512    CharacterSet(String),
6513    Collate(String),
6514    Owner(Identifier),
6515    Template(Identifier),
6516    Encoding(String),
6517    Location(String),
6518}
6519
6520impl CreateDatabase {
6521    pub fn new(name: impl Into<String>) -> Self {
6522        Self {
6523            name: Identifier::new(name),
6524            if_not_exists: false,
6525            options: Vec::new(),
6526            clone_from: None,
6527            at_clause: None,
6528        }
6529    }
6530}
6531
6532/// DROP DATABASE statement
6533#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6534#[cfg_attr(feature = "bindings", derive(TS))]
6535pub struct DropDatabase {
6536    pub name: Identifier,
6537    pub if_exists: bool,
6538}
6539
6540impl DropDatabase {
6541    pub fn new(name: impl Into<String>) -> Self {
6542        Self {
6543            name: Identifier::new(name),
6544            if_exists: false,
6545        }
6546    }
6547}
6548
6549/// CREATE FUNCTION statement
6550#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6551#[cfg_attr(feature = "bindings", derive(TS))]
6552pub struct CreateFunction {
6553    pub name: TableRef,
6554    pub parameters: Vec<FunctionParameter>,
6555    pub return_type: Option<DataType>,
6556    pub body: Option<FunctionBody>,
6557    pub or_replace: bool,
6558    pub if_not_exists: bool,
6559    pub temporary: bool,
6560    pub language: Option<String>,
6561    pub deterministic: Option<bool>,
6562    pub returns_null_on_null_input: Option<bool>,
6563    pub security: Option<FunctionSecurity>,
6564    /// Whether parentheses were present in the original syntax
6565    #[serde(default = "default_true")]
6566    pub has_parens: bool,
6567    /// SQL data access characteristic (CONTAINS SQL, READS SQL DATA, etc.)
6568    #[serde(default)]
6569    pub sql_data_access: Option<SqlDataAccess>,
6570    /// TSQL: RETURNS @var TABLE (col_defs) - stores the variable name and column definitions as raw string
6571    #[serde(default, skip_serializing_if = "Option::is_none")]
6572    pub returns_table_body: Option<String>,
6573    /// True if LANGUAGE clause appears before RETURNS clause
6574    #[serde(default)]
6575    pub language_first: bool,
6576    /// PostgreSQL SET options: SET key = value, SET key FROM CURRENT
6577    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6578    pub set_options: Vec<FunctionSetOption>,
6579    /// True if STRICT was used instead of RETURNS NULL ON NULL INPUT
6580    #[serde(default)]
6581    pub strict: bool,
6582    /// BigQuery: OPTIONS (key=value, ...)
6583    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6584    pub options: Vec<Expression>,
6585    /// BigQuery: True if this is a TABLE FUNCTION (CREATE TABLE FUNCTION)
6586    #[serde(default)]
6587    pub is_table_function: bool,
6588    /// Original order of function properties (SET, AS, LANGUAGE, etc.)
6589    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6590    pub property_order: Vec<FunctionPropertyKind>,
6591    /// Databricks: ENVIRONMENT (dependencies = '...', environment_version = '...')
6592    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6593    pub environment: Vec<Expression>,
6594}
6595
6596/// A SET option in CREATE FUNCTION (PostgreSQL)
6597#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6598#[cfg_attr(feature = "bindings", derive(TS))]
6599pub struct FunctionSetOption {
6600    pub name: String,
6601    pub value: FunctionSetValue,
6602}
6603
6604/// The value of a SET option
6605#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6606#[cfg_attr(feature = "bindings", derive(TS))]
6607pub enum FunctionSetValue {
6608    /// SET key = value (use_to = false) or SET key TO value (use_to = true)
6609    Value { value: String, use_to: bool },
6610    /// SET key FROM CURRENT
6611    FromCurrent,
6612}
6613
6614/// SQL data access characteristics for functions
6615#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6616#[cfg_attr(feature = "bindings", derive(TS))]
6617pub enum SqlDataAccess {
6618    /// NO SQL
6619    NoSql,
6620    /// CONTAINS SQL
6621    ContainsSql,
6622    /// READS SQL DATA
6623    ReadsSqlData,
6624    /// MODIFIES SQL DATA
6625    ModifiesSqlData,
6626}
6627
6628/// Types of properties in CREATE FUNCTION for tracking their original order
6629#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6630#[cfg_attr(feature = "bindings", derive(TS))]
6631pub enum FunctionPropertyKind {
6632    /// SET option
6633    Set,
6634    /// AS body
6635    As,
6636    /// LANGUAGE clause
6637    Language,
6638    /// IMMUTABLE/VOLATILE/STABLE (determinism)
6639    Determinism,
6640    /// CALLED ON NULL INPUT / RETURNS NULL ON NULL INPUT / STRICT
6641    NullInput,
6642    /// SECURITY DEFINER/INVOKER
6643    Security,
6644    /// SQL data access (CONTAINS SQL, READS SQL DATA, etc.)
6645    SqlDataAccess,
6646    /// OPTIONS clause (BigQuery)
6647    Options,
6648    /// ENVIRONMENT clause (Databricks)
6649    Environment,
6650}
6651
6652/// Function parameter
6653#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6654#[cfg_attr(feature = "bindings", derive(TS))]
6655pub struct FunctionParameter {
6656    pub name: Option<Identifier>,
6657    pub data_type: DataType,
6658    pub mode: Option<ParameterMode>,
6659    pub default: Option<Expression>,
6660}
6661
6662/// Parameter mode (IN, OUT, INOUT)
6663#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6664#[cfg_attr(feature = "bindings", derive(TS))]
6665pub enum ParameterMode {
6666    In,
6667    Out,
6668    InOut,
6669}
6670
6671/// Function body
6672#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6673#[cfg_attr(feature = "bindings", derive(TS))]
6674pub enum FunctionBody {
6675    /// AS $$ ... $$ (dollar-quoted)
6676    Block(String),
6677    /// AS 'string' (single-quoted string literal body)
6678    StringLiteral(String),
6679    /// AS 'expression'
6680    Expression(Expression),
6681    /// EXTERNAL NAME 'library'
6682    External(String),
6683    /// RETURN expression
6684    Return(Expression),
6685    /// BEGIN ... END block with parsed statements
6686    Statements(Vec<Expression>),
6687    /// AS $$...$$ or $tag$...$tag$ (dollar-quoted with optional tag)
6688    /// Stores (content, optional_tag)
6689    DollarQuoted {
6690        content: String,
6691        tag: Option<String>,
6692    },
6693}
6694
6695/// Function security (DEFINER, INVOKER, or NONE)
6696#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6697#[cfg_attr(feature = "bindings", derive(TS))]
6698pub enum FunctionSecurity {
6699    Definer,
6700    Invoker,
6701    /// StarRocks/MySQL: SECURITY NONE
6702    None,
6703}
6704
6705impl CreateFunction {
6706    pub fn new(name: impl Into<String>) -> Self {
6707        Self {
6708            name: TableRef::new(name),
6709            parameters: Vec::new(),
6710            return_type: None,
6711            body: None,
6712            or_replace: false,
6713            if_not_exists: false,
6714            temporary: false,
6715            language: None,
6716            deterministic: None,
6717            returns_null_on_null_input: None,
6718            security: None,
6719            has_parens: true,
6720            sql_data_access: None,
6721            returns_table_body: None,
6722            language_first: false,
6723            set_options: Vec::new(),
6724            strict: false,
6725            options: Vec::new(),
6726            is_table_function: false,
6727            property_order: Vec::new(),
6728            environment: Vec::new(),
6729        }
6730    }
6731}
6732
6733/// DROP FUNCTION statement
6734#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6735#[cfg_attr(feature = "bindings", derive(TS))]
6736pub struct DropFunction {
6737    pub name: TableRef,
6738    pub parameters: Option<Vec<DataType>>,
6739    pub if_exists: bool,
6740    pub cascade: bool,
6741}
6742
6743impl DropFunction {
6744    pub fn new(name: impl Into<String>) -> Self {
6745        Self {
6746            name: TableRef::new(name),
6747            parameters: None,
6748            if_exists: false,
6749            cascade: false,
6750        }
6751    }
6752}
6753
6754/// CREATE PROCEDURE statement
6755#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6756#[cfg_attr(feature = "bindings", derive(TS))]
6757pub struct CreateProcedure {
6758    pub name: TableRef,
6759    pub parameters: Vec<FunctionParameter>,
6760    pub body: Option<FunctionBody>,
6761    pub or_replace: bool,
6762    pub if_not_exists: bool,
6763    pub language: Option<String>,
6764    pub security: Option<FunctionSecurity>,
6765    /// Return type (Snowflake: RETURNS OBJECT, RETURNS VARCHAR, etc.)
6766    #[serde(default)]
6767    pub return_type: Option<DataType>,
6768    /// Execution context (EXECUTE AS CALLER, EXECUTE AS OWNER)
6769    #[serde(default)]
6770    pub execute_as: Option<String>,
6771    /// TSQL WITH options (ENCRYPTION, RECOMPILE, SCHEMABINDING, etc.)
6772    #[serde(default, skip_serializing_if = "Vec::is_empty")]
6773    pub with_options: Vec<String>,
6774    /// Whether the parameter list had parentheses (false for TSQL procedures without parens)
6775    #[serde(default = "default_true", skip_serializing_if = "is_true")]
6776    pub has_parens: bool,
6777    /// Whether the short form PROC was used (instead of PROCEDURE)
6778    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
6779    pub use_proc_keyword: bool,
6780}
6781
6782impl CreateProcedure {
6783    pub fn new(name: impl Into<String>) -> Self {
6784        Self {
6785            name: TableRef::new(name),
6786            parameters: Vec::new(),
6787            body: None,
6788            or_replace: false,
6789            if_not_exists: false,
6790            language: None,
6791            security: None,
6792            return_type: None,
6793            execute_as: None,
6794            with_options: Vec::new(),
6795            has_parens: true,
6796            use_proc_keyword: false,
6797        }
6798    }
6799}
6800
6801/// DROP PROCEDURE statement
6802#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6803#[cfg_attr(feature = "bindings", derive(TS))]
6804pub struct DropProcedure {
6805    pub name: TableRef,
6806    pub parameters: Option<Vec<DataType>>,
6807    pub if_exists: bool,
6808    pub cascade: bool,
6809}
6810
6811impl DropProcedure {
6812    pub fn new(name: impl Into<String>) -> Self {
6813        Self {
6814            name: TableRef::new(name),
6815            parameters: None,
6816            if_exists: false,
6817            cascade: false,
6818        }
6819    }
6820}
6821
6822/// Sequence property tag for ordering
6823#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6824#[cfg_attr(feature = "bindings", derive(TS))]
6825pub enum SeqPropKind {
6826    Start,
6827    Increment,
6828    Minvalue,
6829    Maxvalue,
6830    Cache,
6831    Cycle,
6832    NoCycle,
6833    OwnedBy,
6834    Order,
6835    NoOrder,
6836    Comment,
6837}
6838
6839/// CREATE SEQUENCE statement
6840#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6841#[cfg_attr(feature = "bindings", derive(TS))]
6842pub struct CreateSequence {
6843    pub name: TableRef,
6844    pub if_not_exists: bool,
6845    pub temporary: bool,
6846    pub increment: Option<i64>,
6847    pub minvalue: Option<SequenceBound>,
6848    pub maxvalue: Option<SequenceBound>,
6849    pub start: Option<i64>,
6850    pub cache: Option<i64>,
6851    pub cycle: bool,
6852    pub owned_by: Option<TableRef>,
6853    /// Snowflake: ORDER or NOORDER (true = ORDER, false = NOORDER, None = not specified)
6854    #[serde(default)]
6855    pub order: Option<bool>,
6856    /// Snowflake: COMMENT = 'value'
6857    #[serde(default)]
6858    pub comment: Option<String>,
6859    /// Tracks the order in which properties appeared in the source
6860    #[serde(default)]
6861    pub property_order: Vec<SeqPropKind>,
6862}
6863
6864/// Sequence bound (value or NO MINVALUE/NO MAXVALUE)
6865#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6866#[cfg_attr(feature = "bindings", derive(TS))]
6867pub enum SequenceBound {
6868    Value(i64),
6869    None,
6870}
6871
6872impl CreateSequence {
6873    pub fn new(name: impl Into<String>) -> Self {
6874        Self {
6875            name: TableRef::new(name),
6876            if_not_exists: false,
6877            temporary: false,
6878            increment: None,
6879            minvalue: None,
6880            maxvalue: None,
6881            start: None,
6882            cache: None,
6883            cycle: false,
6884            owned_by: None,
6885            order: None,
6886            comment: None,
6887            property_order: Vec::new(),
6888        }
6889    }
6890}
6891
6892/// DROP SEQUENCE statement
6893#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6894#[cfg_attr(feature = "bindings", derive(TS))]
6895pub struct DropSequence {
6896    pub name: TableRef,
6897    pub if_exists: bool,
6898    pub cascade: bool,
6899}
6900
6901impl DropSequence {
6902    pub fn new(name: impl Into<String>) -> Self {
6903        Self {
6904            name: TableRef::new(name),
6905            if_exists: false,
6906            cascade: false,
6907        }
6908    }
6909}
6910
6911/// ALTER SEQUENCE statement
6912#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6913#[cfg_attr(feature = "bindings", derive(TS))]
6914pub struct AlterSequence {
6915    pub name: TableRef,
6916    pub if_exists: bool,
6917    pub increment: Option<i64>,
6918    pub minvalue: Option<SequenceBound>,
6919    pub maxvalue: Option<SequenceBound>,
6920    pub start: Option<i64>,
6921    pub restart: Option<Option<i64>>,
6922    pub cache: Option<i64>,
6923    pub cycle: Option<bool>,
6924    pub owned_by: Option<Option<TableRef>>,
6925}
6926
6927impl AlterSequence {
6928    pub fn new(name: impl Into<String>) -> Self {
6929        Self {
6930            name: TableRef::new(name),
6931            if_exists: false,
6932            increment: None,
6933            minvalue: None,
6934            maxvalue: None,
6935            start: None,
6936            restart: None,
6937            cache: None,
6938            cycle: None,
6939            owned_by: None,
6940        }
6941    }
6942}
6943
6944/// CREATE TRIGGER statement
6945#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6946#[cfg_attr(feature = "bindings", derive(TS))]
6947pub struct CreateTrigger {
6948    pub name: Identifier,
6949    pub table: TableRef,
6950    pub timing: TriggerTiming,
6951    pub events: Vec<TriggerEvent>,
6952    pub for_each: TriggerForEach,
6953    pub when: Option<Expression>,
6954    pub body: TriggerBody,
6955    pub or_replace: bool,
6956    pub constraint: bool,
6957    pub deferrable: Option<bool>,
6958    pub initially_deferred: Option<bool>,
6959    pub referencing: Option<TriggerReferencing>,
6960}
6961
6962/// Trigger timing (BEFORE, AFTER, INSTEAD OF)
6963#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6964#[cfg_attr(feature = "bindings", derive(TS))]
6965pub enum TriggerTiming {
6966    Before,
6967    After,
6968    InsteadOf,
6969}
6970
6971/// Trigger event (INSERT, UPDATE, DELETE, TRUNCATE)
6972#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6973#[cfg_attr(feature = "bindings", derive(TS))]
6974pub enum TriggerEvent {
6975    Insert,
6976    Update(Option<Vec<Identifier>>),
6977    Delete,
6978    Truncate,
6979}
6980
6981/// Trigger FOR EACH clause
6982#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6983#[cfg_attr(feature = "bindings", derive(TS))]
6984pub enum TriggerForEach {
6985    Row,
6986    Statement,
6987}
6988
6989/// Trigger body
6990#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6991#[cfg_attr(feature = "bindings", derive(TS))]
6992pub enum TriggerBody {
6993    /// EXECUTE FUNCTION/PROCEDURE name(args)
6994    Execute {
6995        function: TableRef,
6996        args: Vec<Expression>,
6997    },
6998    /// BEGIN ... END block
6999    Block(String),
7000}
7001
7002/// Trigger REFERENCING clause
7003#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7004#[cfg_attr(feature = "bindings", derive(TS))]
7005pub struct TriggerReferencing {
7006    pub old_table: Option<Identifier>,
7007    pub new_table: Option<Identifier>,
7008    pub old_row: Option<Identifier>,
7009    pub new_row: Option<Identifier>,
7010}
7011
7012impl CreateTrigger {
7013    pub fn new(name: impl Into<String>, table: impl Into<String>) -> Self {
7014        Self {
7015            name: Identifier::new(name),
7016            table: TableRef::new(table),
7017            timing: TriggerTiming::Before,
7018            events: Vec::new(),
7019            for_each: TriggerForEach::Row,
7020            when: None,
7021            body: TriggerBody::Execute {
7022                function: TableRef::new(""),
7023                args: Vec::new(),
7024            },
7025            or_replace: false,
7026            constraint: false,
7027            deferrable: None,
7028            initially_deferred: None,
7029            referencing: None,
7030        }
7031    }
7032}
7033
7034/// DROP TRIGGER statement
7035#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7036#[cfg_attr(feature = "bindings", derive(TS))]
7037pub struct DropTrigger {
7038    pub name: Identifier,
7039    pub table: Option<TableRef>,
7040    pub if_exists: bool,
7041    pub cascade: bool,
7042}
7043
7044impl DropTrigger {
7045    pub fn new(name: impl Into<String>) -> Self {
7046        Self {
7047            name: Identifier::new(name),
7048            table: None,
7049            if_exists: false,
7050            cascade: false,
7051        }
7052    }
7053}
7054
7055/// CREATE TYPE statement
7056#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7057#[cfg_attr(feature = "bindings", derive(TS))]
7058pub struct CreateType {
7059    pub name: TableRef,
7060    pub definition: TypeDefinition,
7061    pub if_not_exists: bool,
7062}
7063
7064/// Type definition
7065#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7066#[cfg_attr(feature = "bindings", derive(TS))]
7067pub enum TypeDefinition {
7068    /// ENUM type: CREATE TYPE name AS ENUM ('val1', 'val2', ...)
7069    Enum(Vec<String>),
7070    /// Composite type: CREATE TYPE name AS (field1 type1, field2 type2, ...)
7071    Composite(Vec<TypeAttribute>),
7072    /// Range type: CREATE TYPE name AS RANGE (SUBTYPE = type, ...)
7073    Range {
7074        subtype: DataType,
7075        subtype_diff: Option<String>,
7076        canonical: Option<String>,
7077    },
7078    /// Base type (for advanced usage)
7079    Base {
7080        input: String,
7081        output: String,
7082        internallength: Option<i32>,
7083    },
7084    /// Domain type
7085    Domain {
7086        base_type: DataType,
7087        default: Option<Expression>,
7088        constraints: Vec<DomainConstraint>,
7089    },
7090}
7091
7092/// Type attribute for composite types
7093#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7094#[cfg_attr(feature = "bindings", derive(TS))]
7095pub struct TypeAttribute {
7096    pub name: Identifier,
7097    pub data_type: DataType,
7098    pub collate: Option<Identifier>,
7099}
7100
7101/// Domain constraint
7102#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7103#[cfg_attr(feature = "bindings", derive(TS))]
7104pub struct DomainConstraint {
7105    pub name: Option<Identifier>,
7106    pub check: Expression,
7107}
7108
7109impl CreateType {
7110    pub fn new_enum(name: impl Into<String>, values: Vec<String>) -> Self {
7111        Self {
7112            name: TableRef::new(name),
7113            definition: TypeDefinition::Enum(values),
7114            if_not_exists: false,
7115        }
7116    }
7117
7118    pub fn new_composite(name: impl Into<String>, attributes: Vec<TypeAttribute>) -> Self {
7119        Self {
7120            name: TableRef::new(name),
7121            definition: TypeDefinition::Composite(attributes),
7122            if_not_exists: false,
7123        }
7124    }
7125}
7126
7127/// DROP TYPE statement
7128#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7129#[cfg_attr(feature = "bindings", derive(TS))]
7130pub struct DropType {
7131    pub name: TableRef,
7132    pub if_exists: bool,
7133    pub cascade: bool,
7134}
7135
7136impl DropType {
7137    pub fn new(name: impl Into<String>) -> Self {
7138        Self {
7139            name: TableRef::new(name),
7140            if_exists: false,
7141            cascade: false,
7142        }
7143    }
7144}
7145
7146/// DESCRIBE statement - shows table structure or query plan
7147#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7148#[cfg_attr(feature = "bindings", derive(TS))]
7149pub struct Describe {
7150    /// The target to describe (table name or query)
7151    pub target: Expression,
7152    /// EXTENDED format
7153    pub extended: bool,
7154    /// FORMATTED format
7155    pub formatted: bool,
7156    /// Object kind (e.g., "SEMANTIC VIEW", "TABLE", etc.)
7157    #[serde(default)]
7158    pub kind: Option<String>,
7159    /// Properties like type=stage
7160    #[serde(default)]
7161    pub properties: Vec<(String, String)>,
7162    /// Style keyword (e.g., "ANALYZE", "HISTORY")
7163    #[serde(default, skip_serializing_if = "Option::is_none")]
7164    pub style: Option<String>,
7165    /// Partition specification for DESCRIBE PARTITION
7166    #[serde(default)]
7167    pub partition: Option<Box<Expression>>,
7168    /// Leading comments before the statement
7169    #[serde(default)]
7170    pub leading_comments: Vec<String>,
7171}
7172
7173impl Describe {
7174    pub fn new(target: Expression) -> Self {
7175        Self {
7176            target,
7177            extended: false,
7178            formatted: false,
7179            kind: None,
7180            properties: Vec::new(),
7181            style: None,
7182            partition: None,
7183            leading_comments: Vec::new(),
7184        }
7185    }
7186}
7187
7188/// SHOW statement - displays database objects
7189#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7190#[cfg_attr(feature = "bindings", derive(TS))]
7191pub struct Show {
7192    /// The thing to show (DATABASES, TABLES, SCHEMAS, etc.)
7193    pub this: String,
7194    /// Whether TERSE was specified
7195    #[serde(default)]
7196    pub terse: bool,
7197    /// Whether HISTORY was specified
7198    #[serde(default)]
7199    pub history: bool,
7200    /// LIKE pattern
7201    pub like: Option<Expression>,
7202    /// IN scope kind (ACCOUNT, DATABASE, SCHEMA, TABLE)
7203    pub scope_kind: Option<String>,
7204    /// IN scope object
7205    pub scope: Option<Expression>,
7206    /// STARTS WITH pattern
7207    pub starts_with: Option<Expression>,
7208    /// LIMIT clause
7209    pub limit: Option<Box<Limit>>,
7210    /// FROM clause (for specific object)
7211    pub from: Option<Expression>,
7212    /// WHERE clause (MySQL: SHOW STATUS WHERE ...)
7213    #[serde(default, skip_serializing_if = "Option::is_none")]
7214    pub where_clause: Option<Expression>,
7215    /// FOR target (MySQL: SHOW GRANTS FOR user, SHOW PROFILE ... FOR QUERY n)
7216    #[serde(default, skip_serializing_if = "Option::is_none")]
7217    pub for_target: Option<Expression>,
7218    /// Second FROM clause (MySQL: SHOW COLUMNS FROM tbl FROM db)
7219    #[serde(default, skip_serializing_if = "Option::is_none")]
7220    pub db: Option<Expression>,
7221    /// Target identifier (MySQL: engine name in SHOW ENGINE, table in SHOW COLUMNS FROM)
7222    #[serde(default, skip_serializing_if = "Option::is_none")]
7223    pub target: Option<Expression>,
7224    /// MUTEX flag for SHOW ENGINE (true=MUTEX, false=STATUS, None=neither)
7225    #[serde(default, skip_serializing_if = "Option::is_none")]
7226    pub mutex: Option<bool>,
7227    /// WITH PRIVILEGES clause (Snowflake: SHOW ... WITH PRIVILEGES USAGE, MODIFY)
7228    #[serde(default, skip_serializing_if = "Vec::is_empty")]
7229    pub privileges: Vec<String>,
7230}
7231
7232impl Show {
7233    pub fn new(this: impl Into<String>) -> Self {
7234        Self {
7235            this: this.into(),
7236            terse: false,
7237            history: false,
7238            like: None,
7239            scope_kind: None,
7240            scope: None,
7241            starts_with: None,
7242            limit: None,
7243            from: None,
7244            where_clause: None,
7245            for_target: None,
7246            db: None,
7247            target: None,
7248            mutex: None,
7249            privileges: Vec::new(),
7250        }
7251    }
7252}
7253
7254/// Represent an explicit parenthesized expression for grouping precedence.
7255///
7256/// Preserves user-written parentheses so that `(a + b) * c` round-trips
7257/// correctly instead of being flattened to `a + b * c`.
7258#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7259#[cfg_attr(feature = "bindings", derive(TS))]
7260pub struct Paren {
7261    /// The inner expression wrapped by parentheses.
7262    pub this: Expression,
7263    #[serde(default)]
7264    pub trailing_comments: Vec<String>,
7265}
7266
7267/// Expression annotated with trailing comments (for round-trip preservation)
7268#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7269#[cfg_attr(feature = "bindings", derive(TS))]
7270pub struct Annotated {
7271    pub this: Expression,
7272    pub trailing_comments: Vec<String>,
7273}
7274
7275
7276// === BATCH GENERATED STRUCT DEFINITIONS ===
7277// Generated from Python sqlglot expressions.py
7278
7279/// Refresh
7280#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7281#[cfg_attr(feature = "bindings", derive(TS))]
7282pub struct Refresh {
7283    pub this: Box<Expression>,
7284    pub kind: String,
7285}
7286
7287/// LockingStatement
7288#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7289#[cfg_attr(feature = "bindings", derive(TS))]
7290pub struct LockingStatement {
7291    pub this: Box<Expression>,
7292    pub expression: Box<Expression>,
7293}
7294
7295/// SequenceProperties
7296#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7297#[cfg_attr(feature = "bindings", derive(TS))]
7298pub struct SequenceProperties {
7299    #[serde(default)]
7300    pub increment: Option<Box<Expression>>,
7301    #[serde(default)]
7302    pub minvalue: Option<Box<Expression>>,
7303    #[serde(default)]
7304    pub maxvalue: Option<Box<Expression>>,
7305    #[serde(default)]
7306    pub cache: Option<Box<Expression>>,
7307    #[serde(default)]
7308    pub start: Option<Box<Expression>>,
7309    #[serde(default)]
7310    pub owned: Option<Box<Expression>>,
7311    #[serde(default)]
7312    pub options: Vec<Expression>,
7313}
7314
7315/// TruncateTable
7316#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7317#[cfg_attr(feature = "bindings", derive(TS))]
7318pub struct TruncateTable {
7319    #[serde(default)]
7320    pub expressions: Vec<Expression>,
7321    #[serde(default)]
7322    pub is_database: Option<Box<Expression>>,
7323    #[serde(default)]
7324    pub exists: bool,
7325    #[serde(default)]
7326    pub only: Option<Box<Expression>>,
7327    #[serde(default)]
7328    pub cluster: Option<Box<Expression>>,
7329    #[serde(default)]
7330    pub identity: Option<Box<Expression>>,
7331    #[serde(default)]
7332    pub option: Option<Box<Expression>>,
7333    #[serde(default)]
7334    pub partition: Option<Box<Expression>>,
7335}
7336
7337/// Clone
7338#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7339#[cfg_attr(feature = "bindings", derive(TS))]
7340pub struct Clone {
7341    pub this: Box<Expression>,
7342    #[serde(default)]
7343    pub shallow: Option<Box<Expression>>,
7344    #[serde(default)]
7345    pub copy: Option<Box<Expression>>,
7346}
7347
7348/// Attach
7349#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7350#[cfg_attr(feature = "bindings", derive(TS))]
7351pub struct Attach {
7352    pub this: Box<Expression>,
7353    #[serde(default)]
7354    pub exists: bool,
7355    #[serde(default)]
7356    pub expressions: Vec<Expression>,
7357}
7358
7359/// Detach
7360#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7361#[cfg_attr(feature = "bindings", derive(TS))]
7362pub struct Detach {
7363    pub this: Box<Expression>,
7364    #[serde(default)]
7365    pub exists: bool,
7366}
7367
7368/// Install
7369#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7370#[cfg_attr(feature = "bindings", derive(TS))]
7371pub struct Install {
7372    pub this: Box<Expression>,
7373    #[serde(default)]
7374    pub from_: Option<Box<Expression>>,
7375    #[serde(default)]
7376    pub force: Option<Box<Expression>>,
7377}
7378
7379/// Summarize
7380#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7381#[cfg_attr(feature = "bindings", derive(TS))]
7382pub struct Summarize {
7383    pub this: Box<Expression>,
7384    #[serde(default)]
7385    pub table: Option<Box<Expression>>,
7386}
7387
7388/// Declare
7389#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7390#[cfg_attr(feature = "bindings", derive(TS))]
7391pub struct Declare {
7392    #[serde(default)]
7393    pub expressions: Vec<Expression>,
7394}
7395
7396/// DeclareItem
7397#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7398#[cfg_attr(feature = "bindings", derive(TS))]
7399pub struct DeclareItem {
7400    pub this: Box<Expression>,
7401    #[serde(default)]
7402    pub kind: Option<String>,
7403    #[serde(default)]
7404    pub default: Option<Box<Expression>>,
7405    #[serde(default)]
7406    pub has_as: bool,
7407    /// BigQuery: additional variable names in multi-variable DECLARE (DECLARE X, Y, Z INT64)
7408    #[serde(default, skip_serializing_if = "Vec::is_empty")]
7409    pub additional_names: Vec<Expression>,
7410}
7411
7412/// Set
7413#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7414#[cfg_attr(feature = "bindings", derive(TS))]
7415pub struct Set {
7416    #[serde(default)]
7417    pub expressions: Vec<Expression>,
7418    #[serde(default)]
7419    pub unset: Option<Box<Expression>>,
7420    #[serde(default)]
7421    pub tag: Option<Box<Expression>>,
7422}
7423
7424/// Heredoc
7425#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7426#[cfg_attr(feature = "bindings", derive(TS))]
7427pub struct Heredoc {
7428    pub this: Box<Expression>,
7429    #[serde(default)]
7430    pub tag: Option<Box<Expression>>,
7431}
7432
7433/// QueryBand
7434#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7435#[cfg_attr(feature = "bindings", derive(TS))]
7436pub struct QueryBand {
7437    pub this: Box<Expression>,
7438    #[serde(default)]
7439    pub scope: Option<Box<Expression>>,
7440    #[serde(default)]
7441    pub update: Option<Box<Expression>>,
7442}
7443
7444/// UserDefinedFunction
7445#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7446#[cfg_attr(feature = "bindings", derive(TS))]
7447pub struct UserDefinedFunction {
7448    pub this: Box<Expression>,
7449    #[serde(default)]
7450    pub expressions: Vec<Expression>,
7451    #[serde(default)]
7452    pub wrapped: Option<Box<Expression>>,
7453}
7454
7455/// RecursiveWithSearch
7456#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7457#[cfg_attr(feature = "bindings", derive(TS))]
7458pub struct RecursiveWithSearch {
7459    pub kind: String,
7460    pub this: Box<Expression>,
7461    pub expression: Box<Expression>,
7462    #[serde(default)]
7463    pub using: Option<Box<Expression>>,
7464}
7465
7466/// ProjectionDef
7467#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7468#[cfg_attr(feature = "bindings", derive(TS))]
7469pub struct ProjectionDef {
7470    pub this: Box<Expression>,
7471    pub expression: Box<Expression>,
7472}
7473
7474/// TableAlias
7475#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7476#[cfg_attr(feature = "bindings", derive(TS))]
7477pub struct TableAlias {
7478    #[serde(default)]
7479    pub this: Option<Box<Expression>>,
7480    #[serde(default)]
7481    pub columns: Vec<Expression>,
7482}
7483
7484/// ByteString
7485#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7486#[cfg_attr(feature = "bindings", derive(TS))]
7487pub struct ByteString {
7488    pub this: Box<Expression>,
7489    #[serde(default)]
7490    pub is_bytes: Option<Box<Expression>>,
7491}
7492
7493/// HexStringExpr - Hex string expression (not literal)
7494/// BigQuery: converts to FROM_HEX(this)
7495#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7496#[cfg_attr(feature = "bindings", derive(TS))]
7497pub struct HexStringExpr {
7498    pub this: Box<Expression>,
7499    #[serde(default)]
7500    pub is_integer: Option<bool>,
7501}
7502
7503/// UnicodeString
7504#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7505#[cfg_attr(feature = "bindings", derive(TS))]
7506pub struct UnicodeString {
7507    pub this: Box<Expression>,
7508    #[serde(default)]
7509    pub escape: Option<Box<Expression>>,
7510}
7511
7512/// AlterColumn
7513#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7514#[cfg_attr(feature = "bindings", derive(TS))]
7515pub struct AlterColumn {
7516    pub this: Box<Expression>,
7517    #[serde(default)]
7518    pub dtype: Option<Box<Expression>>,
7519    #[serde(default)]
7520    pub collate: Option<Box<Expression>>,
7521    #[serde(default)]
7522    pub using: Option<Box<Expression>>,
7523    #[serde(default)]
7524    pub default: Option<Box<Expression>>,
7525    #[serde(default)]
7526    pub drop: Option<Box<Expression>>,
7527    #[serde(default)]
7528    pub comment: Option<Box<Expression>>,
7529    #[serde(default)]
7530    pub allow_null: Option<Box<Expression>>,
7531    #[serde(default)]
7532    pub visible: Option<Box<Expression>>,
7533    #[serde(default)]
7534    pub rename_to: Option<Box<Expression>>,
7535}
7536
7537/// AlterSortKey
7538#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7539#[cfg_attr(feature = "bindings", derive(TS))]
7540pub struct AlterSortKey {
7541    #[serde(default)]
7542    pub this: Option<Box<Expression>>,
7543    #[serde(default)]
7544    pub expressions: Vec<Expression>,
7545    #[serde(default)]
7546    pub compound: Option<Box<Expression>>,
7547}
7548
7549/// AlterSet
7550#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7551#[cfg_attr(feature = "bindings", derive(TS))]
7552pub struct AlterSet {
7553    #[serde(default)]
7554    pub expressions: Vec<Expression>,
7555    #[serde(default)]
7556    pub option: Option<Box<Expression>>,
7557    #[serde(default)]
7558    pub tablespace: Option<Box<Expression>>,
7559    #[serde(default)]
7560    pub access_method: Option<Box<Expression>>,
7561    #[serde(default)]
7562    pub file_format: Option<Box<Expression>>,
7563    #[serde(default)]
7564    pub copy_options: Option<Box<Expression>>,
7565    #[serde(default)]
7566    pub tag: Option<Box<Expression>>,
7567    #[serde(default)]
7568    pub location: Option<Box<Expression>>,
7569    #[serde(default)]
7570    pub serde: Option<Box<Expression>>,
7571}
7572
7573/// RenameColumn
7574#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7575#[cfg_attr(feature = "bindings", derive(TS))]
7576pub struct RenameColumn {
7577    pub this: Box<Expression>,
7578    #[serde(default)]
7579    pub to: Option<Box<Expression>>,
7580    #[serde(default)]
7581    pub exists: bool,
7582}
7583
7584/// Comprehension
7585#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7586#[cfg_attr(feature = "bindings", derive(TS))]
7587pub struct Comprehension {
7588    pub this: Box<Expression>,
7589    pub expression: Box<Expression>,
7590    #[serde(default)]
7591    pub position: Option<Box<Expression>>,
7592    #[serde(default)]
7593    pub iterator: Option<Box<Expression>>,
7594    #[serde(default)]
7595    pub condition: Option<Box<Expression>>,
7596}
7597
7598/// MergeTreeTTLAction
7599#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7600#[cfg_attr(feature = "bindings", derive(TS))]
7601pub struct MergeTreeTTLAction {
7602    pub this: Box<Expression>,
7603    #[serde(default)]
7604    pub delete: Option<Box<Expression>>,
7605    #[serde(default)]
7606    pub recompress: Option<Box<Expression>>,
7607    #[serde(default)]
7608    pub to_disk: Option<Box<Expression>>,
7609    #[serde(default)]
7610    pub to_volume: Option<Box<Expression>>,
7611}
7612
7613/// MergeTreeTTL
7614#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7615#[cfg_attr(feature = "bindings", derive(TS))]
7616pub struct MergeTreeTTL {
7617    #[serde(default)]
7618    pub expressions: Vec<Expression>,
7619    #[serde(default)]
7620    pub where_: Option<Box<Expression>>,
7621    #[serde(default)]
7622    pub group: Option<Box<Expression>>,
7623    #[serde(default)]
7624    pub aggregates: Option<Box<Expression>>,
7625}
7626
7627/// IndexConstraintOption
7628#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7629#[cfg_attr(feature = "bindings", derive(TS))]
7630pub struct IndexConstraintOption {
7631    #[serde(default)]
7632    pub key_block_size: Option<Box<Expression>>,
7633    #[serde(default)]
7634    pub using: Option<Box<Expression>>,
7635    #[serde(default)]
7636    pub parser: Option<Box<Expression>>,
7637    #[serde(default)]
7638    pub comment: Option<Box<Expression>>,
7639    #[serde(default)]
7640    pub visible: Option<Box<Expression>>,
7641    #[serde(default)]
7642    pub engine_attr: Option<Box<Expression>>,
7643    #[serde(default)]
7644    pub secondary_engine_attr: Option<Box<Expression>>,
7645}
7646
7647/// PeriodForSystemTimeConstraint
7648#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7649#[cfg_attr(feature = "bindings", derive(TS))]
7650pub struct PeriodForSystemTimeConstraint {
7651    pub this: Box<Expression>,
7652    pub expression: Box<Expression>,
7653}
7654
7655/// CaseSpecificColumnConstraint
7656#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7657#[cfg_attr(feature = "bindings", derive(TS))]
7658pub struct CaseSpecificColumnConstraint {
7659    #[serde(default)]
7660    pub not_: Option<Box<Expression>>,
7661}
7662
7663/// CharacterSetColumnConstraint
7664#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7665#[cfg_attr(feature = "bindings", derive(TS))]
7666pub struct CharacterSetColumnConstraint {
7667    pub this: Box<Expression>,
7668}
7669
7670/// CheckColumnConstraint
7671#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7672#[cfg_attr(feature = "bindings", derive(TS))]
7673pub struct CheckColumnConstraint {
7674    pub this: Box<Expression>,
7675    #[serde(default)]
7676    pub enforced: Option<Box<Expression>>,
7677}
7678
7679/// CompressColumnConstraint
7680#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7681#[cfg_attr(feature = "bindings", derive(TS))]
7682pub struct CompressColumnConstraint {
7683    #[serde(default)]
7684    pub this: Option<Box<Expression>>,
7685}
7686
7687/// DateFormatColumnConstraint
7688#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7689#[cfg_attr(feature = "bindings", derive(TS))]
7690pub struct DateFormatColumnConstraint {
7691    pub this: Box<Expression>,
7692}
7693
7694/// EphemeralColumnConstraint
7695#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7696#[cfg_attr(feature = "bindings", derive(TS))]
7697pub struct EphemeralColumnConstraint {
7698    #[serde(default)]
7699    pub this: Option<Box<Expression>>,
7700}
7701
7702/// WithOperator
7703#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7704#[cfg_attr(feature = "bindings", derive(TS))]
7705pub struct WithOperator {
7706    pub this: Box<Expression>,
7707    pub op: String,
7708}
7709
7710/// GeneratedAsIdentityColumnConstraint
7711#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7712#[cfg_attr(feature = "bindings", derive(TS))]
7713pub struct GeneratedAsIdentityColumnConstraint {
7714    #[serde(default)]
7715    pub this: Option<Box<Expression>>,
7716    #[serde(default)]
7717    pub expression: Option<Box<Expression>>,
7718    #[serde(default)]
7719    pub on_null: Option<Box<Expression>>,
7720    #[serde(default)]
7721    pub start: Option<Box<Expression>>,
7722    #[serde(default)]
7723    pub increment: Option<Box<Expression>>,
7724    #[serde(default)]
7725    pub minvalue: Option<Box<Expression>>,
7726    #[serde(default)]
7727    pub maxvalue: Option<Box<Expression>>,
7728    #[serde(default)]
7729    pub cycle: Option<Box<Expression>>,
7730    #[serde(default)]
7731    pub order: Option<Box<Expression>>,
7732}
7733
7734/// AutoIncrementColumnConstraint - MySQL/TSQL auto-increment marker
7735/// TSQL: outputs "IDENTITY"
7736#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7737#[cfg_attr(feature = "bindings", derive(TS))]
7738pub struct AutoIncrementColumnConstraint;
7739
7740/// CommentColumnConstraint - Column comment marker
7741#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7742#[cfg_attr(feature = "bindings", derive(TS))]
7743pub struct CommentColumnConstraint;
7744
7745/// GeneratedAsRowColumnConstraint
7746#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7747#[cfg_attr(feature = "bindings", derive(TS))]
7748pub struct GeneratedAsRowColumnConstraint {
7749    #[serde(default)]
7750    pub start: Option<Box<Expression>>,
7751    #[serde(default)]
7752    pub hidden: Option<Box<Expression>>,
7753}
7754
7755/// IndexColumnConstraint
7756#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7757#[cfg_attr(feature = "bindings", derive(TS))]
7758pub struct IndexColumnConstraint {
7759    #[serde(default)]
7760    pub this: Option<Box<Expression>>,
7761    #[serde(default)]
7762    pub expressions: Vec<Expression>,
7763    #[serde(default)]
7764    pub kind: Option<String>,
7765    #[serde(default)]
7766    pub index_type: Option<Box<Expression>>,
7767    #[serde(default)]
7768    pub options: Vec<Expression>,
7769    #[serde(default)]
7770    pub expression: Option<Box<Expression>>,
7771    #[serde(default)]
7772    pub granularity: Option<Box<Expression>>,
7773}
7774
7775/// MaskingPolicyColumnConstraint
7776#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7777#[cfg_attr(feature = "bindings", derive(TS))]
7778pub struct MaskingPolicyColumnConstraint {
7779    pub this: Box<Expression>,
7780    #[serde(default)]
7781    pub expressions: Vec<Expression>,
7782}
7783
7784/// NotNullColumnConstraint
7785#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7786#[cfg_attr(feature = "bindings", derive(TS))]
7787pub struct NotNullColumnConstraint {
7788    #[serde(default)]
7789    pub allow_null: Option<Box<Expression>>,
7790}
7791
7792/// DefaultColumnConstraint - DEFAULT value for a column
7793#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7794#[cfg_attr(feature = "bindings", derive(TS))]
7795pub struct DefaultColumnConstraint {
7796    pub this: Box<Expression>,
7797}
7798
7799/// PrimaryKeyColumnConstraint
7800#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7801#[cfg_attr(feature = "bindings", derive(TS))]
7802pub struct PrimaryKeyColumnConstraint {
7803    #[serde(default)]
7804    pub desc: Option<Box<Expression>>,
7805    #[serde(default)]
7806    pub options: Vec<Expression>,
7807}
7808
7809/// UniqueColumnConstraint
7810#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7811#[cfg_attr(feature = "bindings", derive(TS))]
7812pub struct UniqueColumnConstraint {
7813    #[serde(default)]
7814    pub this: Option<Box<Expression>>,
7815    #[serde(default)]
7816    pub index_type: Option<Box<Expression>>,
7817    #[serde(default)]
7818    pub on_conflict: Option<Box<Expression>>,
7819    #[serde(default)]
7820    pub nulls: Option<Box<Expression>>,
7821    #[serde(default)]
7822    pub options: Vec<Expression>,
7823}
7824
7825/// WatermarkColumnConstraint
7826#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7827#[cfg_attr(feature = "bindings", derive(TS))]
7828pub struct WatermarkColumnConstraint {
7829    pub this: Box<Expression>,
7830    pub expression: Box<Expression>,
7831}
7832
7833/// ComputedColumnConstraint
7834#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7835#[cfg_attr(feature = "bindings", derive(TS))]
7836pub struct ComputedColumnConstraint {
7837    pub this: Box<Expression>,
7838    #[serde(default)]
7839    pub persisted: Option<Box<Expression>>,
7840    #[serde(default)]
7841    pub not_null: Option<Box<Expression>>,
7842    #[serde(default)]
7843    pub data_type: Option<Box<Expression>>,
7844}
7845
7846/// InOutColumnConstraint
7847#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7848#[cfg_attr(feature = "bindings", derive(TS))]
7849pub struct InOutColumnConstraint {
7850    #[serde(default)]
7851    pub input_: Option<Box<Expression>>,
7852    #[serde(default)]
7853    pub output: Option<Box<Expression>>,
7854}
7855
7856/// PathColumnConstraint - PATH 'xpath' for XMLTABLE/JSON_TABLE columns
7857#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7858#[cfg_attr(feature = "bindings", derive(TS))]
7859pub struct PathColumnConstraint {
7860    pub this: Box<Expression>,
7861}
7862
7863/// Constraint
7864#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7865#[cfg_attr(feature = "bindings", derive(TS))]
7866pub struct Constraint {
7867    pub this: Box<Expression>,
7868    #[serde(default)]
7869    pub expressions: Vec<Expression>,
7870}
7871
7872/// Export
7873#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7874#[cfg_attr(feature = "bindings", derive(TS))]
7875pub struct Export {
7876    pub this: Box<Expression>,
7877    #[serde(default)]
7878    pub connection: Option<Box<Expression>>,
7879    #[serde(default)]
7880    pub options: Vec<Expression>,
7881}
7882
7883/// Filter
7884#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7885#[cfg_attr(feature = "bindings", derive(TS))]
7886pub struct Filter {
7887    pub this: Box<Expression>,
7888    pub expression: Box<Expression>,
7889}
7890
7891/// Changes
7892#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7893#[cfg_attr(feature = "bindings", derive(TS))]
7894pub struct Changes {
7895    #[serde(default)]
7896    pub information: Option<Box<Expression>>,
7897    #[serde(default)]
7898    pub at_before: Option<Box<Expression>>,
7899    #[serde(default)]
7900    pub end: Option<Box<Expression>>,
7901}
7902
7903/// Directory
7904#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7905#[cfg_attr(feature = "bindings", derive(TS))]
7906pub struct Directory {
7907    pub this: Box<Expression>,
7908    #[serde(default)]
7909    pub local: Option<Box<Expression>>,
7910    #[serde(default)]
7911    pub row_format: Option<Box<Expression>>,
7912}
7913
7914/// ForeignKey
7915#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7916#[cfg_attr(feature = "bindings", derive(TS))]
7917pub struct ForeignKey {
7918    #[serde(default)]
7919    pub expressions: Vec<Expression>,
7920    #[serde(default)]
7921    pub reference: Option<Box<Expression>>,
7922    #[serde(default)]
7923    pub delete: Option<Box<Expression>>,
7924    #[serde(default)]
7925    pub update: Option<Box<Expression>>,
7926    #[serde(default)]
7927    pub options: Vec<Expression>,
7928}
7929
7930/// ColumnPrefix
7931#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7932#[cfg_attr(feature = "bindings", derive(TS))]
7933pub struct ColumnPrefix {
7934    pub this: Box<Expression>,
7935    pub expression: Box<Expression>,
7936}
7937
7938/// PrimaryKey
7939#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7940#[cfg_attr(feature = "bindings", derive(TS))]
7941pub struct PrimaryKey {
7942    #[serde(default)]
7943    pub this: Option<Box<Expression>>,
7944    #[serde(default)]
7945    pub expressions: Vec<Expression>,
7946    #[serde(default)]
7947    pub options: Vec<Expression>,
7948    #[serde(default)]
7949    pub include: Option<Box<Expression>>,
7950}
7951
7952/// Into
7953#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7954#[cfg_attr(feature = "bindings", derive(TS))]
7955pub struct IntoClause {
7956    #[serde(default)]
7957    pub this: Option<Box<Expression>>,
7958    #[serde(default)]
7959    pub temporary: bool,
7960    #[serde(default)]
7961    pub unlogged: Option<Box<Expression>>,
7962    #[serde(default)]
7963    pub bulk_collect: Option<Box<Expression>>,
7964    #[serde(default)]
7965    pub expressions: Vec<Expression>,
7966}
7967
7968/// JoinHint
7969#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7970#[cfg_attr(feature = "bindings", derive(TS))]
7971pub struct JoinHint {
7972    pub this: Box<Expression>,
7973    #[serde(default)]
7974    pub expressions: Vec<Expression>,
7975}
7976
7977/// Opclass
7978#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7979#[cfg_attr(feature = "bindings", derive(TS))]
7980pub struct Opclass {
7981    pub this: Box<Expression>,
7982    pub expression: Box<Expression>,
7983}
7984
7985/// Index
7986#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7987#[cfg_attr(feature = "bindings", derive(TS))]
7988pub struct Index {
7989    #[serde(default)]
7990    pub this: Option<Box<Expression>>,
7991    #[serde(default)]
7992    pub table: Option<Box<Expression>>,
7993    #[serde(default)]
7994    pub unique: bool,
7995    #[serde(default)]
7996    pub primary: Option<Box<Expression>>,
7997    #[serde(default)]
7998    pub amp: Option<Box<Expression>>,
7999    #[serde(default)]
8000    pub params: Vec<Expression>,
8001}
8002
8003/// IndexParameters
8004#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8005#[cfg_attr(feature = "bindings", derive(TS))]
8006pub struct IndexParameters {
8007    #[serde(default)]
8008    pub using: Option<Box<Expression>>,
8009    #[serde(default)]
8010    pub include: Option<Box<Expression>>,
8011    #[serde(default)]
8012    pub columns: Vec<Expression>,
8013    #[serde(default)]
8014    pub with_storage: Option<Box<Expression>>,
8015    #[serde(default)]
8016    pub partition_by: Option<Box<Expression>>,
8017    #[serde(default)]
8018    pub tablespace: Option<Box<Expression>>,
8019    #[serde(default)]
8020    pub where_: Option<Box<Expression>>,
8021    #[serde(default)]
8022    pub on: Option<Box<Expression>>,
8023}
8024
8025/// ConditionalInsert
8026#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8027#[cfg_attr(feature = "bindings", derive(TS))]
8028pub struct ConditionalInsert {
8029    pub this: Box<Expression>,
8030    #[serde(default)]
8031    pub expression: Option<Box<Expression>>,
8032    #[serde(default)]
8033    pub else_: Option<Box<Expression>>,
8034}
8035
8036/// MultitableInserts
8037#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8038#[cfg_attr(feature = "bindings", derive(TS))]
8039pub struct MultitableInserts {
8040    #[serde(default)]
8041    pub expressions: Vec<Expression>,
8042    pub kind: String,
8043    #[serde(default)]
8044    pub source: Option<Box<Expression>>,
8045    /// Leading comments before the statement
8046    #[serde(default)]
8047    pub leading_comments: Vec<String>,
8048}
8049
8050/// OnConflict
8051#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8052#[cfg_attr(feature = "bindings", derive(TS))]
8053pub struct OnConflict {
8054    #[serde(default)]
8055    pub duplicate: Option<Box<Expression>>,
8056    #[serde(default)]
8057    pub expressions: Vec<Expression>,
8058    #[serde(default)]
8059    pub action: Option<Box<Expression>>,
8060    #[serde(default)]
8061    pub conflict_keys: Option<Box<Expression>>,
8062    #[serde(default)]
8063    pub index_predicate: Option<Box<Expression>>,
8064    #[serde(default)]
8065    pub constraint: Option<Box<Expression>>,
8066    #[serde(default)]
8067    pub where_: Option<Box<Expression>>,
8068}
8069
8070/// OnCondition
8071#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8072#[cfg_attr(feature = "bindings", derive(TS))]
8073pub struct OnCondition {
8074    #[serde(default)]
8075    pub error: Option<Box<Expression>>,
8076    #[serde(default)]
8077    pub empty: Option<Box<Expression>>,
8078    #[serde(default)]
8079    pub null: Option<Box<Expression>>,
8080}
8081
8082/// Returning
8083#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8084#[cfg_attr(feature = "bindings", derive(TS))]
8085pub struct Returning {
8086    #[serde(default)]
8087    pub expressions: Vec<Expression>,
8088    #[serde(default)]
8089    pub into: Option<Box<Expression>>,
8090}
8091
8092/// Introducer
8093#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8094#[cfg_attr(feature = "bindings", derive(TS))]
8095pub struct Introducer {
8096    pub this: Box<Expression>,
8097    pub expression: Box<Expression>,
8098}
8099
8100/// PartitionRange
8101#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8102#[cfg_attr(feature = "bindings", derive(TS))]
8103pub struct PartitionRange {
8104    pub this: Box<Expression>,
8105    #[serde(default)]
8106    pub expression: Option<Box<Expression>>,
8107    #[serde(default)]
8108    pub expressions: Vec<Expression>,
8109}
8110
8111/// Group
8112#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8113#[cfg_attr(feature = "bindings", derive(TS))]
8114pub struct Group {
8115    #[serde(default)]
8116    pub expressions: Vec<Expression>,
8117    #[serde(default)]
8118    pub grouping_sets: Option<Box<Expression>>,
8119    #[serde(default)]
8120    pub cube: Option<Box<Expression>>,
8121    #[serde(default)]
8122    pub rollup: Option<Box<Expression>>,
8123    #[serde(default)]
8124    pub totals: Option<Box<Expression>>,
8125    /// GROUP BY modifier: Some(true) = ALL, Some(false) = DISTINCT, None = no modifier
8126    #[serde(default)]
8127    pub all: Option<bool>,
8128}
8129
8130/// Cube
8131#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8132#[cfg_attr(feature = "bindings", derive(TS))]
8133pub struct Cube {
8134    #[serde(default)]
8135    pub expressions: Vec<Expression>,
8136}
8137
8138/// Rollup
8139#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8140#[cfg_attr(feature = "bindings", derive(TS))]
8141pub struct Rollup {
8142    #[serde(default)]
8143    pub expressions: Vec<Expression>,
8144}
8145
8146/// GroupingSets
8147#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8148#[cfg_attr(feature = "bindings", derive(TS))]
8149pub struct GroupingSets {
8150    #[serde(default)]
8151    pub expressions: Vec<Expression>,
8152}
8153
8154/// LimitOptions
8155#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8156#[cfg_attr(feature = "bindings", derive(TS))]
8157pub struct LimitOptions {
8158    #[serde(default)]
8159    pub percent: Option<Box<Expression>>,
8160    #[serde(default)]
8161    pub rows: Option<Box<Expression>>,
8162    #[serde(default)]
8163    pub with_ties: Option<Box<Expression>>,
8164}
8165
8166/// Lateral
8167#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8168#[cfg_attr(feature = "bindings", derive(TS))]
8169pub struct Lateral {
8170    pub this: Box<Expression>,
8171    #[serde(default)]
8172    pub view: Option<Box<Expression>>,
8173    #[serde(default)]
8174    pub outer: Option<Box<Expression>>,
8175    #[serde(default)]
8176    pub alias: Option<String>,
8177    /// Whether the alias was originally quoted (backtick/double-quote)
8178    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
8179    pub alias_quoted: bool,
8180    #[serde(default)]
8181    pub cross_apply: Option<Box<Expression>>,
8182    #[serde(default)]
8183    pub ordinality: Option<Box<Expression>>,
8184    /// Column aliases for the lateral expression (e.g., LATERAL func() AS alias(col1, col2))
8185    #[serde(default, skip_serializing_if = "Vec::is_empty")]
8186    pub column_aliases: Vec<String>,
8187}
8188
8189/// TableFromRows
8190#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8191#[cfg_attr(feature = "bindings", derive(TS))]
8192pub struct TableFromRows {
8193    pub this: Box<Expression>,
8194    #[serde(default)]
8195    pub alias: Option<String>,
8196    #[serde(default)]
8197    pub joins: Vec<Expression>,
8198    #[serde(default)]
8199    pub pivots: Option<Box<Expression>>,
8200    #[serde(default)]
8201    pub sample: Option<Box<Expression>>,
8202}
8203
8204/// RowsFrom - PostgreSQL ROWS FROM (func1(args) AS alias1(...), func2(args) AS alias2(...)) syntax
8205/// Used for set-returning functions with typed column definitions
8206#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8207#[cfg_attr(feature = "bindings", derive(TS))]
8208pub struct RowsFrom {
8209    /// List of function expressions, each potentially with an alias and typed columns
8210    pub expressions: Vec<Expression>,
8211    /// WITH ORDINALITY modifier
8212    #[serde(default)]
8213    pub ordinality: bool,
8214    /// Optional outer alias: ROWS FROM (...) AS alias(col1 type1, col2 type2)
8215    #[serde(default)]
8216    pub alias: Option<Box<Expression>>,
8217}
8218
8219/// WithFill
8220#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8221#[cfg_attr(feature = "bindings", derive(TS))]
8222pub struct WithFill {
8223    #[serde(default)]
8224    pub from_: Option<Box<Expression>>,
8225    #[serde(default)]
8226    pub to: Option<Box<Expression>>,
8227    #[serde(default)]
8228    pub step: Option<Box<Expression>>,
8229    #[serde(default)]
8230    pub interpolate: Option<Box<Expression>>,
8231}
8232
8233/// Property
8234#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8235#[cfg_attr(feature = "bindings", derive(TS))]
8236pub struct Property {
8237    pub this: Box<Expression>,
8238    #[serde(default)]
8239    pub value: Option<Box<Expression>>,
8240}
8241
8242/// GrantPrivilege
8243#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8244#[cfg_attr(feature = "bindings", derive(TS))]
8245pub struct GrantPrivilege {
8246    pub this: Box<Expression>,
8247    #[serde(default)]
8248    pub expressions: Vec<Expression>,
8249}
8250
8251/// AllowedValuesProperty
8252#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8253#[cfg_attr(feature = "bindings", derive(TS))]
8254pub struct AllowedValuesProperty {
8255    #[serde(default)]
8256    pub expressions: Vec<Expression>,
8257}
8258
8259/// AlgorithmProperty
8260#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8261#[cfg_attr(feature = "bindings", derive(TS))]
8262pub struct AlgorithmProperty {
8263    pub this: Box<Expression>,
8264}
8265
8266/// AutoIncrementProperty
8267#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8268#[cfg_attr(feature = "bindings", derive(TS))]
8269pub struct AutoIncrementProperty {
8270    pub this: Box<Expression>,
8271}
8272
8273/// AutoRefreshProperty
8274#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8275#[cfg_attr(feature = "bindings", derive(TS))]
8276pub struct AutoRefreshProperty {
8277    pub this: Box<Expression>,
8278}
8279
8280/// BackupProperty
8281#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8282#[cfg_attr(feature = "bindings", derive(TS))]
8283pub struct BackupProperty {
8284    pub this: Box<Expression>,
8285}
8286
8287/// BuildProperty
8288#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8289#[cfg_attr(feature = "bindings", derive(TS))]
8290pub struct BuildProperty {
8291    pub this: Box<Expression>,
8292}
8293
8294/// BlockCompressionProperty
8295#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8296#[cfg_attr(feature = "bindings", derive(TS))]
8297pub struct BlockCompressionProperty {
8298    #[serde(default)]
8299    pub autotemp: Option<Box<Expression>>,
8300    #[serde(default)]
8301    pub always: Option<Box<Expression>>,
8302    #[serde(default)]
8303    pub default: Option<Box<Expression>>,
8304    #[serde(default)]
8305    pub manual: Option<Box<Expression>>,
8306    #[serde(default)]
8307    pub never: Option<Box<Expression>>,
8308}
8309
8310/// CharacterSetProperty
8311#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8312#[cfg_attr(feature = "bindings", derive(TS))]
8313pub struct CharacterSetProperty {
8314    pub this: Box<Expression>,
8315    #[serde(default)]
8316    pub default: Option<Box<Expression>>,
8317}
8318
8319/// ChecksumProperty
8320#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8321#[cfg_attr(feature = "bindings", derive(TS))]
8322pub struct ChecksumProperty {
8323    #[serde(default)]
8324    pub on: Option<Box<Expression>>,
8325    #[serde(default)]
8326    pub default: Option<Box<Expression>>,
8327}
8328
8329/// CollateProperty
8330#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8331#[cfg_attr(feature = "bindings", derive(TS))]
8332pub struct CollateProperty {
8333    pub this: Box<Expression>,
8334    #[serde(default)]
8335    pub default: Option<Box<Expression>>,
8336}
8337
8338/// DataBlocksizeProperty
8339#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8340#[cfg_attr(feature = "bindings", derive(TS))]
8341pub struct DataBlocksizeProperty {
8342    #[serde(default)]
8343    pub size: Option<i64>,
8344    #[serde(default)]
8345    pub units: Option<Box<Expression>>,
8346    #[serde(default)]
8347    pub minimum: Option<Box<Expression>>,
8348    #[serde(default)]
8349    pub maximum: Option<Box<Expression>>,
8350    #[serde(default)]
8351    pub default: Option<Box<Expression>>,
8352}
8353
8354/// DataDeletionProperty
8355#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8356#[cfg_attr(feature = "bindings", derive(TS))]
8357pub struct DataDeletionProperty {
8358    pub on: Box<Expression>,
8359    #[serde(default)]
8360    pub filter_column: Option<Box<Expression>>,
8361    #[serde(default)]
8362    pub retention_period: Option<Box<Expression>>,
8363}
8364
8365/// DefinerProperty
8366#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8367#[cfg_attr(feature = "bindings", derive(TS))]
8368pub struct DefinerProperty {
8369    pub this: Box<Expression>,
8370}
8371
8372/// DistKeyProperty
8373#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8374#[cfg_attr(feature = "bindings", derive(TS))]
8375pub struct DistKeyProperty {
8376    pub this: Box<Expression>,
8377}
8378
8379/// DistributedByProperty
8380#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8381#[cfg_attr(feature = "bindings", derive(TS))]
8382pub struct DistributedByProperty {
8383    #[serde(default)]
8384    pub expressions: Vec<Expression>,
8385    pub kind: String,
8386    #[serde(default)]
8387    pub buckets: Option<Box<Expression>>,
8388    #[serde(default)]
8389    pub order: Option<Box<Expression>>,
8390}
8391
8392/// DistStyleProperty
8393#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8394#[cfg_attr(feature = "bindings", derive(TS))]
8395pub struct DistStyleProperty {
8396    pub this: Box<Expression>,
8397}
8398
8399/// DuplicateKeyProperty
8400#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8401#[cfg_attr(feature = "bindings", derive(TS))]
8402pub struct DuplicateKeyProperty {
8403    #[serde(default)]
8404    pub expressions: Vec<Expression>,
8405}
8406
8407/// EngineProperty
8408#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8409#[cfg_attr(feature = "bindings", derive(TS))]
8410pub struct EngineProperty {
8411    pub this: Box<Expression>,
8412}
8413
8414/// ToTableProperty
8415#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8416#[cfg_attr(feature = "bindings", derive(TS))]
8417pub struct ToTableProperty {
8418    pub this: Box<Expression>,
8419}
8420
8421/// ExecuteAsProperty
8422#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8423#[cfg_attr(feature = "bindings", derive(TS))]
8424pub struct ExecuteAsProperty {
8425    pub this: Box<Expression>,
8426}
8427
8428/// ExternalProperty
8429#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8430#[cfg_attr(feature = "bindings", derive(TS))]
8431pub struct ExternalProperty {
8432    #[serde(default)]
8433    pub this: Option<Box<Expression>>,
8434}
8435
8436/// FallbackProperty
8437#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8438#[cfg_attr(feature = "bindings", derive(TS))]
8439pub struct FallbackProperty {
8440    #[serde(default)]
8441    pub no: Option<Box<Expression>>,
8442    #[serde(default)]
8443    pub protection: Option<Box<Expression>>,
8444}
8445
8446/// FileFormatProperty
8447#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8448#[cfg_attr(feature = "bindings", derive(TS))]
8449pub struct FileFormatProperty {
8450    #[serde(default)]
8451    pub this: Option<Box<Expression>>,
8452    #[serde(default)]
8453    pub expressions: Vec<Expression>,
8454    #[serde(default)]
8455    pub hive_format: Option<Box<Expression>>,
8456}
8457
8458/// CredentialsProperty
8459#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8460#[cfg_attr(feature = "bindings", derive(TS))]
8461pub struct CredentialsProperty {
8462    #[serde(default)]
8463    pub expressions: Vec<Expression>,
8464}
8465
8466/// FreespaceProperty
8467#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8468#[cfg_attr(feature = "bindings", derive(TS))]
8469pub struct FreespaceProperty {
8470    pub this: Box<Expression>,
8471    #[serde(default)]
8472    pub percent: Option<Box<Expression>>,
8473}
8474
8475/// InheritsProperty
8476#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8477#[cfg_attr(feature = "bindings", derive(TS))]
8478pub struct InheritsProperty {
8479    #[serde(default)]
8480    pub expressions: Vec<Expression>,
8481}
8482
8483/// InputModelProperty
8484#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8485#[cfg_attr(feature = "bindings", derive(TS))]
8486pub struct InputModelProperty {
8487    pub this: Box<Expression>,
8488}
8489
8490/// OutputModelProperty
8491#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8492#[cfg_attr(feature = "bindings", derive(TS))]
8493pub struct OutputModelProperty {
8494    pub this: Box<Expression>,
8495}
8496
8497/// IsolatedLoadingProperty
8498#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8499#[cfg_attr(feature = "bindings", derive(TS))]
8500pub struct IsolatedLoadingProperty {
8501    #[serde(default)]
8502    pub no: Option<Box<Expression>>,
8503    #[serde(default)]
8504    pub concurrent: Option<Box<Expression>>,
8505    #[serde(default)]
8506    pub target: Option<Box<Expression>>,
8507}
8508
8509/// JournalProperty
8510#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8511#[cfg_attr(feature = "bindings", derive(TS))]
8512pub struct JournalProperty {
8513    #[serde(default)]
8514    pub no: Option<Box<Expression>>,
8515    #[serde(default)]
8516    pub dual: Option<Box<Expression>>,
8517    #[serde(default)]
8518    pub before: Option<Box<Expression>>,
8519    #[serde(default)]
8520    pub local: Option<Box<Expression>>,
8521    #[serde(default)]
8522    pub after: Option<Box<Expression>>,
8523}
8524
8525/// LanguageProperty
8526#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8527#[cfg_attr(feature = "bindings", derive(TS))]
8528pub struct LanguageProperty {
8529    pub this: Box<Expression>,
8530}
8531
8532/// EnviromentProperty
8533#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8534#[cfg_attr(feature = "bindings", derive(TS))]
8535pub struct EnviromentProperty {
8536    #[serde(default)]
8537    pub expressions: Vec<Expression>,
8538}
8539
8540/// ClusteredByProperty
8541#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8542#[cfg_attr(feature = "bindings", derive(TS))]
8543pub struct ClusteredByProperty {
8544    #[serde(default)]
8545    pub expressions: Vec<Expression>,
8546    #[serde(default)]
8547    pub sorted_by: Option<Box<Expression>>,
8548    #[serde(default)]
8549    pub buckets: Option<Box<Expression>>,
8550}
8551
8552/// DictProperty
8553#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8554#[cfg_attr(feature = "bindings", derive(TS))]
8555pub struct DictProperty {
8556    pub this: Box<Expression>,
8557    pub kind: String,
8558    #[serde(default)]
8559    pub settings: Option<Box<Expression>>,
8560}
8561
8562/// DictRange
8563#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8564#[cfg_attr(feature = "bindings", derive(TS))]
8565pub struct DictRange {
8566    pub this: Box<Expression>,
8567    #[serde(default)]
8568    pub min: Option<Box<Expression>>,
8569    #[serde(default)]
8570    pub max: Option<Box<Expression>>,
8571}
8572
8573/// OnCluster
8574#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8575#[cfg_attr(feature = "bindings", derive(TS))]
8576pub struct OnCluster {
8577    pub this: Box<Expression>,
8578}
8579
8580/// LikeProperty
8581#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8582#[cfg_attr(feature = "bindings", derive(TS))]
8583pub struct LikeProperty {
8584    pub this: Box<Expression>,
8585    #[serde(default)]
8586    pub expressions: Vec<Expression>,
8587}
8588
8589/// LocationProperty
8590#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8591#[cfg_attr(feature = "bindings", derive(TS))]
8592pub struct LocationProperty {
8593    pub this: Box<Expression>,
8594}
8595
8596/// LockProperty
8597#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8598#[cfg_attr(feature = "bindings", derive(TS))]
8599pub struct LockProperty {
8600    pub this: Box<Expression>,
8601}
8602
8603/// LockingProperty
8604#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8605#[cfg_attr(feature = "bindings", derive(TS))]
8606pub struct LockingProperty {
8607    #[serde(default)]
8608    pub this: Option<Box<Expression>>,
8609    pub kind: String,
8610    #[serde(default)]
8611    pub for_or_in: Option<Box<Expression>>,
8612    #[serde(default)]
8613    pub lock_type: Option<Box<Expression>>,
8614    #[serde(default)]
8615    pub override_: Option<Box<Expression>>,
8616}
8617
8618/// LogProperty
8619#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8620#[cfg_attr(feature = "bindings", derive(TS))]
8621pub struct LogProperty {
8622    #[serde(default)]
8623    pub no: Option<Box<Expression>>,
8624}
8625
8626/// MaterializedProperty
8627#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8628#[cfg_attr(feature = "bindings", derive(TS))]
8629pub struct MaterializedProperty {
8630    #[serde(default)]
8631    pub this: Option<Box<Expression>>,
8632}
8633
8634/// MergeBlockRatioProperty
8635#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8636#[cfg_attr(feature = "bindings", derive(TS))]
8637pub struct MergeBlockRatioProperty {
8638    #[serde(default)]
8639    pub this: Option<Box<Expression>>,
8640    #[serde(default)]
8641    pub no: Option<Box<Expression>>,
8642    #[serde(default)]
8643    pub default: Option<Box<Expression>>,
8644    #[serde(default)]
8645    pub percent: Option<Box<Expression>>,
8646}
8647
8648/// OnProperty
8649#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8650#[cfg_attr(feature = "bindings", derive(TS))]
8651pub struct OnProperty {
8652    pub this: Box<Expression>,
8653}
8654
8655/// OnCommitProperty
8656#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8657#[cfg_attr(feature = "bindings", derive(TS))]
8658pub struct OnCommitProperty {
8659    #[serde(default)]
8660    pub delete: Option<Box<Expression>>,
8661}
8662
8663/// PartitionedByProperty
8664#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8665#[cfg_attr(feature = "bindings", derive(TS))]
8666pub struct PartitionedByProperty {
8667    pub this: Box<Expression>,
8668}
8669
8670/// PartitionedByBucket
8671#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8672#[cfg_attr(feature = "bindings", derive(TS))]
8673pub struct PartitionedByBucket {
8674    pub this: Box<Expression>,
8675    pub expression: Box<Expression>,
8676}
8677
8678/// PartitionByTruncate
8679#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8680#[cfg_attr(feature = "bindings", derive(TS))]
8681pub struct PartitionByTruncate {
8682    pub this: Box<Expression>,
8683    pub expression: Box<Expression>,
8684}
8685
8686/// PartitionByRangeProperty
8687#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8688#[cfg_attr(feature = "bindings", derive(TS))]
8689pub struct PartitionByRangeProperty {
8690    #[serde(default)]
8691    pub partition_expressions: Option<Box<Expression>>,
8692    #[serde(default)]
8693    pub create_expressions: Option<Box<Expression>>,
8694}
8695
8696/// PartitionByRangePropertyDynamic
8697#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8698#[cfg_attr(feature = "bindings", derive(TS))]
8699pub struct PartitionByRangePropertyDynamic {
8700    #[serde(default)]
8701    pub this: Option<Box<Expression>>,
8702    #[serde(default)]
8703    pub start: Option<Box<Expression>>,
8704    #[serde(default)]
8705    pub end: Option<Box<Expression>>,
8706    #[serde(default)]
8707    pub every: Option<Box<Expression>>,
8708}
8709
8710/// PartitionByListProperty
8711#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8712#[cfg_attr(feature = "bindings", derive(TS))]
8713pub struct PartitionByListProperty {
8714    #[serde(default)]
8715    pub partition_expressions: Option<Box<Expression>>,
8716    #[serde(default)]
8717    pub create_expressions: Option<Box<Expression>>,
8718}
8719
8720/// PartitionList
8721#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8722#[cfg_attr(feature = "bindings", derive(TS))]
8723pub struct PartitionList {
8724    pub this: Box<Expression>,
8725    #[serde(default)]
8726    pub expressions: Vec<Expression>,
8727}
8728
8729/// Partition - represents PARTITION/SUBPARTITION clause
8730#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8731#[cfg_attr(feature = "bindings", derive(TS))]
8732pub struct Partition {
8733    pub expressions: Vec<Expression>,
8734    #[serde(default)]
8735    pub subpartition: bool,
8736}
8737
8738/// RefreshTriggerProperty - Doris REFRESH clause for materialized views
8739/// e.g., REFRESH COMPLETE ON MANUAL, REFRESH AUTO ON SCHEDULE EVERY 5 MINUTE
8740#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8741#[cfg_attr(feature = "bindings", derive(TS))]
8742pub struct RefreshTriggerProperty {
8743    /// Method: COMPLETE or AUTO
8744    pub method: String,
8745    /// Trigger kind: MANUAL, COMMIT, or SCHEDULE
8746    #[serde(default)]
8747    pub kind: Option<String>,
8748    /// For SCHEDULE: EVERY n (the number)
8749    #[serde(default)]
8750    pub every: Option<Box<Expression>>,
8751    /// For SCHEDULE: the time unit (MINUTE, HOUR, DAY, etc.)
8752    #[serde(default)]
8753    pub unit: Option<String>,
8754    /// For SCHEDULE: STARTS 'datetime'
8755    #[serde(default)]
8756    pub starts: Option<Box<Expression>>,
8757}
8758
8759/// UniqueKeyProperty
8760#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8761#[cfg_attr(feature = "bindings", derive(TS))]
8762pub struct UniqueKeyProperty {
8763    #[serde(default)]
8764    pub expressions: Vec<Expression>,
8765}
8766
8767/// RollupProperty - StarRocks ROLLUP (index_name(col1, col2), ...)
8768#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8769#[cfg_attr(feature = "bindings", derive(TS))]
8770pub struct RollupProperty {
8771    pub expressions: Vec<RollupIndex>,
8772}
8773
8774/// RollupIndex - A single rollup index: name(col1, col2)
8775#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8776#[cfg_attr(feature = "bindings", derive(TS))]
8777pub struct RollupIndex {
8778    pub name: Identifier,
8779    pub expressions: Vec<Identifier>,
8780}
8781
8782/// PartitionBoundSpec
8783#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8784#[cfg_attr(feature = "bindings", derive(TS))]
8785pub struct PartitionBoundSpec {
8786    #[serde(default)]
8787    pub this: Option<Box<Expression>>,
8788    #[serde(default)]
8789    pub expression: Option<Box<Expression>>,
8790    #[serde(default)]
8791    pub from_expressions: Option<Box<Expression>>,
8792    #[serde(default)]
8793    pub to_expressions: Option<Box<Expression>>,
8794}
8795
8796/// PartitionedOfProperty
8797#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8798#[cfg_attr(feature = "bindings", derive(TS))]
8799pub struct PartitionedOfProperty {
8800    pub this: Box<Expression>,
8801    pub expression: Box<Expression>,
8802}
8803
8804/// RemoteWithConnectionModelProperty
8805#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8806#[cfg_attr(feature = "bindings", derive(TS))]
8807pub struct RemoteWithConnectionModelProperty {
8808    pub this: Box<Expression>,
8809}
8810
8811/// ReturnsProperty
8812#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8813#[cfg_attr(feature = "bindings", derive(TS))]
8814pub struct ReturnsProperty {
8815    #[serde(default)]
8816    pub this: Option<Box<Expression>>,
8817    #[serde(default)]
8818    pub is_table: Option<Box<Expression>>,
8819    #[serde(default)]
8820    pub table: Option<Box<Expression>>,
8821    #[serde(default)]
8822    pub null: Option<Box<Expression>>,
8823}
8824
8825/// RowFormatProperty
8826#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8827#[cfg_attr(feature = "bindings", derive(TS))]
8828pub struct RowFormatProperty {
8829    pub this: Box<Expression>,
8830}
8831
8832/// RowFormatDelimitedProperty
8833#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8834#[cfg_attr(feature = "bindings", derive(TS))]
8835pub struct RowFormatDelimitedProperty {
8836    #[serde(default)]
8837    pub fields: Option<Box<Expression>>,
8838    #[serde(default)]
8839    pub escaped: Option<Box<Expression>>,
8840    #[serde(default)]
8841    pub collection_items: Option<Box<Expression>>,
8842    #[serde(default)]
8843    pub map_keys: Option<Box<Expression>>,
8844    #[serde(default)]
8845    pub lines: Option<Box<Expression>>,
8846    #[serde(default)]
8847    pub null: Option<Box<Expression>>,
8848    #[serde(default)]
8849    pub serde: Option<Box<Expression>>,
8850}
8851
8852/// RowFormatSerdeProperty
8853#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8854#[cfg_attr(feature = "bindings", derive(TS))]
8855pub struct RowFormatSerdeProperty {
8856    pub this: Box<Expression>,
8857    #[serde(default)]
8858    pub serde_properties: Option<Box<Expression>>,
8859}
8860
8861/// QueryTransform
8862#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8863#[cfg_attr(feature = "bindings", derive(TS))]
8864pub struct QueryTransform {
8865    #[serde(default)]
8866    pub expressions: Vec<Expression>,
8867    #[serde(default)]
8868    pub command_script: Option<Box<Expression>>,
8869    #[serde(default)]
8870    pub schema: Option<Box<Expression>>,
8871    #[serde(default)]
8872    pub row_format_before: Option<Box<Expression>>,
8873    #[serde(default)]
8874    pub record_writer: Option<Box<Expression>>,
8875    #[serde(default)]
8876    pub row_format_after: Option<Box<Expression>>,
8877    #[serde(default)]
8878    pub record_reader: Option<Box<Expression>>,
8879}
8880
8881/// SampleProperty
8882#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8883#[cfg_attr(feature = "bindings", derive(TS))]
8884pub struct SampleProperty {
8885    pub this: Box<Expression>,
8886}
8887
8888/// SecurityProperty
8889#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8890#[cfg_attr(feature = "bindings", derive(TS))]
8891pub struct SecurityProperty {
8892    pub this: Box<Expression>,
8893}
8894
8895/// SchemaCommentProperty
8896#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8897#[cfg_attr(feature = "bindings", derive(TS))]
8898pub struct SchemaCommentProperty {
8899    pub this: Box<Expression>,
8900}
8901
8902/// SemanticView
8903#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8904#[cfg_attr(feature = "bindings", derive(TS))]
8905pub struct SemanticView {
8906    pub this: Box<Expression>,
8907    #[serde(default)]
8908    pub metrics: Option<Box<Expression>>,
8909    #[serde(default)]
8910    pub dimensions: Option<Box<Expression>>,
8911    #[serde(default)]
8912    pub facts: Option<Box<Expression>>,
8913    #[serde(default)]
8914    pub where_: Option<Box<Expression>>,
8915}
8916
8917/// SerdeProperties
8918#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8919#[cfg_attr(feature = "bindings", derive(TS))]
8920pub struct SerdeProperties {
8921    #[serde(default)]
8922    pub expressions: Vec<Expression>,
8923    #[serde(default)]
8924    pub with_: Option<Box<Expression>>,
8925}
8926
8927/// SetProperty
8928#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8929#[cfg_attr(feature = "bindings", derive(TS))]
8930pub struct SetProperty {
8931    #[serde(default)]
8932    pub multi: Option<Box<Expression>>,
8933}
8934
8935/// SharingProperty
8936#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8937#[cfg_attr(feature = "bindings", derive(TS))]
8938pub struct SharingProperty {
8939    #[serde(default)]
8940    pub this: Option<Box<Expression>>,
8941}
8942
8943/// SetConfigProperty
8944#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8945#[cfg_attr(feature = "bindings", derive(TS))]
8946pub struct SetConfigProperty {
8947    pub this: Box<Expression>,
8948}
8949
8950/// SettingsProperty
8951#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8952#[cfg_attr(feature = "bindings", derive(TS))]
8953pub struct SettingsProperty {
8954    #[serde(default)]
8955    pub expressions: Vec<Expression>,
8956}
8957
8958/// SortKeyProperty
8959#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8960#[cfg_attr(feature = "bindings", derive(TS))]
8961pub struct SortKeyProperty {
8962    pub this: Box<Expression>,
8963    #[serde(default)]
8964    pub compound: Option<Box<Expression>>,
8965}
8966
8967/// SqlReadWriteProperty
8968#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8969#[cfg_attr(feature = "bindings", derive(TS))]
8970pub struct SqlReadWriteProperty {
8971    pub this: Box<Expression>,
8972}
8973
8974/// SqlSecurityProperty
8975#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8976#[cfg_attr(feature = "bindings", derive(TS))]
8977pub struct SqlSecurityProperty {
8978    pub this: Box<Expression>,
8979}
8980
8981/// StabilityProperty
8982#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8983#[cfg_attr(feature = "bindings", derive(TS))]
8984pub struct StabilityProperty {
8985    pub this: Box<Expression>,
8986}
8987
8988/// StorageHandlerProperty
8989#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8990#[cfg_attr(feature = "bindings", derive(TS))]
8991pub struct StorageHandlerProperty {
8992    pub this: Box<Expression>,
8993}
8994
8995/// TemporaryProperty
8996#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8997#[cfg_attr(feature = "bindings", derive(TS))]
8998pub struct TemporaryProperty {
8999    #[serde(default)]
9000    pub this: Option<Box<Expression>>,
9001}
9002
9003/// Tags
9004#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9005#[cfg_attr(feature = "bindings", derive(TS))]
9006pub struct Tags {
9007    #[serde(default)]
9008    pub expressions: Vec<Expression>,
9009}
9010
9011/// TransformModelProperty
9012#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9013#[cfg_attr(feature = "bindings", derive(TS))]
9014pub struct TransformModelProperty {
9015    #[serde(default)]
9016    pub expressions: Vec<Expression>,
9017}
9018
9019/// TransientProperty
9020#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9021#[cfg_attr(feature = "bindings", derive(TS))]
9022pub struct TransientProperty {
9023    #[serde(default)]
9024    pub this: Option<Box<Expression>>,
9025}
9026
9027/// UsingTemplateProperty
9028#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9029#[cfg_attr(feature = "bindings", derive(TS))]
9030pub struct UsingTemplateProperty {
9031    pub this: Box<Expression>,
9032}
9033
9034/// ViewAttributeProperty
9035#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9036#[cfg_attr(feature = "bindings", derive(TS))]
9037pub struct ViewAttributeProperty {
9038    pub this: Box<Expression>,
9039}
9040
9041/// VolatileProperty
9042#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9043#[cfg_attr(feature = "bindings", derive(TS))]
9044pub struct VolatileProperty {
9045    #[serde(default)]
9046    pub this: Option<Box<Expression>>,
9047}
9048
9049/// WithDataProperty
9050#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9051#[cfg_attr(feature = "bindings", derive(TS))]
9052pub struct WithDataProperty {
9053    #[serde(default)]
9054    pub no: Option<Box<Expression>>,
9055    #[serde(default)]
9056    pub statistics: Option<Box<Expression>>,
9057}
9058
9059/// WithJournalTableProperty
9060#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9061#[cfg_attr(feature = "bindings", derive(TS))]
9062pub struct WithJournalTableProperty {
9063    pub this: Box<Expression>,
9064}
9065
9066/// WithSchemaBindingProperty
9067#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9068#[cfg_attr(feature = "bindings", derive(TS))]
9069pub struct WithSchemaBindingProperty {
9070    pub this: Box<Expression>,
9071}
9072
9073/// WithSystemVersioningProperty
9074#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9075#[cfg_attr(feature = "bindings", derive(TS))]
9076pub struct WithSystemVersioningProperty {
9077    #[serde(default)]
9078    pub on: Option<Box<Expression>>,
9079    #[serde(default)]
9080    pub this: Option<Box<Expression>>,
9081    #[serde(default)]
9082    pub data_consistency: Option<Box<Expression>>,
9083    #[serde(default)]
9084    pub retention_period: Option<Box<Expression>>,
9085    #[serde(default)]
9086    pub with_: Option<Box<Expression>>,
9087}
9088
9089/// WithProcedureOptions
9090#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9091#[cfg_attr(feature = "bindings", derive(TS))]
9092pub struct WithProcedureOptions {
9093    #[serde(default)]
9094    pub expressions: Vec<Expression>,
9095}
9096
9097/// EncodeProperty
9098#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9099#[cfg_attr(feature = "bindings", derive(TS))]
9100pub struct EncodeProperty {
9101    pub this: Box<Expression>,
9102    #[serde(default)]
9103    pub properties: Vec<Expression>,
9104    #[serde(default)]
9105    pub key: Option<Box<Expression>>,
9106}
9107
9108/// IncludeProperty
9109#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9110#[cfg_attr(feature = "bindings", derive(TS))]
9111pub struct IncludeProperty {
9112    pub this: Box<Expression>,
9113    #[serde(default)]
9114    pub alias: Option<String>,
9115    #[serde(default)]
9116    pub column_def: Option<Box<Expression>>,
9117}
9118
9119/// Properties
9120#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9121#[cfg_attr(feature = "bindings", derive(TS))]
9122pub struct Properties {
9123    #[serde(default)]
9124    pub expressions: Vec<Expression>,
9125}
9126
9127/// InputOutputFormat
9128#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9129#[cfg_attr(feature = "bindings", derive(TS))]
9130pub struct InputOutputFormat {
9131    #[serde(default)]
9132    pub input_format: Option<Box<Expression>>,
9133    #[serde(default)]
9134    pub output_format: Option<Box<Expression>>,
9135}
9136
9137/// Reference
9138#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9139#[cfg_attr(feature = "bindings", derive(TS))]
9140pub struct Reference {
9141    pub this: Box<Expression>,
9142    #[serde(default)]
9143    pub expressions: Vec<Expression>,
9144    #[serde(default)]
9145    pub options: Vec<Expression>,
9146}
9147
9148/// QueryOption
9149#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9150#[cfg_attr(feature = "bindings", derive(TS))]
9151pub struct QueryOption {
9152    pub this: Box<Expression>,
9153    #[serde(default)]
9154    pub expression: Option<Box<Expression>>,
9155}
9156
9157/// WithTableHint
9158#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9159#[cfg_attr(feature = "bindings", derive(TS))]
9160pub struct WithTableHint {
9161    #[serde(default)]
9162    pub expressions: Vec<Expression>,
9163}
9164
9165/// IndexTableHint
9166#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9167#[cfg_attr(feature = "bindings", derive(TS))]
9168pub struct IndexTableHint {
9169    pub this: Box<Expression>,
9170    #[serde(default)]
9171    pub expressions: Vec<Expression>,
9172    #[serde(default)]
9173    pub target: Option<Box<Expression>>,
9174}
9175
9176/// Get
9177#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9178#[cfg_attr(feature = "bindings", derive(TS))]
9179pub struct Get {
9180    pub this: Box<Expression>,
9181    #[serde(default)]
9182    pub target: Option<Box<Expression>>,
9183    #[serde(default)]
9184    pub properties: Vec<Expression>,
9185}
9186
9187/// SetOperation
9188#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9189#[cfg_attr(feature = "bindings", derive(TS))]
9190pub struct SetOperation {
9191    #[serde(default)]
9192    pub with_: Option<Box<Expression>>,
9193    pub this: Box<Expression>,
9194    pub expression: Box<Expression>,
9195    #[serde(default)]
9196    pub distinct: bool,
9197    #[serde(default)]
9198    pub by_name: Option<Box<Expression>>,
9199    #[serde(default)]
9200    pub side: Option<Box<Expression>>,
9201    #[serde(default)]
9202    pub kind: Option<String>,
9203    #[serde(default)]
9204    pub on: Option<Box<Expression>>,
9205}
9206
9207/// Var - Simple variable reference (for SQL variables, keywords as values)
9208#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9209#[cfg_attr(feature = "bindings", derive(TS))]
9210pub struct Var {
9211    pub this: String,
9212}
9213
9214/// Version
9215#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9216#[cfg_attr(feature = "bindings", derive(TS))]
9217pub struct Version {
9218    pub this: Box<Expression>,
9219    pub kind: String,
9220    #[serde(default)]
9221    pub expression: Option<Box<Expression>>,
9222}
9223
9224/// Schema
9225#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9226#[cfg_attr(feature = "bindings", derive(TS))]
9227pub struct Schema {
9228    #[serde(default)]
9229    pub this: Option<Box<Expression>>,
9230    #[serde(default)]
9231    pub expressions: Vec<Expression>,
9232}
9233
9234/// Lock
9235#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9236#[cfg_attr(feature = "bindings", derive(TS))]
9237pub struct Lock {
9238    #[serde(default)]
9239    pub update: Option<Box<Expression>>,
9240    #[serde(default)]
9241    pub expressions: Vec<Expression>,
9242    #[serde(default)]
9243    pub wait: Option<Box<Expression>>,
9244    #[serde(default)]
9245    pub key: Option<Box<Expression>>,
9246}
9247
9248/// TableSample - wraps an expression with a TABLESAMPLE clause
9249/// Used when TABLESAMPLE follows a non-Table expression (subquery, function, etc.)
9250#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9251#[cfg_attr(feature = "bindings", derive(TS))]
9252pub struct TableSample {
9253    /// The expression being sampled (subquery, function, etc.)
9254    #[serde(default, skip_serializing_if = "Option::is_none")]
9255    pub this: Option<Box<Expression>>,
9256    /// The sample specification
9257    #[serde(default, skip_serializing_if = "Option::is_none")]
9258    pub sample: Option<Box<Sample>>,
9259    #[serde(default)]
9260    pub expressions: Vec<Expression>,
9261    #[serde(default)]
9262    pub method: Option<String>,
9263    #[serde(default)]
9264    pub bucket_numerator: Option<Box<Expression>>,
9265    #[serde(default)]
9266    pub bucket_denominator: Option<Box<Expression>>,
9267    #[serde(default)]
9268    pub bucket_field: Option<Box<Expression>>,
9269    #[serde(default)]
9270    pub percent: Option<Box<Expression>>,
9271    #[serde(default)]
9272    pub rows: Option<Box<Expression>>,
9273    #[serde(default)]
9274    pub size: Option<i64>,
9275    #[serde(default)]
9276    pub seed: Option<Box<Expression>>,
9277}
9278
9279/// Tags are used for generating arbitrary sql like SELECT <span>x</span>.
9280#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9281#[cfg_attr(feature = "bindings", derive(TS))]
9282pub struct Tag {
9283    #[serde(default)]
9284    pub this: Option<Box<Expression>>,
9285    #[serde(default)]
9286    pub prefix: Option<Box<Expression>>,
9287    #[serde(default)]
9288    pub postfix: Option<Box<Expression>>,
9289}
9290
9291/// UnpivotColumns
9292#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9293#[cfg_attr(feature = "bindings", derive(TS))]
9294pub struct UnpivotColumns {
9295    pub this: Box<Expression>,
9296    #[serde(default)]
9297    pub expressions: Vec<Expression>,
9298}
9299
9300/// SessionParameter
9301#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9302#[cfg_attr(feature = "bindings", derive(TS))]
9303pub struct SessionParameter {
9304    pub this: Box<Expression>,
9305    #[serde(default)]
9306    pub kind: Option<String>,
9307}
9308
9309/// PseudoType
9310#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9311#[cfg_attr(feature = "bindings", derive(TS))]
9312pub struct PseudoType {
9313    pub this: Box<Expression>,
9314}
9315
9316/// ObjectIdentifier
9317#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9318#[cfg_attr(feature = "bindings", derive(TS))]
9319pub struct ObjectIdentifier {
9320    pub this: Box<Expression>,
9321}
9322
9323/// Transaction
9324#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9325#[cfg_attr(feature = "bindings", derive(TS))]
9326pub struct Transaction {
9327    #[serde(default)]
9328    pub this: Option<Box<Expression>>,
9329    #[serde(default)]
9330    pub modes: Option<Box<Expression>>,
9331    #[serde(default)]
9332    pub mark: Option<Box<Expression>>,
9333}
9334
9335/// Commit
9336#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9337#[cfg_attr(feature = "bindings", derive(TS))]
9338pub struct Commit {
9339    #[serde(default)]
9340    pub chain: Option<Box<Expression>>,
9341    #[serde(default)]
9342    pub this: Option<Box<Expression>>,
9343    #[serde(default)]
9344    pub durability: Option<Box<Expression>>,
9345}
9346
9347/// Rollback
9348#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9349#[cfg_attr(feature = "bindings", derive(TS))]
9350pub struct Rollback {
9351    #[serde(default)]
9352    pub savepoint: Option<Box<Expression>>,
9353    #[serde(default)]
9354    pub this: Option<Box<Expression>>,
9355}
9356
9357/// AlterSession
9358#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9359#[cfg_attr(feature = "bindings", derive(TS))]
9360pub struct AlterSession {
9361    #[serde(default)]
9362    pub expressions: Vec<Expression>,
9363    #[serde(default)]
9364    pub unset: Option<Box<Expression>>,
9365}
9366
9367/// Analyze
9368#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9369#[cfg_attr(feature = "bindings", derive(TS))]
9370pub struct Analyze {
9371    #[serde(default)]
9372    pub kind: Option<String>,
9373    #[serde(default)]
9374    pub this: Option<Box<Expression>>,
9375    #[serde(default)]
9376    pub options: Vec<Expression>,
9377    #[serde(default)]
9378    pub mode: Option<Box<Expression>>,
9379    #[serde(default)]
9380    pub partition: Option<Box<Expression>>,
9381    #[serde(default)]
9382    pub expression: Option<Box<Expression>>,
9383    #[serde(default)]
9384    pub properties: Vec<Expression>,
9385    /// Column list for ANALYZE tbl(col1, col2) syntax (PostgreSQL)
9386    #[serde(default, skip_serializing_if = "Vec::is_empty")]
9387    pub columns: Vec<String>,
9388}
9389
9390/// AnalyzeStatistics
9391#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9392#[cfg_attr(feature = "bindings", derive(TS))]
9393pub struct AnalyzeStatistics {
9394    pub kind: String,
9395    #[serde(default)]
9396    pub option: Option<Box<Expression>>,
9397    #[serde(default)]
9398    pub this: Option<Box<Expression>>,
9399    #[serde(default)]
9400    pub expressions: Vec<Expression>,
9401}
9402
9403/// AnalyzeHistogram
9404#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9405#[cfg_attr(feature = "bindings", derive(TS))]
9406pub struct AnalyzeHistogram {
9407    pub this: Box<Expression>,
9408    #[serde(default)]
9409    pub expressions: Vec<Expression>,
9410    #[serde(default)]
9411    pub expression: Option<Box<Expression>>,
9412    #[serde(default)]
9413    pub update_options: Option<Box<Expression>>,
9414}
9415
9416/// AnalyzeSample
9417#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9418#[cfg_attr(feature = "bindings", derive(TS))]
9419pub struct AnalyzeSample {
9420    pub kind: String,
9421    #[serde(default)]
9422    pub sample: Option<Box<Expression>>,
9423}
9424
9425/// AnalyzeListChainedRows
9426#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9427#[cfg_attr(feature = "bindings", derive(TS))]
9428pub struct AnalyzeListChainedRows {
9429    #[serde(default)]
9430    pub expression: Option<Box<Expression>>,
9431}
9432
9433/// AnalyzeDelete
9434#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9435#[cfg_attr(feature = "bindings", derive(TS))]
9436pub struct AnalyzeDelete {
9437    #[serde(default)]
9438    pub kind: Option<String>,
9439}
9440
9441/// AnalyzeWith
9442#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9443#[cfg_attr(feature = "bindings", derive(TS))]
9444pub struct AnalyzeWith {
9445    #[serde(default)]
9446    pub expressions: Vec<Expression>,
9447}
9448
9449/// AnalyzeValidate
9450#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9451#[cfg_attr(feature = "bindings", derive(TS))]
9452pub struct AnalyzeValidate {
9453    pub kind: String,
9454    #[serde(default)]
9455    pub this: Option<Box<Expression>>,
9456    #[serde(default)]
9457    pub expression: Option<Box<Expression>>,
9458}
9459
9460/// AddPartition
9461#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9462#[cfg_attr(feature = "bindings", derive(TS))]
9463pub struct AddPartition {
9464    pub this: Box<Expression>,
9465    #[serde(default)]
9466    pub exists: bool,
9467    #[serde(default)]
9468    pub location: Option<Box<Expression>>,
9469}
9470
9471/// AttachOption
9472#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9473#[cfg_attr(feature = "bindings", derive(TS))]
9474pub struct AttachOption {
9475    pub this: Box<Expression>,
9476    #[serde(default)]
9477    pub expression: Option<Box<Expression>>,
9478}
9479
9480/// DropPartition
9481#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9482#[cfg_attr(feature = "bindings", derive(TS))]
9483pub struct DropPartition {
9484    #[serde(default)]
9485    pub expressions: Vec<Expression>,
9486    #[serde(default)]
9487    pub exists: bool,
9488}
9489
9490/// ReplacePartition
9491#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9492#[cfg_attr(feature = "bindings", derive(TS))]
9493pub struct ReplacePartition {
9494    pub expression: Box<Expression>,
9495    #[serde(default)]
9496    pub source: Option<Box<Expression>>,
9497}
9498
9499/// DPipe
9500#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9501#[cfg_attr(feature = "bindings", derive(TS))]
9502pub struct DPipe {
9503    pub this: Box<Expression>,
9504    pub expression: Box<Expression>,
9505    #[serde(default)]
9506    pub safe: Option<Box<Expression>>,
9507}
9508
9509/// Operator
9510#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9511#[cfg_attr(feature = "bindings", derive(TS))]
9512pub struct Operator {
9513    pub this: Box<Expression>,
9514    #[serde(default)]
9515    pub operator: Option<Box<Expression>>,
9516    pub expression: Box<Expression>,
9517}
9518
9519/// PivotAny
9520#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9521#[cfg_attr(feature = "bindings", derive(TS))]
9522pub struct PivotAny {
9523    #[serde(default)]
9524    pub this: Option<Box<Expression>>,
9525}
9526
9527/// Aliases
9528#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9529#[cfg_attr(feature = "bindings", derive(TS))]
9530pub struct Aliases {
9531    pub this: Box<Expression>,
9532    #[serde(default)]
9533    pub expressions: Vec<Expression>,
9534}
9535
9536/// AtIndex
9537#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9538#[cfg_attr(feature = "bindings", derive(TS))]
9539pub struct AtIndex {
9540    pub this: Box<Expression>,
9541    pub expression: Box<Expression>,
9542}
9543
9544/// FromTimeZone
9545#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9546#[cfg_attr(feature = "bindings", derive(TS))]
9547pub struct FromTimeZone {
9548    pub this: Box<Expression>,
9549    #[serde(default)]
9550    pub zone: Option<Box<Expression>>,
9551}
9552
9553/// Format override for a column in Teradata
9554#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9555#[cfg_attr(feature = "bindings", derive(TS))]
9556pub struct FormatPhrase {
9557    pub this: Box<Expression>,
9558    pub format: String,
9559}
9560
9561/// ForIn
9562#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9563#[cfg_attr(feature = "bindings", derive(TS))]
9564pub struct ForIn {
9565    pub this: Box<Expression>,
9566    pub expression: Box<Expression>,
9567}
9568
9569/// Automatically converts unit arg into a var.
9570#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9571#[cfg_attr(feature = "bindings", derive(TS))]
9572pub struct TimeUnit {
9573    #[serde(default)]
9574    pub unit: Option<String>,
9575}
9576
9577/// IntervalOp
9578#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9579#[cfg_attr(feature = "bindings", derive(TS))]
9580pub struct IntervalOp {
9581    #[serde(default)]
9582    pub unit: Option<String>,
9583    pub expression: Box<Expression>,
9584}
9585
9586/// HavingMax
9587#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9588#[cfg_attr(feature = "bindings", derive(TS))]
9589pub struct HavingMax {
9590    pub this: Box<Expression>,
9591    pub expression: Box<Expression>,
9592    #[serde(default)]
9593    pub max: Option<Box<Expression>>,
9594}
9595
9596/// CosineDistance
9597#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9598#[cfg_attr(feature = "bindings", derive(TS))]
9599pub struct CosineDistance {
9600    pub this: Box<Expression>,
9601    pub expression: Box<Expression>,
9602}
9603
9604/// DotProduct
9605#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9606#[cfg_attr(feature = "bindings", derive(TS))]
9607pub struct DotProduct {
9608    pub this: Box<Expression>,
9609    pub expression: Box<Expression>,
9610}
9611
9612/// EuclideanDistance
9613#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9614#[cfg_attr(feature = "bindings", derive(TS))]
9615pub struct EuclideanDistance {
9616    pub this: Box<Expression>,
9617    pub expression: Box<Expression>,
9618}
9619
9620/// ManhattanDistance
9621#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9622#[cfg_attr(feature = "bindings", derive(TS))]
9623pub struct ManhattanDistance {
9624    pub this: Box<Expression>,
9625    pub expression: Box<Expression>,
9626}
9627
9628/// JarowinklerSimilarity
9629#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9630#[cfg_attr(feature = "bindings", derive(TS))]
9631pub struct JarowinklerSimilarity {
9632    pub this: Box<Expression>,
9633    pub expression: Box<Expression>,
9634}
9635
9636/// Booland
9637#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9638#[cfg_attr(feature = "bindings", derive(TS))]
9639pub struct Booland {
9640    pub this: Box<Expression>,
9641    pub expression: Box<Expression>,
9642}
9643
9644/// Boolor
9645#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9646#[cfg_attr(feature = "bindings", derive(TS))]
9647pub struct Boolor {
9648    pub this: Box<Expression>,
9649    pub expression: Box<Expression>,
9650}
9651
9652/// ParameterizedAgg
9653#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9654#[cfg_attr(feature = "bindings", derive(TS))]
9655pub struct ParameterizedAgg {
9656    pub this: Box<Expression>,
9657    #[serde(default)]
9658    pub expressions: Vec<Expression>,
9659    #[serde(default)]
9660    pub params: Vec<Expression>,
9661}
9662
9663/// ArgMax
9664#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9665#[cfg_attr(feature = "bindings", derive(TS))]
9666pub struct ArgMax {
9667    pub this: Box<Expression>,
9668    pub expression: Box<Expression>,
9669    #[serde(default)]
9670    pub count: Option<Box<Expression>>,
9671}
9672
9673/// ArgMin
9674#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9675#[cfg_attr(feature = "bindings", derive(TS))]
9676pub struct ArgMin {
9677    pub this: Box<Expression>,
9678    pub expression: Box<Expression>,
9679    #[serde(default)]
9680    pub count: Option<Box<Expression>>,
9681}
9682
9683/// ApproxTopK
9684#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9685#[cfg_attr(feature = "bindings", derive(TS))]
9686pub struct ApproxTopK {
9687    pub this: Box<Expression>,
9688    #[serde(default)]
9689    pub expression: Option<Box<Expression>>,
9690    #[serde(default)]
9691    pub counters: Option<Box<Expression>>,
9692}
9693
9694/// ApproxTopKAccumulate
9695#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9696#[cfg_attr(feature = "bindings", derive(TS))]
9697pub struct ApproxTopKAccumulate {
9698    pub this: Box<Expression>,
9699    #[serde(default)]
9700    pub expression: Option<Box<Expression>>,
9701}
9702
9703/// ApproxTopKCombine
9704#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9705#[cfg_attr(feature = "bindings", derive(TS))]
9706pub struct ApproxTopKCombine {
9707    pub this: Box<Expression>,
9708    #[serde(default)]
9709    pub expression: Option<Box<Expression>>,
9710}
9711
9712/// ApproxTopKEstimate
9713#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9714#[cfg_attr(feature = "bindings", derive(TS))]
9715pub struct ApproxTopKEstimate {
9716    pub this: Box<Expression>,
9717    #[serde(default)]
9718    pub expression: Option<Box<Expression>>,
9719}
9720
9721/// ApproxTopSum
9722#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9723#[cfg_attr(feature = "bindings", derive(TS))]
9724pub struct ApproxTopSum {
9725    pub this: Box<Expression>,
9726    pub expression: Box<Expression>,
9727    #[serde(default)]
9728    pub count: Option<Box<Expression>>,
9729}
9730
9731/// ApproxQuantiles
9732#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9733#[cfg_attr(feature = "bindings", derive(TS))]
9734pub struct ApproxQuantiles {
9735    pub this: Box<Expression>,
9736    #[serde(default)]
9737    pub expression: Option<Box<Expression>>,
9738}
9739
9740/// Minhash
9741#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9742#[cfg_attr(feature = "bindings", derive(TS))]
9743pub struct Minhash {
9744    pub this: Box<Expression>,
9745    #[serde(default)]
9746    pub expressions: Vec<Expression>,
9747}
9748
9749/// FarmFingerprint
9750#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9751#[cfg_attr(feature = "bindings", derive(TS))]
9752pub struct FarmFingerprint {
9753    #[serde(default)]
9754    pub expressions: Vec<Expression>,
9755}
9756
9757/// Float64
9758#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9759#[cfg_attr(feature = "bindings", derive(TS))]
9760pub struct Float64 {
9761    pub this: Box<Expression>,
9762    #[serde(default)]
9763    pub expression: Option<Box<Expression>>,
9764}
9765
9766/// Transform
9767#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9768#[cfg_attr(feature = "bindings", derive(TS))]
9769pub struct Transform {
9770    pub this: Box<Expression>,
9771    pub expression: Box<Expression>,
9772}
9773
9774/// Translate
9775#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9776#[cfg_attr(feature = "bindings", derive(TS))]
9777pub struct Translate {
9778    pub this: Box<Expression>,
9779    #[serde(default)]
9780    pub from_: Option<Box<Expression>>,
9781    #[serde(default)]
9782    pub to: Option<Box<Expression>>,
9783}
9784
9785/// Grouping
9786#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9787#[cfg_attr(feature = "bindings", derive(TS))]
9788pub struct Grouping {
9789    #[serde(default)]
9790    pub expressions: Vec<Expression>,
9791}
9792
9793/// GroupingId
9794#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9795#[cfg_attr(feature = "bindings", derive(TS))]
9796pub struct GroupingId {
9797    #[serde(default)]
9798    pub expressions: Vec<Expression>,
9799}
9800
9801/// Anonymous
9802#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9803#[cfg_attr(feature = "bindings", derive(TS))]
9804pub struct Anonymous {
9805    pub this: Box<Expression>,
9806    #[serde(default)]
9807    pub expressions: Vec<Expression>,
9808}
9809
9810/// AnonymousAggFunc
9811#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9812#[cfg_attr(feature = "bindings", derive(TS))]
9813pub struct AnonymousAggFunc {
9814    pub this: Box<Expression>,
9815    #[serde(default)]
9816    pub expressions: Vec<Expression>,
9817}
9818
9819/// CombinedAggFunc
9820#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9821#[cfg_attr(feature = "bindings", derive(TS))]
9822pub struct CombinedAggFunc {
9823    pub this: Box<Expression>,
9824    #[serde(default)]
9825    pub expressions: Vec<Expression>,
9826}
9827
9828/// CombinedParameterizedAgg
9829#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9830#[cfg_attr(feature = "bindings", derive(TS))]
9831pub struct CombinedParameterizedAgg {
9832    pub this: Box<Expression>,
9833    #[serde(default)]
9834    pub expressions: Vec<Expression>,
9835    #[serde(default)]
9836    pub params: Vec<Expression>,
9837}
9838
9839/// HashAgg
9840#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9841#[cfg_attr(feature = "bindings", derive(TS))]
9842pub struct HashAgg {
9843    pub this: Box<Expression>,
9844    #[serde(default)]
9845    pub expressions: Vec<Expression>,
9846}
9847
9848/// Hll
9849#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9850#[cfg_attr(feature = "bindings", derive(TS))]
9851pub struct Hll {
9852    pub this: Box<Expression>,
9853    #[serde(default)]
9854    pub expressions: Vec<Expression>,
9855}
9856
9857/// Apply
9858#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9859#[cfg_attr(feature = "bindings", derive(TS))]
9860pub struct Apply {
9861    pub this: Box<Expression>,
9862    pub expression: Box<Expression>,
9863}
9864
9865/// ToBoolean
9866#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9867#[cfg_attr(feature = "bindings", derive(TS))]
9868pub struct ToBoolean {
9869    pub this: Box<Expression>,
9870    #[serde(default)]
9871    pub safe: Option<Box<Expression>>,
9872}
9873
9874/// List
9875#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9876#[cfg_attr(feature = "bindings", derive(TS))]
9877pub struct List {
9878    #[serde(default)]
9879    pub expressions: Vec<Expression>,
9880}
9881
9882/// ToMap - Materialize-style map constructor
9883/// Can hold either:
9884/// - A SELECT subquery (MAP(SELECT 'a', 1))
9885/// - A struct with key=>value entries (MAP['a' => 1, 'b' => 2])
9886#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9887#[cfg_attr(feature = "bindings", derive(TS))]
9888pub struct ToMap {
9889    /// Either a Select subquery or a Struct containing PropertyEQ entries
9890    pub this: Box<Expression>,
9891}
9892
9893/// Pad
9894#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9895#[cfg_attr(feature = "bindings", derive(TS))]
9896pub struct Pad {
9897    pub this: Box<Expression>,
9898    pub expression: Box<Expression>,
9899    #[serde(default)]
9900    pub fill_pattern: Option<Box<Expression>>,
9901    #[serde(default)]
9902    pub is_left: Option<Box<Expression>>,
9903}
9904
9905/// ToChar
9906#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9907#[cfg_attr(feature = "bindings", derive(TS))]
9908pub struct ToChar {
9909    pub this: Box<Expression>,
9910    #[serde(default)]
9911    pub format: Option<String>,
9912    #[serde(default)]
9913    pub nlsparam: Option<Box<Expression>>,
9914    #[serde(default)]
9915    pub is_numeric: Option<Box<Expression>>,
9916}
9917
9918/// StringFunc - String type conversion function (BigQuery STRING)
9919#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9920#[cfg_attr(feature = "bindings", derive(TS))]
9921pub struct StringFunc {
9922    pub this: Box<Expression>,
9923    #[serde(default)]
9924    pub zone: Option<Box<Expression>>,
9925}
9926
9927/// ToNumber
9928#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9929#[cfg_attr(feature = "bindings", derive(TS))]
9930pub struct ToNumber {
9931    pub this: Box<Expression>,
9932    #[serde(default)]
9933    pub format: Option<Box<Expression>>,
9934    #[serde(default)]
9935    pub nlsparam: Option<Box<Expression>>,
9936    #[serde(default)]
9937    pub precision: Option<Box<Expression>>,
9938    #[serde(default)]
9939    pub scale: Option<Box<Expression>>,
9940    #[serde(default)]
9941    pub safe: Option<Box<Expression>>,
9942    #[serde(default)]
9943    pub safe_name: Option<Box<Expression>>,
9944}
9945
9946/// ToDouble
9947#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9948#[cfg_attr(feature = "bindings", derive(TS))]
9949pub struct ToDouble {
9950    pub this: Box<Expression>,
9951    #[serde(default)]
9952    pub format: Option<String>,
9953    #[serde(default)]
9954    pub safe: Option<Box<Expression>>,
9955}
9956
9957/// ToDecfloat
9958#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9959#[cfg_attr(feature = "bindings", derive(TS))]
9960pub struct ToDecfloat {
9961    pub this: Box<Expression>,
9962    #[serde(default)]
9963    pub format: Option<String>,
9964}
9965
9966/// TryToDecfloat
9967#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9968#[cfg_attr(feature = "bindings", derive(TS))]
9969pub struct TryToDecfloat {
9970    pub this: Box<Expression>,
9971    #[serde(default)]
9972    pub format: Option<String>,
9973}
9974
9975/// ToFile
9976#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9977#[cfg_attr(feature = "bindings", derive(TS))]
9978pub struct ToFile {
9979    pub this: Box<Expression>,
9980    #[serde(default)]
9981    pub path: Option<Box<Expression>>,
9982    #[serde(default)]
9983    pub safe: Option<Box<Expression>>,
9984}
9985
9986/// Columns
9987#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9988#[cfg_attr(feature = "bindings", derive(TS))]
9989pub struct Columns {
9990    pub this: Box<Expression>,
9991    #[serde(default)]
9992    pub unpack: Option<Box<Expression>>,
9993}
9994
9995/// ConvertToCharset
9996#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9997#[cfg_attr(feature = "bindings", derive(TS))]
9998pub struct ConvertToCharset {
9999    pub this: Box<Expression>,
10000    #[serde(default)]
10001    pub dest: Option<Box<Expression>>,
10002    #[serde(default)]
10003    pub source: Option<Box<Expression>>,
10004}
10005
10006/// ConvertTimezone
10007#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10008#[cfg_attr(feature = "bindings", derive(TS))]
10009pub struct ConvertTimezone {
10010    #[serde(default)]
10011    pub source_tz: Option<Box<Expression>>,
10012    #[serde(default)]
10013    pub target_tz: Option<Box<Expression>>,
10014    #[serde(default)]
10015    pub timestamp: Option<Box<Expression>>,
10016    #[serde(default)]
10017    pub options: Vec<Expression>,
10018}
10019
10020/// GenerateSeries
10021#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10022#[cfg_attr(feature = "bindings", derive(TS))]
10023pub struct GenerateSeries {
10024    #[serde(default)]
10025    pub start: Option<Box<Expression>>,
10026    #[serde(default)]
10027    pub end: Option<Box<Expression>>,
10028    #[serde(default)]
10029    pub step: Option<Box<Expression>>,
10030    #[serde(default)]
10031    pub is_end_exclusive: Option<Box<Expression>>,
10032}
10033
10034/// AIAgg
10035#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10036#[cfg_attr(feature = "bindings", derive(TS))]
10037pub struct AIAgg {
10038    pub this: Box<Expression>,
10039    pub expression: Box<Expression>,
10040}
10041
10042/// AIClassify
10043#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10044#[cfg_attr(feature = "bindings", derive(TS))]
10045pub struct AIClassify {
10046    pub this: Box<Expression>,
10047    #[serde(default)]
10048    pub categories: Option<Box<Expression>>,
10049    #[serde(default)]
10050    pub config: Option<Box<Expression>>,
10051}
10052
10053/// ArrayAll
10054#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10055#[cfg_attr(feature = "bindings", derive(TS))]
10056pub struct ArrayAll {
10057    pub this: Box<Expression>,
10058    pub expression: Box<Expression>,
10059}
10060
10061/// ArrayAny
10062#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10063#[cfg_attr(feature = "bindings", derive(TS))]
10064pub struct ArrayAny {
10065    pub this: Box<Expression>,
10066    pub expression: Box<Expression>,
10067}
10068
10069/// ArrayConstructCompact
10070#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10071#[cfg_attr(feature = "bindings", derive(TS))]
10072pub struct ArrayConstructCompact {
10073    #[serde(default)]
10074    pub expressions: Vec<Expression>,
10075}
10076
10077/// StPoint
10078#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10079#[cfg_attr(feature = "bindings", derive(TS))]
10080pub struct StPoint {
10081    pub this: Box<Expression>,
10082    pub expression: Box<Expression>,
10083    #[serde(default)]
10084    pub null: Option<Box<Expression>>,
10085}
10086
10087/// StDistance
10088#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10089#[cfg_attr(feature = "bindings", derive(TS))]
10090pub struct StDistance {
10091    pub this: Box<Expression>,
10092    pub expression: Box<Expression>,
10093    #[serde(default)]
10094    pub use_spheroid: Option<Box<Expression>>,
10095}
10096
10097/// StringToArray
10098#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10099#[cfg_attr(feature = "bindings", derive(TS))]
10100pub struct StringToArray {
10101    pub this: Box<Expression>,
10102    #[serde(default)]
10103    pub expression: Option<Box<Expression>>,
10104    #[serde(default)]
10105    pub null: Option<Box<Expression>>,
10106}
10107
10108/// ArraySum
10109#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10110#[cfg_attr(feature = "bindings", derive(TS))]
10111pub struct ArraySum {
10112    pub this: Box<Expression>,
10113    #[serde(default)]
10114    pub expression: Option<Box<Expression>>,
10115}
10116
10117/// ObjectAgg
10118#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10119#[cfg_attr(feature = "bindings", derive(TS))]
10120pub struct ObjectAgg {
10121    pub this: Box<Expression>,
10122    pub expression: Box<Expression>,
10123}
10124
10125/// CastToStrType
10126#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10127#[cfg_attr(feature = "bindings", derive(TS))]
10128pub struct CastToStrType {
10129    pub this: Box<Expression>,
10130    #[serde(default)]
10131    pub to: Option<Box<Expression>>,
10132}
10133
10134/// CheckJson
10135#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10136#[cfg_attr(feature = "bindings", derive(TS))]
10137pub struct CheckJson {
10138    pub this: Box<Expression>,
10139}
10140
10141/// CheckXml
10142#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10143#[cfg_attr(feature = "bindings", derive(TS))]
10144pub struct CheckXml {
10145    pub this: Box<Expression>,
10146    #[serde(default)]
10147    pub disable_auto_convert: Option<Box<Expression>>,
10148}
10149
10150/// TranslateCharacters
10151#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10152#[cfg_attr(feature = "bindings", derive(TS))]
10153pub struct TranslateCharacters {
10154    pub this: Box<Expression>,
10155    pub expression: Box<Expression>,
10156    #[serde(default)]
10157    pub with_error: Option<Box<Expression>>,
10158}
10159
10160/// CurrentSchemas
10161#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10162#[cfg_attr(feature = "bindings", derive(TS))]
10163pub struct CurrentSchemas {
10164    #[serde(default)]
10165    pub this: Option<Box<Expression>>,
10166}
10167
10168/// CurrentDatetime
10169#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10170#[cfg_attr(feature = "bindings", derive(TS))]
10171pub struct CurrentDatetime {
10172    #[serde(default)]
10173    pub this: Option<Box<Expression>>,
10174}
10175
10176/// Localtime
10177#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10178#[cfg_attr(feature = "bindings", derive(TS))]
10179pub struct Localtime {
10180    #[serde(default)]
10181    pub this: Option<Box<Expression>>,
10182}
10183
10184/// Localtimestamp
10185#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10186#[cfg_attr(feature = "bindings", derive(TS))]
10187pub struct Localtimestamp {
10188    #[serde(default)]
10189    pub this: Option<Box<Expression>>,
10190}
10191
10192/// Systimestamp
10193#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10194#[cfg_attr(feature = "bindings", derive(TS))]
10195pub struct Systimestamp {
10196    #[serde(default)]
10197    pub this: Option<Box<Expression>>,
10198}
10199
10200/// CurrentSchema
10201#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10202#[cfg_attr(feature = "bindings", derive(TS))]
10203pub struct CurrentSchema {
10204    #[serde(default)]
10205    pub this: Option<Box<Expression>>,
10206}
10207
10208/// CurrentUser
10209#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10210#[cfg_attr(feature = "bindings", derive(TS))]
10211pub struct CurrentUser {
10212    #[serde(default)]
10213    pub this: Option<Box<Expression>>,
10214}
10215
10216/// SessionUser - MySQL/PostgreSQL SESSION_USER function
10217#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10218#[cfg_attr(feature = "bindings", derive(TS))]
10219pub struct SessionUser;
10220
10221/// JSONPathRoot - Represents $ in JSON path expressions
10222#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10223#[cfg_attr(feature = "bindings", derive(TS))]
10224pub struct JSONPathRoot;
10225
10226/// UtcTime
10227#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10228#[cfg_attr(feature = "bindings", derive(TS))]
10229pub struct UtcTime {
10230    #[serde(default)]
10231    pub this: Option<Box<Expression>>,
10232}
10233
10234/// UtcTimestamp
10235#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10236#[cfg_attr(feature = "bindings", derive(TS))]
10237pub struct UtcTimestamp {
10238    #[serde(default)]
10239    pub this: Option<Box<Expression>>,
10240}
10241
10242/// TimestampFunc - TIMESTAMP constructor function
10243#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10244#[cfg_attr(feature = "bindings", derive(TS))]
10245pub struct TimestampFunc {
10246    #[serde(default)]
10247    pub this: Option<Box<Expression>>,
10248    #[serde(default)]
10249    pub zone: Option<Box<Expression>>,
10250    #[serde(default)]
10251    pub with_tz: Option<bool>,
10252    #[serde(default)]
10253    pub safe: Option<bool>,
10254}
10255
10256/// DateBin
10257#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10258#[cfg_attr(feature = "bindings", derive(TS))]
10259pub struct DateBin {
10260    pub this: Box<Expression>,
10261    pub expression: Box<Expression>,
10262    #[serde(default)]
10263    pub unit: Option<String>,
10264    #[serde(default)]
10265    pub zone: Option<Box<Expression>>,
10266    #[serde(default)]
10267    pub origin: Option<Box<Expression>>,
10268}
10269
10270/// Datetime
10271#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10272#[cfg_attr(feature = "bindings", derive(TS))]
10273pub struct Datetime {
10274    pub this: Box<Expression>,
10275    #[serde(default)]
10276    pub expression: Option<Box<Expression>>,
10277}
10278
10279/// DatetimeAdd
10280#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10281#[cfg_attr(feature = "bindings", derive(TS))]
10282pub struct DatetimeAdd {
10283    pub this: Box<Expression>,
10284    pub expression: Box<Expression>,
10285    #[serde(default)]
10286    pub unit: Option<String>,
10287}
10288
10289/// DatetimeSub
10290#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10291#[cfg_attr(feature = "bindings", derive(TS))]
10292pub struct DatetimeSub {
10293    pub this: Box<Expression>,
10294    pub expression: Box<Expression>,
10295    #[serde(default)]
10296    pub unit: Option<String>,
10297}
10298
10299/// DatetimeDiff
10300#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10301#[cfg_attr(feature = "bindings", derive(TS))]
10302pub struct DatetimeDiff {
10303    pub this: Box<Expression>,
10304    pub expression: Box<Expression>,
10305    #[serde(default)]
10306    pub unit: Option<String>,
10307}
10308
10309/// DatetimeTrunc
10310#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10311#[cfg_attr(feature = "bindings", derive(TS))]
10312pub struct DatetimeTrunc {
10313    pub this: Box<Expression>,
10314    pub unit: String,
10315    #[serde(default)]
10316    pub zone: Option<Box<Expression>>,
10317}
10318
10319/// Dayname
10320#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10321#[cfg_attr(feature = "bindings", derive(TS))]
10322pub struct Dayname {
10323    pub this: Box<Expression>,
10324    #[serde(default)]
10325    pub abbreviated: Option<Box<Expression>>,
10326}
10327
10328/// MakeInterval
10329#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10330#[cfg_attr(feature = "bindings", derive(TS))]
10331pub struct MakeInterval {
10332    #[serde(default)]
10333    pub year: Option<Box<Expression>>,
10334    #[serde(default)]
10335    pub month: Option<Box<Expression>>,
10336    #[serde(default)]
10337    pub week: Option<Box<Expression>>,
10338    #[serde(default)]
10339    pub day: Option<Box<Expression>>,
10340    #[serde(default)]
10341    pub hour: Option<Box<Expression>>,
10342    #[serde(default)]
10343    pub minute: Option<Box<Expression>>,
10344    #[serde(default)]
10345    pub second: Option<Box<Expression>>,
10346}
10347
10348/// PreviousDay
10349#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10350#[cfg_attr(feature = "bindings", derive(TS))]
10351pub struct PreviousDay {
10352    pub this: Box<Expression>,
10353    pub expression: Box<Expression>,
10354}
10355
10356/// Elt
10357#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10358#[cfg_attr(feature = "bindings", derive(TS))]
10359pub struct Elt {
10360    pub this: Box<Expression>,
10361    #[serde(default)]
10362    pub expressions: Vec<Expression>,
10363}
10364
10365/// TimestampAdd
10366#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10367#[cfg_attr(feature = "bindings", derive(TS))]
10368pub struct TimestampAdd {
10369    pub this: Box<Expression>,
10370    pub expression: Box<Expression>,
10371    #[serde(default)]
10372    pub unit: Option<String>,
10373}
10374
10375/// TimestampSub
10376#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10377#[cfg_attr(feature = "bindings", derive(TS))]
10378pub struct TimestampSub {
10379    pub this: Box<Expression>,
10380    pub expression: Box<Expression>,
10381    #[serde(default)]
10382    pub unit: Option<String>,
10383}
10384
10385/// TimestampDiff
10386#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10387#[cfg_attr(feature = "bindings", derive(TS))]
10388pub struct TimestampDiff {
10389    pub this: Box<Expression>,
10390    pub expression: Box<Expression>,
10391    #[serde(default)]
10392    pub unit: Option<String>,
10393}
10394
10395/// TimeSlice
10396#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10397#[cfg_attr(feature = "bindings", derive(TS))]
10398pub struct TimeSlice {
10399    pub this: Box<Expression>,
10400    pub expression: Box<Expression>,
10401    pub unit: String,
10402    #[serde(default)]
10403    pub kind: Option<String>,
10404}
10405
10406/// TimeAdd
10407#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10408#[cfg_attr(feature = "bindings", derive(TS))]
10409pub struct TimeAdd {
10410    pub this: Box<Expression>,
10411    pub expression: Box<Expression>,
10412    #[serde(default)]
10413    pub unit: Option<String>,
10414}
10415
10416/// TimeSub
10417#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10418#[cfg_attr(feature = "bindings", derive(TS))]
10419pub struct TimeSub {
10420    pub this: Box<Expression>,
10421    pub expression: Box<Expression>,
10422    #[serde(default)]
10423    pub unit: Option<String>,
10424}
10425
10426/// TimeDiff
10427#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10428#[cfg_attr(feature = "bindings", derive(TS))]
10429pub struct TimeDiff {
10430    pub this: Box<Expression>,
10431    pub expression: Box<Expression>,
10432    #[serde(default)]
10433    pub unit: Option<String>,
10434}
10435
10436/// TimeTrunc
10437#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10438#[cfg_attr(feature = "bindings", derive(TS))]
10439pub struct TimeTrunc {
10440    pub this: Box<Expression>,
10441    pub unit: String,
10442    #[serde(default)]
10443    pub zone: Option<Box<Expression>>,
10444}
10445
10446/// DateFromParts
10447#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10448#[cfg_attr(feature = "bindings", derive(TS))]
10449pub struct DateFromParts {
10450    #[serde(default)]
10451    pub year: Option<Box<Expression>>,
10452    #[serde(default)]
10453    pub month: Option<Box<Expression>>,
10454    #[serde(default)]
10455    pub day: Option<Box<Expression>>,
10456    #[serde(default)]
10457    pub allow_overflow: Option<Box<Expression>>,
10458}
10459
10460/// TimeFromParts
10461#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10462#[cfg_attr(feature = "bindings", derive(TS))]
10463pub struct TimeFromParts {
10464    #[serde(default)]
10465    pub hour: Option<Box<Expression>>,
10466    #[serde(default)]
10467    pub min: Option<Box<Expression>>,
10468    #[serde(default)]
10469    pub sec: Option<Box<Expression>>,
10470    #[serde(default)]
10471    pub nano: Option<Box<Expression>>,
10472    #[serde(default)]
10473    pub fractions: Option<Box<Expression>>,
10474    #[serde(default)]
10475    pub precision: Option<i64>,
10476}
10477
10478/// DecodeCase
10479#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10480#[cfg_attr(feature = "bindings", derive(TS))]
10481pub struct DecodeCase {
10482    #[serde(default)]
10483    pub expressions: Vec<Expression>,
10484}
10485
10486/// Decrypt
10487#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10488#[cfg_attr(feature = "bindings", derive(TS))]
10489pub struct Decrypt {
10490    pub this: Box<Expression>,
10491    #[serde(default)]
10492    pub passphrase: Option<Box<Expression>>,
10493    #[serde(default)]
10494    pub aad: Option<Box<Expression>>,
10495    #[serde(default)]
10496    pub encryption_method: Option<Box<Expression>>,
10497    #[serde(default)]
10498    pub safe: Option<Box<Expression>>,
10499}
10500
10501/// DecryptRaw
10502#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10503#[cfg_attr(feature = "bindings", derive(TS))]
10504pub struct DecryptRaw {
10505    pub this: Box<Expression>,
10506    #[serde(default)]
10507    pub key: Option<Box<Expression>>,
10508    #[serde(default)]
10509    pub iv: Option<Box<Expression>>,
10510    #[serde(default)]
10511    pub aad: Option<Box<Expression>>,
10512    #[serde(default)]
10513    pub encryption_method: Option<Box<Expression>>,
10514    #[serde(default)]
10515    pub aead: Option<Box<Expression>>,
10516    #[serde(default)]
10517    pub safe: Option<Box<Expression>>,
10518}
10519
10520/// Encode
10521#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10522#[cfg_attr(feature = "bindings", derive(TS))]
10523pub struct Encode {
10524    pub this: Box<Expression>,
10525    #[serde(default)]
10526    pub charset: Option<Box<Expression>>,
10527}
10528
10529/// Encrypt
10530#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10531#[cfg_attr(feature = "bindings", derive(TS))]
10532pub struct Encrypt {
10533    pub this: Box<Expression>,
10534    #[serde(default)]
10535    pub passphrase: Option<Box<Expression>>,
10536    #[serde(default)]
10537    pub aad: Option<Box<Expression>>,
10538    #[serde(default)]
10539    pub encryption_method: Option<Box<Expression>>,
10540}
10541
10542/// EncryptRaw
10543#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10544#[cfg_attr(feature = "bindings", derive(TS))]
10545pub struct EncryptRaw {
10546    pub this: Box<Expression>,
10547    #[serde(default)]
10548    pub key: Option<Box<Expression>>,
10549    #[serde(default)]
10550    pub iv: Option<Box<Expression>>,
10551    #[serde(default)]
10552    pub aad: Option<Box<Expression>>,
10553    #[serde(default)]
10554    pub encryption_method: Option<Box<Expression>>,
10555}
10556
10557/// EqualNull
10558#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10559#[cfg_attr(feature = "bindings", derive(TS))]
10560pub struct EqualNull {
10561    pub this: Box<Expression>,
10562    pub expression: Box<Expression>,
10563}
10564
10565/// ToBinary
10566#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10567#[cfg_attr(feature = "bindings", derive(TS))]
10568pub struct ToBinary {
10569    pub this: Box<Expression>,
10570    #[serde(default)]
10571    pub format: Option<String>,
10572    #[serde(default)]
10573    pub safe: Option<Box<Expression>>,
10574}
10575
10576/// Base64DecodeBinary
10577#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10578#[cfg_attr(feature = "bindings", derive(TS))]
10579pub struct Base64DecodeBinary {
10580    pub this: Box<Expression>,
10581    #[serde(default)]
10582    pub alphabet: Option<Box<Expression>>,
10583}
10584
10585/// Base64DecodeString
10586#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10587#[cfg_attr(feature = "bindings", derive(TS))]
10588pub struct Base64DecodeString {
10589    pub this: Box<Expression>,
10590    #[serde(default)]
10591    pub alphabet: Option<Box<Expression>>,
10592}
10593
10594/// Base64Encode
10595#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10596#[cfg_attr(feature = "bindings", derive(TS))]
10597pub struct Base64Encode {
10598    pub this: Box<Expression>,
10599    #[serde(default)]
10600    pub max_line_length: Option<Box<Expression>>,
10601    #[serde(default)]
10602    pub alphabet: Option<Box<Expression>>,
10603}
10604
10605/// TryBase64DecodeBinary
10606#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10607#[cfg_attr(feature = "bindings", derive(TS))]
10608pub struct TryBase64DecodeBinary {
10609    pub this: Box<Expression>,
10610    #[serde(default)]
10611    pub alphabet: Option<Box<Expression>>,
10612}
10613
10614/// TryBase64DecodeString
10615#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10616#[cfg_attr(feature = "bindings", derive(TS))]
10617pub struct TryBase64DecodeString {
10618    pub this: Box<Expression>,
10619    #[serde(default)]
10620    pub alphabet: Option<Box<Expression>>,
10621}
10622
10623/// GapFill
10624#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10625#[cfg_attr(feature = "bindings", derive(TS))]
10626pub struct GapFill {
10627    pub this: Box<Expression>,
10628    #[serde(default)]
10629    pub ts_column: Option<Box<Expression>>,
10630    #[serde(default)]
10631    pub bucket_width: Option<Box<Expression>>,
10632    #[serde(default)]
10633    pub partitioning_columns: Option<Box<Expression>>,
10634    #[serde(default)]
10635    pub value_columns: Option<Box<Expression>>,
10636    #[serde(default)]
10637    pub origin: Option<Box<Expression>>,
10638    #[serde(default)]
10639    pub ignore_nulls: Option<Box<Expression>>,
10640}
10641
10642/// GenerateDateArray
10643#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10644#[cfg_attr(feature = "bindings", derive(TS))]
10645pub struct GenerateDateArray {
10646    #[serde(default)]
10647    pub start: Option<Box<Expression>>,
10648    #[serde(default)]
10649    pub end: Option<Box<Expression>>,
10650    #[serde(default)]
10651    pub step: Option<Box<Expression>>,
10652}
10653
10654/// GenerateTimestampArray
10655#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10656#[cfg_attr(feature = "bindings", derive(TS))]
10657pub struct GenerateTimestampArray {
10658    #[serde(default)]
10659    pub start: Option<Box<Expression>>,
10660    #[serde(default)]
10661    pub end: Option<Box<Expression>>,
10662    #[serde(default)]
10663    pub step: Option<Box<Expression>>,
10664}
10665
10666/// GetExtract
10667#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10668#[cfg_attr(feature = "bindings", derive(TS))]
10669pub struct GetExtract {
10670    pub this: Box<Expression>,
10671    pub expression: Box<Expression>,
10672}
10673
10674/// Getbit
10675#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10676#[cfg_attr(feature = "bindings", derive(TS))]
10677pub struct Getbit {
10678    pub this: Box<Expression>,
10679    pub expression: Box<Expression>,
10680    #[serde(default)]
10681    pub zero_is_msb: Option<Box<Expression>>,
10682}
10683
10684/// OverflowTruncateBehavior
10685#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10686#[cfg_attr(feature = "bindings", derive(TS))]
10687pub struct OverflowTruncateBehavior {
10688    #[serde(default)]
10689    pub this: Option<Box<Expression>>,
10690    #[serde(default)]
10691    pub with_count: Option<Box<Expression>>,
10692}
10693
10694/// HexEncode
10695#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10696#[cfg_attr(feature = "bindings", derive(TS))]
10697pub struct HexEncode {
10698    pub this: Box<Expression>,
10699    #[serde(default)]
10700    pub case: Option<Box<Expression>>,
10701}
10702
10703/// Compress
10704#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10705#[cfg_attr(feature = "bindings", derive(TS))]
10706pub struct Compress {
10707    pub this: Box<Expression>,
10708    #[serde(default)]
10709    pub method: Option<String>,
10710}
10711
10712/// DecompressBinary
10713#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10714#[cfg_attr(feature = "bindings", derive(TS))]
10715pub struct DecompressBinary {
10716    pub this: Box<Expression>,
10717    pub method: String,
10718}
10719
10720/// DecompressString
10721#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10722#[cfg_attr(feature = "bindings", derive(TS))]
10723pub struct DecompressString {
10724    pub this: Box<Expression>,
10725    pub method: String,
10726}
10727
10728/// Xor
10729#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10730#[cfg_attr(feature = "bindings", derive(TS))]
10731pub struct Xor {
10732    #[serde(default)]
10733    pub this: Option<Box<Expression>>,
10734    #[serde(default)]
10735    pub expression: Option<Box<Expression>>,
10736    #[serde(default)]
10737    pub expressions: Vec<Expression>,
10738}
10739
10740/// Nullif
10741#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10742#[cfg_attr(feature = "bindings", derive(TS))]
10743pub struct Nullif {
10744    pub this: Box<Expression>,
10745    pub expression: Box<Expression>,
10746}
10747
10748/// JSON
10749#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10750#[cfg_attr(feature = "bindings", derive(TS))]
10751pub struct JSON {
10752    #[serde(default)]
10753    pub this: Option<Box<Expression>>,
10754    #[serde(default)]
10755    pub with_: Option<Box<Expression>>,
10756    #[serde(default)]
10757    pub unique: bool,
10758}
10759
10760/// JSONPath
10761#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10762#[cfg_attr(feature = "bindings", derive(TS))]
10763pub struct JSONPath {
10764    #[serde(default)]
10765    pub expressions: Vec<Expression>,
10766    #[serde(default)]
10767    pub escape: Option<Box<Expression>>,
10768}
10769
10770/// JSONPathFilter
10771#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10772#[cfg_attr(feature = "bindings", derive(TS))]
10773pub struct JSONPathFilter {
10774    pub this: Box<Expression>,
10775}
10776
10777/// JSONPathKey
10778#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10779#[cfg_attr(feature = "bindings", derive(TS))]
10780pub struct JSONPathKey {
10781    pub this: Box<Expression>,
10782}
10783
10784/// JSONPathRecursive
10785#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10786#[cfg_attr(feature = "bindings", derive(TS))]
10787pub struct JSONPathRecursive {
10788    #[serde(default)]
10789    pub this: Option<Box<Expression>>,
10790}
10791
10792/// JSONPathScript
10793#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10794#[cfg_attr(feature = "bindings", derive(TS))]
10795pub struct JSONPathScript {
10796    pub this: Box<Expression>,
10797}
10798
10799/// JSONPathSlice
10800#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10801#[cfg_attr(feature = "bindings", derive(TS))]
10802pub struct JSONPathSlice {
10803    #[serde(default)]
10804    pub start: Option<Box<Expression>>,
10805    #[serde(default)]
10806    pub end: Option<Box<Expression>>,
10807    #[serde(default)]
10808    pub step: Option<Box<Expression>>,
10809}
10810
10811/// JSONPathSelector
10812#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10813#[cfg_attr(feature = "bindings", derive(TS))]
10814pub struct JSONPathSelector {
10815    pub this: Box<Expression>,
10816}
10817
10818/// JSONPathSubscript
10819#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10820#[cfg_attr(feature = "bindings", derive(TS))]
10821pub struct JSONPathSubscript {
10822    pub this: Box<Expression>,
10823}
10824
10825/// JSONPathUnion
10826#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10827#[cfg_attr(feature = "bindings", derive(TS))]
10828pub struct JSONPathUnion {
10829    #[serde(default)]
10830    pub expressions: Vec<Expression>,
10831}
10832
10833/// Format
10834#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10835#[cfg_attr(feature = "bindings", derive(TS))]
10836pub struct Format {
10837    pub this: Box<Expression>,
10838    #[serde(default)]
10839    pub expressions: Vec<Expression>,
10840}
10841
10842/// JSONKeys
10843#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10844#[cfg_attr(feature = "bindings", derive(TS))]
10845pub struct JSONKeys {
10846    pub this: Box<Expression>,
10847    #[serde(default)]
10848    pub expression: Option<Box<Expression>>,
10849    #[serde(default)]
10850    pub expressions: Vec<Expression>,
10851}
10852
10853/// JSONKeyValue
10854#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10855#[cfg_attr(feature = "bindings", derive(TS))]
10856pub struct JSONKeyValue {
10857    pub this: Box<Expression>,
10858    pub expression: Box<Expression>,
10859}
10860
10861/// JSONKeysAtDepth
10862#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10863#[cfg_attr(feature = "bindings", derive(TS))]
10864pub struct JSONKeysAtDepth {
10865    pub this: Box<Expression>,
10866    #[serde(default)]
10867    pub expression: Option<Box<Expression>>,
10868    #[serde(default)]
10869    pub mode: Option<Box<Expression>>,
10870}
10871
10872/// JSONObject
10873#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10874#[cfg_attr(feature = "bindings", derive(TS))]
10875pub struct JSONObject {
10876    #[serde(default)]
10877    pub expressions: Vec<Expression>,
10878    #[serde(default)]
10879    pub null_handling: Option<Box<Expression>>,
10880    #[serde(default)]
10881    pub unique_keys: Option<Box<Expression>>,
10882    #[serde(default)]
10883    pub return_type: Option<Box<Expression>>,
10884    #[serde(default)]
10885    pub encoding: Option<Box<Expression>>,
10886}
10887
10888/// JSONObjectAgg
10889#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10890#[cfg_attr(feature = "bindings", derive(TS))]
10891pub struct JSONObjectAgg {
10892    #[serde(default)]
10893    pub expressions: Vec<Expression>,
10894    #[serde(default)]
10895    pub null_handling: Option<Box<Expression>>,
10896    #[serde(default)]
10897    pub unique_keys: Option<Box<Expression>>,
10898    #[serde(default)]
10899    pub return_type: Option<Box<Expression>>,
10900    #[serde(default)]
10901    pub encoding: Option<Box<Expression>>,
10902}
10903
10904/// JSONBObjectAgg
10905#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10906#[cfg_attr(feature = "bindings", derive(TS))]
10907pub struct JSONBObjectAgg {
10908    pub this: Box<Expression>,
10909    pub expression: Box<Expression>,
10910}
10911
10912/// JSONArray
10913#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10914#[cfg_attr(feature = "bindings", derive(TS))]
10915pub struct JSONArray {
10916    #[serde(default)]
10917    pub expressions: Vec<Expression>,
10918    #[serde(default)]
10919    pub null_handling: Option<Box<Expression>>,
10920    #[serde(default)]
10921    pub return_type: Option<Box<Expression>>,
10922    #[serde(default)]
10923    pub strict: Option<Box<Expression>>,
10924}
10925
10926/// JSONArrayAgg
10927#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10928#[cfg_attr(feature = "bindings", derive(TS))]
10929pub struct JSONArrayAgg {
10930    pub this: Box<Expression>,
10931    #[serde(default)]
10932    pub order: Option<Box<Expression>>,
10933    #[serde(default)]
10934    pub null_handling: Option<Box<Expression>>,
10935    #[serde(default)]
10936    pub return_type: Option<Box<Expression>>,
10937    #[serde(default)]
10938    pub strict: Option<Box<Expression>>,
10939}
10940
10941/// JSONExists
10942#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10943#[cfg_attr(feature = "bindings", derive(TS))]
10944pub struct JSONExists {
10945    pub this: Box<Expression>,
10946    #[serde(default)]
10947    pub path: Option<Box<Expression>>,
10948    #[serde(default)]
10949    pub passing: Option<Box<Expression>>,
10950    #[serde(default)]
10951    pub on_condition: Option<Box<Expression>>,
10952    #[serde(default)]
10953    pub from_dcolonqmark: Option<Box<Expression>>,
10954}
10955
10956/// JSONColumnDef
10957#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10958#[cfg_attr(feature = "bindings", derive(TS))]
10959pub struct JSONColumnDef {
10960    #[serde(default)]
10961    pub this: Option<Box<Expression>>,
10962    #[serde(default)]
10963    pub kind: Option<String>,
10964    #[serde(default)]
10965    pub path: Option<Box<Expression>>,
10966    #[serde(default)]
10967    pub nested_schema: Option<Box<Expression>>,
10968    #[serde(default)]
10969    pub ordinality: Option<Box<Expression>>,
10970}
10971
10972/// JSONSchema
10973#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10974#[cfg_attr(feature = "bindings", derive(TS))]
10975pub struct JSONSchema {
10976    #[serde(default)]
10977    pub expressions: Vec<Expression>,
10978}
10979
10980/// JSONSet
10981#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10982#[cfg_attr(feature = "bindings", derive(TS))]
10983pub struct JSONSet {
10984    pub this: Box<Expression>,
10985    #[serde(default)]
10986    pub expressions: Vec<Expression>,
10987}
10988
10989/// JSONStripNulls
10990#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10991#[cfg_attr(feature = "bindings", derive(TS))]
10992pub struct JSONStripNulls {
10993    pub this: Box<Expression>,
10994    #[serde(default)]
10995    pub expression: Option<Box<Expression>>,
10996    #[serde(default)]
10997    pub include_arrays: Option<Box<Expression>>,
10998    #[serde(default)]
10999    pub remove_empty: Option<Box<Expression>>,
11000}
11001
11002/// JSONValue
11003#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11004#[cfg_attr(feature = "bindings", derive(TS))]
11005pub struct JSONValue {
11006    pub this: Box<Expression>,
11007    #[serde(default)]
11008    pub path: Option<Box<Expression>>,
11009    #[serde(default)]
11010    pub returning: Option<Box<Expression>>,
11011    #[serde(default)]
11012    pub on_condition: Option<Box<Expression>>,
11013}
11014
11015/// JSONValueArray
11016#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11017#[cfg_attr(feature = "bindings", derive(TS))]
11018pub struct JSONValueArray {
11019    pub this: Box<Expression>,
11020    #[serde(default)]
11021    pub expression: Option<Box<Expression>>,
11022}
11023
11024/// JSONRemove
11025#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11026#[cfg_attr(feature = "bindings", derive(TS))]
11027pub struct JSONRemove {
11028    pub this: Box<Expression>,
11029    #[serde(default)]
11030    pub expressions: Vec<Expression>,
11031}
11032
11033/// JSONTable
11034#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11035#[cfg_attr(feature = "bindings", derive(TS))]
11036pub struct JSONTable {
11037    pub this: Box<Expression>,
11038    #[serde(default)]
11039    pub schema: Option<Box<Expression>>,
11040    #[serde(default)]
11041    pub path: Option<Box<Expression>>,
11042    #[serde(default)]
11043    pub error_handling: Option<Box<Expression>>,
11044    #[serde(default)]
11045    pub empty_handling: Option<Box<Expression>>,
11046}
11047
11048/// JSONType
11049#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11050#[cfg_attr(feature = "bindings", derive(TS))]
11051pub struct JSONType {
11052    pub this: Box<Expression>,
11053    #[serde(default)]
11054    pub expression: Option<Box<Expression>>,
11055}
11056
11057/// ObjectInsert
11058#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11059#[cfg_attr(feature = "bindings", derive(TS))]
11060pub struct ObjectInsert {
11061    pub this: Box<Expression>,
11062    #[serde(default)]
11063    pub key: Option<Box<Expression>>,
11064    #[serde(default)]
11065    pub value: Option<Box<Expression>>,
11066    #[serde(default)]
11067    pub update_flag: Option<Box<Expression>>,
11068}
11069
11070/// OpenJSONColumnDef
11071#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11072#[cfg_attr(feature = "bindings", derive(TS))]
11073pub struct OpenJSONColumnDef {
11074    pub this: Box<Expression>,
11075    pub kind: String,
11076    #[serde(default)]
11077    pub path: Option<Box<Expression>>,
11078    #[serde(default)]
11079    pub as_json: Option<Box<Expression>>,
11080    /// The parsed data type for proper generation
11081    #[serde(default, skip_serializing_if = "Option::is_none")]
11082    pub data_type: Option<DataType>,
11083}
11084
11085/// OpenJSON
11086#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11087#[cfg_attr(feature = "bindings", derive(TS))]
11088pub struct OpenJSON {
11089    pub this: Box<Expression>,
11090    #[serde(default)]
11091    pub path: Option<Box<Expression>>,
11092    #[serde(default)]
11093    pub expressions: Vec<Expression>,
11094}
11095
11096/// JSONBExists
11097#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11098#[cfg_attr(feature = "bindings", derive(TS))]
11099pub struct JSONBExists {
11100    pub this: Box<Expression>,
11101    #[serde(default)]
11102    pub path: Option<Box<Expression>>,
11103}
11104
11105/// JSONCast
11106#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11107#[cfg_attr(feature = "bindings", derive(TS))]
11108pub struct JSONCast {
11109    pub this: Box<Expression>,
11110    pub to: DataType,
11111}
11112
11113/// JSONExtract
11114#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11115#[cfg_attr(feature = "bindings", derive(TS))]
11116pub struct JSONExtract {
11117    pub this: Box<Expression>,
11118    pub expression: Box<Expression>,
11119    #[serde(default)]
11120    pub only_json_types: Option<Box<Expression>>,
11121    #[serde(default)]
11122    pub expressions: Vec<Expression>,
11123    #[serde(default)]
11124    pub variant_extract: Option<Box<Expression>>,
11125    #[serde(default)]
11126    pub json_query: Option<Box<Expression>>,
11127    #[serde(default)]
11128    pub option: Option<Box<Expression>>,
11129    #[serde(default)]
11130    pub quote: Option<Box<Expression>>,
11131    #[serde(default)]
11132    pub on_condition: Option<Box<Expression>>,
11133    #[serde(default)]
11134    pub requires_json: Option<Box<Expression>>,
11135}
11136
11137/// JSONExtractQuote
11138#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11139#[cfg_attr(feature = "bindings", derive(TS))]
11140pub struct JSONExtractQuote {
11141    #[serde(default)]
11142    pub option: Option<Box<Expression>>,
11143    #[serde(default)]
11144    pub scalar: Option<Box<Expression>>,
11145}
11146
11147/// JSONExtractArray
11148#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11149#[cfg_attr(feature = "bindings", derive(TS))]
11150pub struct JSONExtractArray {
11151    pub this: Box<Expression>,
11152    #[serde(default)]
11153    pub expression: Option<Box<Expression>>,
11154}
11155
11156/// JSONExtractScalar
11157#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11158#[cfg_attr(feature = "bindings", derive(TS))]
11159pub struct JSONExtractScalar {
11160    pub this: Box<Expression>,
11161    pub expression: Box<Expression>,
11162    #[serde(default)]
11163    pub only_json_types: Option<Box<Expression>>,
11164    #[serde(default)]
11165    pub expressions: Vec<Expression>,
11166    #[serde(default)]
11167    pub json_type: Option<Box<Expression>>,
11168    #[serde(default)]
11169    pub scalar_only: Option<Box<Expression>>,
11170}
11171
11172/// JSONBExtractScalar
11173#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11174#[cfg_attr(feature = "bindings", derive(TS))]
11175pub struct JSONBExtractScalar {
11176    pub this: Box<Expression>,
11177    pub expression: Box<Expression>,
11178    #[serde(default)]
11179    pub json_type: Option<Box<Expression>>,
11180}
11181
11182/// JSONFormat
11183#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11184#[cfg_attr(feature = "bindings", derive(TS))]
11185pub struct JSONFormat {
11186    #[serde(default)]
11187    pub this: Option<Box<Expression>>,
11188    #[serde(default)]
11189    pub options: Vec<Expression>,
11190    #[serde(default)]
11191    pub is_json: Option<Box<Expression>>,
11192    #[serde(default)]
11193    pub to_json: Option<Box<Expression>>,
11194}
11195
11196/// JSONArrayAppend
11197#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11198#[cfg_attr(feature = "bindings", derive(TS))]
11199pub struct JSONArrayAppend {
11200    pub this: Box<Expression>,
11201    #[serde(default)]
11202    pub expressions: Vec<Expression>,
11203}
11204
11205/// JSONArrayContains
11206#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11207#[cfg_attr(feature = "bindings", derive(TS))]
11208pub struct JSONArrayContains {
11209    pub this: Box<Expression>,
11210    pub expression: Box<Expression>,
11211    #[serde(default)]
11212    pub json_type: Option<Box<Expression>>,
11213}
11214
11215/// JSONArrayInsert
11216#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11217#[cfg_attr(feature = "bindings", derive(TS))]
11218pub struct JSONArrayInsert {
11219    pub this: Box<Expression>,
11220    #[serde(default)]
11221    pub expressions: Vec<Expression>,
11222}
11223
11224/// ParseJSON
11225#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11226#[cfg_attr(feature = "bindings", derive(TS))]
11227pub struct ParseJSON {
11228    pub this: Box<Expression>,
11229    #[serde(default)]
11230    pub expression: Option<Box<Expression>>,
11231    #[serde(default)]
11232    pub safe: Option<Box<Expression>>,
11233}
11234
11235/// ParseUrl
11236#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11237#[cfg_attr(feature = "bindings", derive(TS))]
11238pub struct ParseUrl {
11239    pub this: Box<Expression>,
11240    #[serde(default)]
11241    pub part_to_extract: Option<Box<Expression>>,
11242    #[serde(default)]
11243    pub key: Option<Box<Expression>>,
11244    #[serde(default)]
11245    pub permissive: Option<Box<Expression>>,
11246}
11247
11248/// ParseIp
11249#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11250#[cfg_attr(feature = "bindings", derive(TS))]
11251pub struct ParseIp {
11252    pub this: Box<Expression>,
11253    #[serde(default)]
11254    pub type_: Option<Box<Expression>>,
11255    #[serde(default)]
11256    pub permissive: Option<Box<Expression>>,
11257}
11258
11259/// ParseTime
11260#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11261#[cfg_attr(feature = "bindings", derive(TS))]
11262pub struct ParseTime {
11263    pub this: Box<Expression>,
11264    pub format: String,
11265}
11266
11267/// ParseDatetime
11268#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11269#[cfg_attr(feature = "bindings", derive(TS))]
11270pub struct ParseDatetime {
11271    pub this: Box<Expression>,
11272    #[serde(default)]
11273    pub format: Option<String>,
11274    #[serde(default)]
11275    pub zone: Option<Box<Expression>>,
11276}
11277
11278/// Map
11279#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11280#[cfg_attr(feature = "bindings", derive(TS))]
11281pub struct Map {
11282    #[serde(default)]
11283    pub keys: Vec<Expression>,
11284    #[serde(default)]
11285    pub values: Vec<Expression>,
11286}
11287
11288/// MapCat
11289#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11290#[cfg_attr(feature = "bindings", derive(TS))]
11291pub struct MapCat {
11292    pub this: Box<Expression>,
11293    pub expression: Box<Expression>,
11294}
11295
11296/// MapDelete
11297#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11298#[cfg_attr(feature = "bindings", derive(TS))]
11299pub struct MapDelete {
11300    pub this: Box<Expression>,
11301    #[serde(default)]
11302    pub expressions: Vec<Expression>,
11303}
11304
11305/// MapInsert
11306#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11307#[cfg_attr(feature = "bindings", derive(TS))]
11308pub struct MapInsert {
11309    pub this: Box<Expression>,
11310    #[serde(default)]
11311    pub key: Option<Box<Expression>>,
11312    #[serde(default)]
11313    pub value: Option<Box<Expression>>,
11314    #[serde(default)]
11315    pub update_flag: Option<Box<Expression>>,
11316}
11317
11318/// MapPick
11319#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11320#[cfg_attr(feature = "bindings", derive(TS))]
11321pub struct MapPick {
11322    pub this: Box<Expression>,
11323    #[serde(default)]
11324    pub expressions: Vec<Expression>,
11325}
11326
11327/// ScopeResolution
11328#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11329#[cfg_attr(feature = "bindings", derive(TS))]
11330pub struct ScopeResolution {
11331    #[serde(default)]
11332    pub this: Option<Box<Expression>>,
11333    pub expression: Box<Expression>,
11334}
11335
11336/// Slice
11337#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11338#[cfg_attr(feature = "bindings", derive(TS))]
11339pub struct Slice {
11340    #[serde(default)]
11341    pub this: Option<Box<Expression>>,
11342    #[serde(default)]
11343    pub expression: Option<Box<Expression>>,
11344    #[serde(default)]
11345    pub step: Option<Box<Expression>>,
11346}
11347
11348/// VarMap
11349#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11350#[cfg_attr(feature = "bindings", derive(TS))]
11351pub struct VarMap {
11352    #[serde(default)]
11353    pub keys: Vec<Expression>,
11354    #[serde(default)]
11355    pub values: Vec<Expression>,
11356}
11357
11358/// MatchAgainst
11359#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11360#[cfg_attr(feature = "bindings", derive(TS))]
11361pub struct MatchAgainst {
11362    pub this: Box<Expression>,
11363    #[serde(default)]
11364    pub expressions: Vec<Expression>,
11365    #[serde(default)]
11366    pub modifier: Option<Box<Expression>>,
11367}
11368
11369/// MD5Digest
11370#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11371#[cfg_attr(feature = "bindings", derive(TS))]
11372pub struct MD5Digest {
11373    pub this: Box<Expression>,
11374    #[serde(default)]
11375    pub expressions: Vec<Expression>,
11376}
11377
11378/// Monthname
11379#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11380#[cfg_attr(feature = "bindings", derive(TS))]
11381pub struct Monthname {
11382    pub this: Box<Expression>,
11383    #[serde(default)]
11384    pub abbreviated: Option<Box<Expression>>,
11385}
11386
11387/// Ntile
11388#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11389#[cfg_attr(feature = "bindings", derive(TS))]
11390pub struct Ntile {
11391    #[serde(default)]
11392    pub this: Option<Box<Expression>>,
11393}
11394
11395/// Normalize
11396#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11397#[cfg_attr(feature = "bindings", derive(TS))]
11398pub struct Normalize {
11399    pub this: Box<Expression>,
11400    #[serde(default)]
11401    pub form: Option<Box<Expression>>,
11402    #[serde(default)]
11403    pub is_casefold: Option<Box<Expression>>,
11404}
11405
11406/// Normal
11407#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11408#[cfg_attr(feature = "bindings", derive(TS))]
11409pub struct Normal {
11410    pub this: Box<Expression>,
11411    #[serde(default)]
11412    pub stddev: Option<Box<Expression>>,
11413    #[serde(default)]
11414    pub gen: Option<Box<Expression>>,
11415}
11416
11417/// Predict
11418#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11419#[cfg_attr(feature = "bindings", derive(TS))]
11420pub struct Predict {
11421    pub this: Box<Expression>,
11422    pub expression: Box<Expression>,
11423    #[serde(default)]
11424    pub params_struct: Option<Box<Expression>>,
11425}
11426
11427/// MLTranslate
11428#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11429#[cfg_attr(feature = "bindings", derive(TS))]
11430pub struct MLTranslate {
11431    pub this: Box<Expression>,
11432    pub expression: Box<Expression>,
11433    #[serde(default)]
11434    pub params_struct: Option<Box<Expression>>,
11435}
11436
11437/// FeaturesAtTime
11438#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11439#[cfg_attr(feature = "bindings", derive(TS))]
11440pub struct FeaturesAtTime {
11441    pub this: Box<Expression>,
11442    #[serde(default)]
11443    pub time: Option<Box<Expression>>,
11444    #[serde(default)]
11445    pub num_rows: Option<Box<Expression>>,
11446    #[serde(default)]
11447    pub ignore_feature_nulls: Option<Box<Expression>>,
11448}
11449
11450/// GenerateEmbedding
11451#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11452#[cfg_attr(feature = "bindings", derive(TS))]
11453pub struct GenerateEmbedding {
11454    pub this: Box<Expression>,
11455    pub expression: Box<Expression>,
11456    #[serde(default)]
11457    pub params_struct: Option<Box<Expression>>,
11458    #[serde(default)]
11459    pub is_text: Option<Box<Expression>>,
11460}
11461
11462/// MLForecast
11463#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11464#[cfg_attr(feature = "bindings", derive(TS))]
11465pub struct MLForecast {
11466    pub this: Box<Expression>,
11467    #[serde(default)]
11468    pub expression: Option<Box<Expression>>,
11469    #[serde(default)]
11470    pub params_struct: Option<Box<Expression>>,
11471}
11472
11473/// ModelAttribute
11474#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11475#[cfg_attr(feature = "bindings", derive(TS))]
11476pub struct ModelAttribute {
11477    pub this: Box<Expression>,
11478    pub expression: Box<Expression>,
11479}
11480
11481/// VectorSearch
11482#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11483#[cfg_attr(feature = "bindings", derive(TS))]
11484pub struct VectorSearch {
11485    pub this: Box<Expression>,
11486    #[serde(default)]
11487    pub column_to_search: Option<Box<Expression>>,
11488    #[serde(default)]
11489    pub query_table: Option<Box<Expression>>,
11490    #[serde(default)]
11491    pub query_column_to_search: Option<Box<Expression>>,
11492    #[serde(default)]
11493    pub top_k: Option<Box<Expression>>,
11494    #[serde(default)]
11495    pub distance_type: Option<Box<Expression>>,
11496    #[serde(default)]
11497    pub options: Vec<Expression>,
11498}
11499
11500/// Quantile
11501#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11502#[cfg_attr(feature = "bindings", derive(TS))]
11503pub struct Quantile {
11504    pub this: Box<Expression>,
11505    #[serde(default)]
11506    pub quantile: Option<Box<Expression>>,
11507}
11508
11509/// ApproxQuantile
11510#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11511#[cfg_attr(feature = "bindings", derive(TS))]
11512pub struct ApproxQuantile {
11513    pub this: Box<Expression>,
11514    #[serde(default)]
11515    pub quantile: Option<Box<Expression>>,
11516    #[serde(default)]
11517    pub accuracy: Option<Box<Expression>>,
11518    #[serde(default)]
11519    pub weight: Option<Box<Expression>>,
11520    #[serde(default)]
11521    pub error_tolerance: Option<Box<Expression>>,
11522}
11523
11524/// ApproxPercentileEstimate
11525#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11526#[cfg_attr(feature = "bindings", derive(TS))]
11527pub struct ApproxPercentileEstimate {
11528    pub this: Box<Expression>,
11529    #[serde(default)]
11530    pub percentile: Option<Box<Expression>>,
11531}
11532
11533/// Randn
11534#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11535#[cfg_attr(feature = "bindings", derive(TS))]
11536pub struct Randn {
11537    #[serde(default)]
11538    pub this: Option<Box<Expression>>,
11539}
11540
11541/// Randstr
11542#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11543#[cfg_attr(feature = "bindings", derive(TS))]
11544pub struct Randstr {
11545    pub this: Box<Expression>,
11546    #[serde(default)]
11547    pub generator: Option<Box<Expression>>,
11548}
11549
11550/// RangeN
11551#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11552#[cfg_attr(feature = "bindings", derive(TS))]
11553pub struct RangeN {
11554    pub this: Box<Expression>,
11555    #[serde(default)]
11556    pub expressions: Vec<Expression>,
11557    #[serde(default)]
11558    pub each: Option<Box<Expression>>,
11559}
11560
11561/// RangeBucket
11562#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11563#[cfg_attr(feature = "bindings", derive(TS))]
11564pub struct RangeBucket {
11565    pub this: Box<Expression>,
11566    pub expression: Box<Expression>,
11567}
11568
11569/// ReadCSV
11570#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11571#[cfg_attr(feature = "bindings", derive(TS))]
11572pub struct ReadCSV {
11573    pub this: Box<Expression>,
11574    #[serde(default)]
11575    pub expressions: Vec<Expression>,
11576}
11577
11578/// ReadParquet
11579#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11580#[cfg_attr(feature = "bindings", derive(TS))]
11581pub struct ReadParquet {
11582    #[serde(default)]
11583    pub expressions: Vec<Expression>,
11584}
11585
11586/// Reduce
11587#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11588#[cfg_attr(feature = "bindings", derive(TS))]
11589pub struct Reduce {
11590    pub this: Box<Expression>,
11591    #[serde(default)]
11592    pub initial: Option<Box<Expression>>,
11593    #[serde(default)]
11594    pub merge: Option<Box<Expression>>,
11595    #[serde(default)]
11596    pub finish: Option<Box<Expression>>,
11597}
11598
11599/// RegexpExtractAll
11600#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11601#[cfg_attr(feature = "bindings", derive(TS))]
11602pub struct RegexpExtractAll {
11603    pub this: Box<Expression>,
11604    pub expression: Box<Expression>,
11605    #[serde(default)]
11606    pub group: Option<Box<Expression>>,
11607    #[serde(default)]
11608    pub parameters: Option<Box<Expression>>,
11609    #[serde(default)]
11610    pub position: Option<Box<Expression>>,
11611    #[serde(default)]
11612    pub occurrence: Option<Box<Expression>>,
11613}
11614
11615/// RegexpILike
11616#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11617#[cfg_attr(feature = "bindings", derive(TS))]
11618pub struct RegexpILike {
11619    pub this: Box<Expression>,
11620    pub expression: Box<Expression>,
11621    #[serde(default)]
11622    pub flag: Option<Box<Expression>>,
11623}
11624
11625/// RegexpFullMatch
11626#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11627#[cfg_attr(feature = "bindings", derive(TS))]
11628pub struct RegexpFullMatch {
11629    pub this: Box<Expression>,
11630    pub expression: Box<Expression>,
11631    #[serde(default)]
11632    pub options: Vec<Expression>,
11633}
11634
11635/// RegexpInstr
11636#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11637#[cfg_attr(feature = "bindings", derive(TS))]
11638pub struct RegexpInstr {
11639    pub this: Box<Expression>,
11640    pub expression: Box<Expression>,
11641    #[serde(default)]
11642    pub position: Option<Box<Expression>>,
11643    #[serde(default)]
11644    pub occurrence: Option<Box<Expression>>,
11645    #[serde(default)]
11646    pub option: Option<Box<Expression>>,
11647    #[serde(default)]
11648    pub parameters: Option<Box<Expression>>,
11649    #[serde(default)]
11650    pub group: Option<Box<Expression>>,
11651}
11652
11653/// RegexpSplit
11654#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11655#[cfg_attr(feature = "bindings", derive(TS))]
11656pub struct RegexpSplit {
11657    pub this: Box<Expression>,
11658    pub expression: Box<Expression>,
11659    #[serde(default)]
11660    pub limit: Option<Box<Expression>>,
11661}
11662
11663/// RegexpCount
11664#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11665#[cfg_attr(feature = "bindings", derive(TS))]
11666pub struct RegexpCount {
11667    pub this: Box<Expression>,
11668    pub expression: Box<Expression>,
11669    #[serde(default)]
11670    pub position: Option<Box<Expression>>,
11671    #[serde(default)]
11672    pub parameters: Option<Box<Expression>>,
11673}
11674
11675/// RegrValx
11676#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11677#[cfg_attr(feature = "bindings", derive(TS))]
11678pub struct RegrValx {
11679    pub this: Box<Expression>,
11680    pub expression: Box<Expression>,
11681}
11682
11683/// RegrValy
11684#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11685#[cfg_attr(feature = "bindings", derive(TS))]
11686pub struct RegrValy {
11687    pub this: Box<Expression>,
11688    pub expression: Box<Expression>,
11689}
11690
11691/// RegrAvgy
11692#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11693#[cfg_attr(feature = "bindings", derive(TS))]
11694pub struct RegrAvgy {
11695    pub this: Box<Expression>,
11696    pub expression: Box<Expression>,
11697}
11698
11699/// RegrAvgx
11700#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11701#[cfg_attr(feature = "bindings", derive(TS))]
11702pub struct RegrAvgx {
11703    pub this: Box<Expression>,
11704    pub expression: Box<Expression>,
11705}
11706
11707/// RegrCount
11708#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11709#[cfg_attr(feature = "bindings", derive(TS))]
11710pub struct RegrCount {
11711    pub this: Box<Expression>,
11712    pub expression: Box<Expression>,
11713}
11714
11715/// RegrIntercept
11716#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11717#[cfg_attr(feature = "bindings", derive(TS))]
11718pub struct RegrIntercept {
11719    pub this: Box<Expression>,
11720    pub expression: Box<Expression>,
11721}
11722
11723/// RegrR2
11724#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11725#[cfg_attr(feature = "bindings", derive(TS))]
11726pub struct RegrR2 {
11727    pub this: Box<Expression>,
11728    pub expression: Box<Expression>,
11729}
11730
11731/// RegrSxx
11732#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11733#[cfg_attr(feature = "bindings", derive(TS))]
11734pub struct RegrSxx {
11735    pub this: Box<Expression>,
11736    pub expression: Box<Expression>,
11737}
11738
11739/// RegrSxy
11740#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11741#[cfg_attr(feature = "bindings", derive(TS))]
11742pub struct RegrSxy {
11743    pub this: Box<Expression>,
11744    pub expression: Box<Expression>,
11745}
11746
11747/// RegrSyy
11748#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11749#[cfg_attr(feature = "bindings", derive(TS))]
11750pub struct RegrSyy {
11751    pub this: Box<Expression>,
11752    pub expression: Box<Expression>,
11753}
11754
11755/// RegrSlope
11756#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11757#[cfg_attr(feature = "bindings", derive(TS))]
11758pub struct RegrSlope {
11759    pub this: Box<Expression>,
11760    pub expression: Box<Expression>,
11761}
11762
11763/// SafeAdd
11764#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11765#[cfg_attr(feature = "bindings", derive(TS))]
11766pub struct SafeAdd {
11767    pub this: Box<Expression>,
11768    pub expression: Box<Expression>,
11769}
11770
11771/// SafeDivide
11772#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11773#[cfg_attr(feature = "bindings", derive(TS))]
11774pub struct SafeDivide {
11775    pub this: Box<Expression>,
11776    pub expression: Box<Expression>,
11777}
11778
11779/// SafeMultiply
11780#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11781#[cfg_attr(feature = "bindings", derive(TS))]
11782pub struct SafeMultiply {
11783    pub this: Box<Expression>,
11784    pub expression: Box<Expression>,
11785}
11786
11787/// SafeSubtract
11788#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11789#[cfg_attr(feature = "bindings", derive(TS))]
11790pub struct SafeSubtract {
11791    pub this: Box<Expression>,
11792    pub expression: Box<Expression>,
11793}
11794
11795/// SHA2
11796#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11797#[cfg_attr(feature = "bindings", derive(TS))]
11798pub struct SHA2 {
11799    pub this: Box<Expression>,
11800    #[serde(default)]
11801    pub length: Option<i64>,
11802}
11803
11804/// SHA2Digest
11805#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11806#[cfg_attr(feature = "bindings", derive(TS))]
11807pub struct SHA2Digest {
11808    pub this: Box<Expression>,
11809    #[serde(default)]
11810    pub length: Option<i64>,
11811}
11812
11813/// SortArray
11814#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11815#[cfg_attr(feature = "bindings", derive(TS))]
11816pub struct SortArray {
11817    pub this: Box<Expression>,
11818    #[serde(default)]
11819    pub asc: Option<Box<Expression>>,
11820    #[serde(default)]
11821    pub nulls_first: Option<Box<Expression>>,
11822}
11823
11824/// SplitPart
11825#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11826#[cfg_attr(feature = "bindings", derive(TS))]
11827pub struct SplitPart {
11828    pub this: Box<Expression>,
11829    #[serde(default)]
11830    pub delimiter: Option<Box<Expression>>,
11831    #[serde(default)]
11832    pub part_index: Option<Box<Expression>>,
11833}
11834
11835/// SUBSTRING_INDEX(str, delim, count)
11836#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11837#[cfg_attr(feature = "bindings", derive(TS))]
11838pub struct SubstringIndex {
11839    pub this: Box<Expression>,
11840    #[serde(default)]
11841    pub delimiter: Option<Box<Expression>>,
11842    #[serde(default)]
11843    pub count: Option<Box<Expression>>,
11844}
11845
11846/// StandardHash
11847#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11848#[cfg_attr(feature = "bindings", derive(TS))]
11849pub struct StandardHash {
11850    pub this: Box<Expression>,
11851    #[serde(default)]
11852    pub expression: Option<Box<Expression>>,
11853}
11854
11855/// StrPosition
11856#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11857#[cfg_attr(feature = "bindings", derive(TS))]
11858pub struct StrPosition {
11859    pub this: Box<Expression>,
11860    #[serde(default)]
11861    pub substr: Option<Box<Expression>>,
11862    #[serde(default)]
11863    pub position: Option<Box<Expression>>,
11864    #[serde(default)]
11865    pub occurrence: Option<Box<Expression>>,
11866}
11867
11868/// Search
11869#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11870#[cfg_attr(feature = "bindings", derive(TS))]
11871pub struct Search {
11872    pub this: Box<Expression>,
11873    pub expression: Box<Expression>,
11874    #[serde(default)]
11875    pub json_scope: Option<Box<Expression>>,
11876    #[serde(default)]
11877    pub analyzer: Option<Box<Expression>>,
11878    #[serde(default)]
11879    pub analyzer_options: Option<Box<Expression>>,
11880    #[serde(default)]
11881    pub search_mode: Option<Box<Expression>>,
11882}
11883
11884/// SearchIp
11885#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11886#[cfg_attr(feature = "bindings", derive(TS))]
11887pub struct SearchIp {
11888    pub this: Box<Expression>,
11889    pub expression: Box<Expression>,
11890}
11891
11892/// StrToDate
11893#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11894#[cfg_attr(feature = "bindings", derive(TS))]
11895pub struct StrToDate {
11896    pub this: Box<Expression>,
11897    #[serde(default)]
11898    pub format: Option<String>,
11899    #[serde(default)]
11900    pub safe: Option<Box<Expression>>,
11901}
11902
11903/// StrToTime
11904#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11905#[cfg_attr(feature = "bindings", derive(TS))]
11906pub struct StrToTime {
11907    pub this: Box<Expression>,
11908    pub format: String,
11909    #[serde(default)]
11910    pub zone: Option<Box<Expression>>,
11911    #[serde(default)]
11912    pub safe: Option<Box<Expression>>,
11913    #[serde(default)]
11914    pub target_type: Option<Box<Expression>>,
11915}
11916
11917/// StrToUnix
11918#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11919#[cfg_attr(feature = "bindings", derive(TS))]
11920pub struct StrToUnix {
11921    #[serde(default)]
11922    pub this: Option<Box<Expression>>,
11923    #[serde(default)]
11924    pub format: Option<String>,
11925}
11926
11927/// StrToMap
11928#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11929#[cfg_attr(feature = "bindings", derive(TS))]
11930pub struct StrToMap {
11931    pub this: Box<Expression>,
11932    #[serde(default)]
11933    pub pair_delim: Option<Box<Expression>>,
11934    #[serde(default)]
11935    pub key_value_delim: Option<Box<Expression>>,
11936    #[serde(default)]
11937    pub duplicate_resolution_callback: Option<Box<Expression>>,
11938}
11939
11940/// NumberToStr
11941#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11942#[cfg_attr(feature = "bindings", derive(TS))]
11943pub struct NumberToStr {
11944    pub this: Box<Expression>,
11945    pub format: String,
11946    #[serde(default)]
11947    pub culture: Option<Box<Expression>>,
11948}
11949
11950/// FromBase
11951#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11952#[cfg_attr(feature = "bindings", derive(TS))]
11953pub struct FromBase {
11954    pub this: Box<Expression>,
11955    pub expression: Box<Expression>,
11956}
11957
11958/// Stuff
11959#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11960#[cfg_attr(feature = "bindings", derive(TS))]
11961pub struct Stuff {
11962    pub this: Box<Expression>,
11963    #[serde(default)]
11964    pub start: Option<Box<Expression>>,
11965    #[serde(default)]
11966    pub length: Option<i64>,
11967    pub expression: Box<Expression>,
11968}
11969
11970/// TimeToStr
11971#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11972#[cfg_attr(feature = "bindings", derive(TS))]
11973pub struct TimeToStr {
11974    pub this: Box<Expression>,
11975    pub format: String,
11976    #[serde(default)]
11977    pub culture: Option<Box<Expression>>,
11978    #[serde(default)]
11979    pub zone: Option<Box<Expression>>,
11980}
11981
11982/// TimeStrToTime
11983#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11984#[cfg_attr(feature = "bindings", derive(TS))]
11985pub struct TimeStrToTime {
11986    pub this: Box<Expression>,
11987    #[serde(default)]
11988    pub zone: Option<Box<Expression>>,
11989}
11990
11991/// TsOrDsAdd
11992#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11993#[cfg_attr(feature = "bindings", derive(TS))]
11994pub struct TsOrDsAdd {
11995    pub this: Box<Expression>,
11996    pub expression: Box<Expression>,
11997    #[serde(default)]
11998    pub unit: Option<String>,
11999    #[serde(default)]
12000    pub return_type: Option<Box<Expression>>,
12001}
12002
12003/// TsOrDsDiff
12004#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12005#[cfg_attr(feature = "bindings", derive(TS))]
12006pub struct TsOrDsDiff {
12007    pub this: Box<Expression>,
12008    pub expression: Box<Expression>,
12009    #[serde(default)]
12010    pub unit: Option<String>,
12011}
12012
12013/// TsOrDsToDate
12014#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12015#[cfg_attr(feature = "bindings", derive(TS))]
12016pub struct TsOrDsToDate {
12017    pub this: Box<Expression>,
12018    #[serde(default)]
12019    pub format: Option<String>,
12020    #[serde(default)]
12021    pub safe: Option<Box<Expression>>,
12022}
12023
12024/// TsOrDsToTime
12025#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12026#[cfg_attr(feature = "bindings", derive(TS))]
12027pub struct TsOrDsToTime {
12028    pub this: Box<Expression>,
12029    #[serde(default)]
12030    pub format: Option<String>,
12031    #[serde(default)]
12032    pub safe: Option<Box<Expression>>,
12033}
12034
12035/// Unhex
12036#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12037#[cfg_attr(feature = "bindings", derive(TS))]
12038pub struct Unhex {
12039    pub this: Box<Expression>,
12040    #[serde(default)]
12041    pub expression: Option<Box<Expression>>,
12042}
12043
12044/// Uniform
12045#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12046#[cfg_attr(feature = "bindings", derive(TS))]
12047pub struct Uniform {
12048    pub this: Box<Expression>,
12049    pub expression: Box<Expression>,
12050    #[serde(default)]
12051    pub gen: Option<Box<Expression>>,
12052    #[serde(default)]
12053    pub seed: Option<Box<Expression>>,
12054}
12055
12056/// UnixToStr
12057#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12058#[cfg_attr(feature = "bindings", derive(TS))]
12059pub struct UnixToStr {
12060    pub this: Box<Expression>,
12061    #[serde(default)]
12062    pub format: Option<String>,
12063}
12064
12065/// UnixToTime
12066#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12067#[cfg_attr(feature = "bindings", derive(TS))]
12068pub struct UnixToTime {
12069    pub this: Box<Expression>,
12070    #[serde(default)]
12071    pub scale: Option<i64>,
12072    #[serde(default)]
12073    pub zone: Option<Box<Expression>>,
12074    #[serde(default)]
12075    pub hours: Option<Box<Expression>>,
12076    #[serde(default)]
12077    pub minutes: Option<Box<Expression>>,
12078    #[serde(default)]
12079    pub format: Option<String>,
12080    #[serde(default)]
12081    pub target_type: Option<Box<Expression>>,
12082}
12083
12084/// Uuid
12085#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12086#[cfg_attr(feature = "bindings", derive(TS))]
12087pub struct Uuid {
12088    #[serde(default)]
12089    pub this: Option<Box<Expression>>,
12090    #[serde(default)]
12091    pub name: Option<String>,
12092    #[serde(default)]
12093    pub is_string: Option<Box<Expression>>,
12094}
12095
12096/// TimestampFromParts
12097#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12098#[cfg_attr(feature = "bindings", derive(TS))]
12099pub struct TimestampFromParts {
12100    #[serde(default)]
12101    pub zone: Option<Box<Expression>>,
12102    #[serde(default)]
12103    pub milli: Option<Box<Expression>>,
12104    #[serde(default)]
12105    pub this: Option<Box<Expression>>,
12106    #[serde(default)]
12107    pub expression: Option<Box<Expression>>,
12108}
12109
12110/// TimestampTzFromParts
12111#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12112#[cfg_attr(feature = "bindings", derive(TS))]
12113pub struct TimestampTzFromParts {
12114    #[serde(default)]
12115    pub zone: Option<Box<Expression>>,
12116}
12117
12118/// Corr
12119#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12120#[cfg_attr(feature = "bindings", derive(TS))]
12121pub struct Corr {
12122    pub this: Box<Expression>,
12123    pub expression: Box<Expression>,
12124    #[serde(default)]
12125    pub null_on_zero_variance: Option<Box<Expression>>,
12126}
12127
12128/// WidthBucket
12129#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12130#[cfg_attr(feature = "bindings", derive(TS))]
12131pub struct WidthBucket {
12132    pub this: Box<Expression>,
12133    #[serde(default)]
12134    pub min_value: Option<Box<Expression>>,
12135    #[serde(default)]
12136    pub max_value: Option<Box<Expression>>,
12137    #[serde(default)]
12138    pub num_buckets: Option<Box<Expression>>,
12139    #[serde(default)]
12140    pub threshold: Option<Box<Expression>>,
12141}
12142
12143/// CovarSamp
12144#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12145#[cfg_attr(feature = "bindings", derive(TS))]
12146pub struct CovarSamp {
12147    pub this: Box<Expression>,
12148    pub expression: Box<Expression>,
12149}
12150
12151/// CovarPop
12152#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12153#[cfg_attr(feature = "bindings", derive(TS))]
12154pub struct CovarPop {
12155    pub this: Box<Expression>,
12156    pub expression: Box<Expression>,
12157}
12158
12159/// Week
12160#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12161#[cfg_attr(feature = "bindings", derive(TS))]
12162pub struct Week {
12163    pub this: Box<Expression>,
12164    #[serde(default)]
12165    pub mode: Option<Box<Expression>>,
12166}
12167
12168/// XMLElement
12169#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12170#[cfg_attr(feature = "bindings", derive(TS))]
12171pub struct XMLElement {
12172    pub this: Box<Expression>,
12173    #[serde(default)]
12174    pub expressions: Vec<Expression>,
12175    #[serde(default)]
12176    pub evalname: Option<Box<Expression>>,
12177}
12178
12179/// XMLGet
12180#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12181#[cfg_attr(feature = "bindings", derive(TS))]
12182pub struct XMLGet {
12183    pub this: Box<Expression>,
12184    pub expression: Box<Expression>,
12185    #[serde(default)]
12186    pub instance: Option<Box<Expression>>,
12187}
12188
12189/// XMLTable
12190#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12191#[cfg_attr(feature = "bindings", derive(TS))]
12192pub struct XMLTable {
12193    pub this: Box<Expression>,
12194    #[serde(default)]
12195    pub namespaces: Option<Box<Expression>>,
12196    #[serde(default)]
12197    pub passing: Option<Box<Expression>>,
12198    #[serde(default)]
12199    pub columns: Vec<Expression>,
12200    #[serde(default)]
12201    pub by_ref: Option<Box<Expression>>,
12202}
12203
12204/// XMLKeyValueOption
12205#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12206#[cfg_attr(feature = "bindings", derive(TS))]
12207pub struct XMLKeyValueOption {
12208    pub this: Box<Expression>,
12209    #[serde(default)]
12210    pub expression: Option<Box<Expression>>,
12211}
12212
12213/// Zipf
12214#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12215#[cfg_attr(feature = "bindings", derive(TS))]
12216pub struct Zipf {
12217    pub this: Box<Expression>,
12218    #[serde(default)]
12219    pub elementcount: Option<Box<Expression>>,
12220    #[serde(default)]
12221    pub gen: Option<Box<Expression>>,
12222}
12223
12224/// Merge
12225#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12226#[cfg_attr(feature = "bindings", derive(TS))]
12227pub struct Merge {
12228    pub this: Box<Expression>,
12229    pub using: Box<Expression>,
12230    #[serde(default)]
12231    pub on: Option<Box<Expression>>,
12232    #[serde(default)]
12233    pub using_cond: Option<Box<Expression>>,
12234    #[serde(default)]
12235    pub whens: Option<Box<Expression>>,
12236    #[serde(default)]
12237    pub with_: Option<Box<Expression>>,
12238    #[serde(default)]
12239    pub returning: Option<Box<Expression>>,
12240}
12241
12242/// When
12243#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12244#[cfg_attr(feature = "bindings", derive(TS))]
12245pub struct When {
12246    #[serde(default)]
12247    pub matched: Option<Box<Expression>>,
12248    #[serde(default)]
12249    pub source: Option<Box<Expression>>,
12250    #[serde(default)]
12251    pub condition: Option<Box<Expression>>,
12252    pub then: Box<Expression>,
12253}
12254
12255/// Wraps around one or more WHEN [NOT] MATCHED [...] clauses.
12256#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12257#[cfg_attr(feature = "bindings", derive(TS))]
12258pub struct Whens {
12259    #[serde(default)]
12260    pub expressions: Vec<Expression>,
12261}
12262
12263/// NextValueFor
12264#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12265#[cfg_attr(feature = "bindings", derive(TS))]
12266pub struct NextValueFor {
12267    pub this: Box<Expression>,
12268    #[serde(default)]
12269    pub order: Option<Box<Expression>>,
12270}
12271
12272
12273#[cfg(test)]
12274mod tests {
12275    use super::*;
12276
12277    #[test]
12278    #[cfg(feature = "bindings")]
12279    fn export_typescript_types() {
12280        // This test exports TypeScript types to the generated directory
12281        // Run with: cargo test -p polyglot-sql --features bindings export_typescript_types
12282        Expression::export_all(&ts_rs::Config::default()).expect("Failed to export Expression types");
12283    }
12284
12285    #[test]
12286    fn test_simple_select_builder() {
12287        let select = Select::new()
12288            .column(Expression::star())
12289            .from(Expression::Table(TableRef::new("users")));
12290
12291        assert_eq!(select.expressions.len(), 1);
12292        assert!(select.from.is_some());
12293    }
12294
12295    #[test]
12296    fn test_expression_alias() {
12297        let expr = Expression::column("id").alias("user_id");
12298
12299        match expr {
12300            Expression::Alias(a) => {
12301                assert_eq!(a.alias.name, "user_id");
12302            }
12303            _ => panic!("Expected Alias"),
12304        }
12305    }
12306
12307    #[test]
12308    fn test_literal_creation() {
12309        let num = Expression::number(42);
12310        let str = Expression::string("hello");
12311
12312        match num {
12313            Expression::Literal(Literal::Number(n)) => assert_eq!(n, "42"),
12314            _ => panic!("Expected Number"),
12315        }
12316
12317        match str {
12318            Expression::Literal(Literal::String(s)) => assert_eq!(s, "hello"),
12319            _ => panic!("Expected String"),
12320        }
12321    }
12322
12323    #[test]
12324    fn test_expression_sql() {
12325        let expr = crate::parse_one("SELECT 1 + 2", crate::DialectType::Generic).unwrap();
12326        assert_eq!(expr.sql(), "SELECT 1 + 2");
12327    }
12328
12329    #[test]
12330    fn test_expression_sql_for() {
12331        let expr = crate::parse_one("SELECT IF(x > 0, 1, 0)", crate::DialectType::Generic).unwrap();
12332        let sql = expr.sql_for(crate::DialectType::Generic);
12333        assert!(sql.contains("IF"));
12334    }
12335}