diff --git a/Makefile b/Makefile index eb70f763..7fb55a18 100644 --- a/Makefile +++ b/Makefile @@ -60,4 +60,4 @@ update-mod: install-dep: bin/golangci-lint bin/golangci-lint: - GOBIN=$(CURDIR)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(CURDIR)/bin v1.62.2 diff --git a/ast/ast.go b/ast/ast.go index f7263943..9746f538 100644 --- a/ast/ast.go +++ b/ast/ast.go @@ -101,16 +101,28 @@ func (Insert) isStatement() {} func (Delete) isStatement() {} func (Update) isStatement() {} -// QueryExpr represents set operator operands. +// QueryExpr represents query expression, which can be body of QueryStatement or subqueries. +// Select and FromQuery are leaf QueryExpr and others wrap other QueryExpr. type QueryExpr interface { Node isQueryExpr() } func (Select) isQueryExpr() {} +func (Query) isQueryExpr() {} +func (FromQuery) isQueryExpr() {} func (SubQuery) isQueryExpr() {} func (CompoundQuery) isQueryExpr() {} +// PipeOperator represents pipe operator node which can be appeared in Query. +type PipeOperator interface { + Node + isPipeOperator() +} + +func (PipeSelect) isPipeOperator() {} +func (PipeWhere) isPipeOperator() {} + // SelectItem represents expression in SELECT clause result columns list. type SelectItem interface { Node @@ -144,6 +156,7 @@ func (PathTableExpr) isTableExpr() {} func (SubQueryTableExpr) isTableExpr() {} func (ParenTableExpr) isTableExpr() {} func (Join) isTableExpr() {} +func (TVFCallExpr) isTableExpr() {} // JoinCondition represents condition part of JOIN expression. type JoinCondition interface { @@ -172,6 +185,7 @@ func (CallExpr) isExpr() {} func (CountStarExpr) isExpr() {} func (CastExpr) isExpr() {} func (ExtractExpr) isExpr() {} +func (WithExpr) isExpr() {} func (ReplaceFieldsExpr) isExpr() {} func (CaseExpr) isExpr() {} func (IfExpr) isExpr() {} @@ -220,6 +234,15 @@ func (IntervalArg) isArg() {} func (SequenceArg) isArg() {} func (LambdaArg) isArg() {} +type TVFArg interface { + Node + isTVFArg() +} + +func (ExprArg) isTVFArg() {} +func (ModelArg) isTVFArg() {} +func (TableArg) isTVFArg() {} + // NullHandlingModifier represents IGNORE/RESPECT NULLS of aggregate function calls type NullHandlingModifier interface { Node @@ -506,18 +529,38 @@ func (ChangeStreamSetOptions) isChangeStreamAlteration() {} // QueryStatement is query statement node. // -// {{.Hint | sqlOpt}} {{.With | sqlOpt}} {{.Query | sql}} -// -// https://cloud.google.com/spanner/docs/query-syntax +// {{.Hint | sqlOpt}} {{.Query | sql}} type QueryStatement struct { - // pos = (Hint ?? With ?? Query).pos + // pos = (Hint ?? Query).pos // end = Query.end Hint *Hint // optional - With *With // optional Query QueryExpr } +// Query is query expression node with optional CTE, ORDER BY, LIMIT, and pipe operators. +// Usually, it is used as outermost QueryExpr in SubQuery and QueryStatement +// +// {{.With | sqlOpt}} +// {{.Query | sql}} +// {{.OrderBy | sqlOpt}} +// {{.Limit | sqlOpt}} +// {{.PipeOperators | sqlJoin ", "}} +// +// https://cloud.google.com/spanner/docs/query-syntax +type Query struct { + // pos = (With ?? Query).pos + // end = Query.end + + With *With + Query QueryExpr + + OrderBy *OrderBy // optional + Limit *Limit // optional + + PipeOperators []PipeOperator +} + // Hint is hint node. // // @{{"{"}}{{.Records | sqlJoin ","}}{{"}"}} @@ -570,30 +613,26 @@ type CTE struct { // Select is SELECT statement node. // // SELECT -// {{if .Distinct}}DISTINCT{{end}} +// {{.AllOrDistinct}} // {{.As | sqlOpt}} // {{.Results | sqlJoin ","}} // {{.From | sqlOpt}} // {{.Where | sqlOpt}} // {{.GroupBy | sqlOpt}} // {{.Having | sqlOpt}} -// {{.OrderBy | sqlOpt}} -// {{.Limit | sqlOpt}} type Select struct { // pos = Select - // end = (Limit ?? OrderBy ?? Having ?? GroupBy ?? Where ?? From ?? Results[$]).end + // end = (Having ?? GroupBy ?? Where ?? From ?? Results[$]).end Select token.Pos // position of "select" keyword - Distinct bool - As SelectAs // optional - Results []SelectItem // len(Results) > 0 - From *From // optional - Where *Where // optional - GroupBy *GroupBy // optional - Having *Having // optional - OrderBy *OrderBy // optional - Limit *Limit // optional + AllOrDistinct AllOrDistinct // optional + As SelectAs // optional + Results []SelectItem // len(Results) > 0 + From *From // optional + Where *Where // optional + GroupBy *GroupBy // optional + Having *Having // optional } // AsStruct represents AS STRUCT node in SELECT clause. @@ -629,56 +668,110 @@ type AsTypeName struct { TypeName *NamedType } -// CompoundQuery is query statement node compounded by set operators. +// FromQuery is FROM query expression node. +type FromQuery struct { + // pos = From.pos + // end = From.end + + From *From +} + +func (f *FromQuery) SQL() string { + return f.From.SQL() +} + +// CompoundQuery is query expression node compounded by set operators. +// Note: A single CompoundQuery can express query expressions compounded by the same set operator. +// If there are mixed Op or Distinct in query expression, CompoundQuery will be nested. // -// {{.Queries | sqlJoin (printf "%s %s" .Op or(and(.Distinct, "DISTINCT"), "ALL"))}} -// {{.OrderBy | sqlOpt}} -// {{.Limit | sqlOpt}} +// {{.Queries | sqlJoin (printf "%s %s" .Op .AllOrDistinct)}} type CompoundQuery struct { // pos = Queries[0].pos - // end = (Limit ?? OrderBy ?? Queries[$]).end + // end = Queries[$].end - Op SetOp - Distinct bool - Queries []QueryExpr // len(Queries) >= 2 - OrderBy *OrderBy // optional - Limit *Limit // optional + Op SetOp + AllOrDistinct AllOrDistinct + Queries []QueryExpr // len(Queries) >= 2 } -// SubQuery is subquery statement node. +// SubQuery is parenthesized query expression node. +// Note: subquery expression is expressed as a ParenTableExpr. Maybe better to rename as like ParenQueryExpr? // -// ({{.Query | sql}}) {{.OrderBy | sqlOpt}} {{.Limit | sqlOpt}} +// ({{.Query | sql}}) type SubQuery struct { // pos = Lparen - // end = (Limit ?? OrderBy).end || Rparen + 1 + // end = Rparen + 1 Lparen, Rparen token.Pos // position of "(" and ")" - Query QueryExpr - OrderBy *OrderBy // optional - Limit *Limit // optional + Query QueryExpr +} + +// StarModifierExcept is EXCEPT node in Star and DotStar of SelectItem. +// +// EXCEPT ({{Columns | sqlJoin ", "}}) +type StarModifierExcept struct { + // pos = Except + // end = Rparen + 1 + + Except token.Pos + Rparen token.Pos + + Columns []*Ident +} + +// StarModifierReplaceItem is a single item of StarModifierReplace. +// +// {{.Expr | sql}} AS {{.Name | sql}} +type StarModifierReplaceItem struct { + // pos = Expr.pos + // end = Name.end + + Expr Expr + Name *Ident +} + +// StarModifierReplace is REPLACE node in Star and DotStar of SelectItem. +// +// REPLACE ({{Columns | sqlJoin ", "}}) +type StarModifierReplace struct { + // pos = Replace + // end = Rparen + 1 + + Replace token.Pos + Rparen token.Pos + + Columns []*StarModifierReplaceItem } // Star is a single * in SELECT result columns list. // -// * +// {{"*"}} {{.Except | sqlOpt}} {{.Replace | sqlOpt}} +// +// Note: The text/template notation escapes * to avoid normalize * to - by some formatters +// because the prefix * is ambiguous with bulletin list. type Star struct { // pos = Star - // end = Star + 1 + // end = (Replace ?? Except).end || Star + 1 Star token.Pos // position of "*" + + Except *StarModifierExcept // optional + Replace *StarModifierReplace // optional } // DotStar is expression with * in SELECT result columns list. // -// {{.Expr | sql}}.* +// {{.Expr | sql}}.* {{.Except | sqlOpt}} {{.Replace | sqlOpt}} type DotStar struct { // pos = Expr.pos - // end = Star + 1 + // end = (Replace ?? Except).end || Star + 1 Star token.Pos // position of "*" - Expr Expr + Expr Expr + Except *StarModifierExcept // optional + Replace *StarModifierReplace // optional } // Alias is aliased expression by AS clause. @@ -830,6 +923,42 @@ type Offset struct { Value IntValue } +// ================================================================================ +// +// Pipe Operators +// +// Must be the same order in document. +// https://github.com/google/zetasql/blob/master/docs/pipe-syntax.md#pipe-operators +// TODO: The reference should be Spanner reference when it is supported. +// +// ================================================================================ + +// PipeSelect is SELECT pipe operator node. +// +// |> SELECT {{.AllOrDistinct}} {{.As | sqlOpt}} {{.Results | sqlJoin ", "}} +type PipeSelect struct { + // pos = Pipe + // end = Results[$].end + + Pipe token.Pos // position of "|>" + + AllOrDistinct AllOrDistinct // optional + As SelectAs // optional + Results []SelectItem // len(Results) > 0 +} + +// PipeWhere is WHERE pipe operator node. +// +// |> WHERE {{.Expr | sql}} +type PipeWhere struct { + // pos = Pipe + // end = Expr.end + + Pipe token.Pos // position of "|>" + + Expr Expr +} + // ================================================================================ // // JOIN @@ -1164,9 +1293,10 @@ type SubscriptSpecifierKeyword struct { // {{.NullHandling | sqlOpt}} // {{.Having | sqlOpt}} // ) +// {{.Hint | sqlOpt}} type CallExpr struct { // pos = Func.pos - // end = Rparen + 1 + // end = Hint.end || Rparen + 1 Rparen token.Pos // position of ")" @@ -1176,6 +1306,29 @@ type CallExpr struct { NamedArgs []*NamedArg NullHandling NullHandlingModifier // optional Having HavingModifier // optional + Hint *Hint // optional +} + +// TVFCallExpr is table-valued function call expression node. +// +// {{.Name | sql}}( +// {{.Args | sqlJoin ", "}} +// {{if len(.Args) > 0 && len(.NamedArgs) > 0}}, {{end}} +// {{.NamedArgs | sqlJoin ", "}} +// ) +// {{.Hint | sqlOpt}} +// {{.Sample | sqlOpt}} +type TVFCallExpr struct { + // pos = Name.pos + // end = (Sample ?? Hint).end || Rparen + 1 + + Rparen token.Pos // position of ")" + + Name *Path + Args []TVFArg + NamedArgs []*NamedArg + Hint *Hint // optional + Sample *TableSample // optional } // ExprArg is argument of the generic function call. @@ -1228,6 +1381,30 @@ type LambdaArg struct { Expr Expr } +// ModelArg is argument of model function call. +// +// MODEL {{.Name | sql}} +type ModelArg struct { + // pos = Model + // end = Name.end + + Model token.Pos // position of "MODEL" keyword + + Name *Path +} + +// TableArg is TABLE table_name argument of table valued function call. +// +// TABLE {{.Name | sql}} +type TableArg struct { + // pos = Table + // end = Name.end + + Table token.Pos // position of "TABLE" keyword + + Name *Path +} + // NamedArg represents a name and value pair in named arguments // // {{.Name | sql}} => {{.Value | sql}} @@ -1346,6 +1523,31 @@ type AtTimeZone struct { Expr Expr } +// WithExprVar is "name AS expr" node in WITH expression. +// +// {{.Name | sql}} AS {{.Expr | sql}} +type WithExprVar struct { + // pos = Name.pos + // end = Expr.end + + Name *Ident + Expr Expr +} + +// WithExpr is WITH expression node. +// +// WITH({{.Vars | sqlJoin ", "}}, {{.Expr | sql}}) +type WithExpr struct { + // pos = With + // end = Rparen + 1 + + With token.Pos // position of "WITH" keyword + Rparen token.Pos // position of ")" + + Vars []*WithExprVar // len(Vars) > 0 + Expr Expr +} + // CastExpr is CAST/SAFE_CAST call expression node. // // {{if .Safe}}SAFE_{{end}}CAST({{.Expr | sql}} AS {{.Type | sql}}) @@ -3228,15 +3430,17 @@ type SizedSchemaType struct { // ArraySchemaType is array type node in schema. // -// ARRAY<{{.Item | sql}}> +// ARRAY<{{.Item | sql}}>{{if .NamedArgs}}({{.NamedArgs | sqlJoin ", "}}){{end}} type ArraySchemaType struct { // pos = Array - // end = Gt + 1 + // end = Rparen + 1 || Gt + 1 - Array token.Pos // position of "ARRAY" keyword - Gt token.Pos // position of ">" + Array token.Pos // position of "ARRAY" keyword + Gt token.Pos // position of ">" + Rparen token.Pos // position of ")" when len(NamedArgs) > 0 - Item SchemaType // ScalarSchemaType or SizedSchemaType + Item SchemaType // ScalarSchemaType or SizedSchemaType + NamedArgs []*NamedArg } // ================================================================================ diff --git a/ast/const.go b/ast/const.go index 9ea9a7d9..d72748d1 100644 --- a/ast/const.go +++ b/ast/const.go @@ -1,5 +1,14 @@ package ast +// AllOrDistinct represents ALL or DISTINCT in SELECT or set operations, etc. +// If it is optional, it may be an empty string, so handle it according to the context. +type AllOrDistinct string + +const ( + AllOrDistinctAll AllOrDistinct = "ALL" + AllOrDistinctDistinct AllOrDistinct = "DISTINCT" +) + type TableHintKey string const ( diff --git a/ast/pos.go b/ast/pos.go index 0723bb16..c5a89ad6 100644 --- a/ast/pos.go +++ b/ast/pos.go @@ -7,13 +7,21 @@ import ( ) func (q *QueryStatement) Pos() token.Pos { - return nodePos(nodeChoice(wrapNode(q.Hint), wrapNode(q.With), wrapNode(q.Query))) + return nodePos(nodeChoice(wrapNode(q.Hint), wrapNode(q.Query))) } func (q *QueryStatement) End() token.Pos { return nodeEnd(wrapNode(q.Query)) } +func (q *Query) Pos() token.Pos { + return nodePos(nodeChoice(wrapNode(q.With), wrapNode(q.Query))) +} + +func (q *Query) End() token.Pos { + return nodeEnd(wrapNode(q.Query)) +} + func (h *Hint) Pos() token.Pos { return h.Atmark } @@ -51,7 +59,7 @@ func (s *Select) Pos() token.Pos { } func (s *Select) End() token.Pos { - return nodeEnd(nodeChoice(wrapNode(s.Limit), wrapNode(s.OrderBy), wrapNode(s.Having), wrapNode(s.GroupBy), wrapNode(s.Where), wrapNode(s.From), nodeSliceLast(s.Results))) + return nodeEnd(nodeChoice(wrapNode(s.Having), wrapNode(s.GroupBy), wrapNode(s.Where), wrapNode(s.From), nodeSliceLast(s.Results))) } func (a *AsStruct) Pos() token.Pos { @@ -78,12 +86,20 @@ func (a *AsTypeName) End() token.Pos { return nodeEnd(wrapNode(a.TypeName)) } +func (f *FromQuery) Pos() token.Pos { + return nodePos(wrapNode(f.From)) +} + +func (f *FromQuery) End() token.Pos { + return nodeEnd(wrapNode(f.From)) +} + func (c *CompoundQuery) Pos() token.Pos { return nodePos(nodeSliceIndex(c.Queries, 0)) } func (c *CompoundQuery) End() token.Pos { - return nodeEnd(nodeChoice(wrapNode(c.Limit), wrapNode(c.OrderBy), nodeSliceLast(c.Queries))) + return nodeEnd(nodeSliceLast(c.Queries)) } func (s *SubQuery) Pos() token.Pos { @@ -91,7 +107,31 @@ func (s *SubQuery) Pos() token.Pos { } func (s *SubQuery) End() token.Pos { - return posChoice(nodeEnd(nodeChoice(wrapNode(s.Limit), wrapNode(s.OrderBy))), posAdd(s.Rparen, 1)) + return posAdd(s.Rparen, 1) +} + +func (s *StarModifierExcept) Pos() token.Pos { + return s.Except +} + +func (s *StarModifierExcept) End() token.Pos { + return posAdd(s.Rparen, 1) +} + +func (s *StarModifierReplaceItem) Pos() token.Pos { + return nodePos(wrapNode(s.Expr)) +} + +func (s *StarModifierReplaceItem) End() token.Pos { + return nodeEnd(wrapNode(s.Name)) +} + +func (s *StarModifierReplace) Pos() token.Pos { + return s.Replace +} + +func (s *StarModifierReplace) End() token.Pos { + return posAdd(s.Rparen, 1) } func (s *Star) Pos() token.Pos { @@ -99,7 +139,7 @@ func (s *Star) Pos() token.Pos { } func (s *Star) End() token.Pos { - return posAdd(s.Star, 1) + return posChoice(nodeEnd(nodeChoice(wrapNode(s.Replace), wrapNode(s.Except))), posAdd(s.Star, 1)) } func (d *DotStar) Pos() token.Pos { @@ -107,7 +147,7 @@ func (d *DotStar) Pos() token.Pos { } func (d *DotStar) End() token.Pos { - return posAdd(d.Star, 1) + return posChoice(nodeEnd(nodeChoice(wrapNode(d.Replace), wrapNode(d.Except))), posAdd(d.Star, 1)) } func (a *Alias) Pos() token.Pos { @@ -206,6 +246,22 @@ func (o *Offset) End() token.Pos { return nodeEnd(wrapNode(o.Value)) } +func (p *PipeSelect) Pos() token.Pos { + return p.Pipe +} + +func (p *PipeSelect) End() token.Pos { + return nodeEnd(nodeSliceLast(p.Results)) +} + +func (p *PipeWhere) Pos() token.Pos { + return p.Pipe +} + +func (p *PipeWhere) End() token.Pos { + return nodeEnd(wrapNode(p.Expr)) +} + func (u *Unnest) Pos() token.Pos { return u.Unnest } @@ -395,7 +451,15 @@ func (c *CallExpr) Pos() token.Pos { } func (c *CallExpr) End() token.Pos { - return posAdd(c.Rparen, 1) + return posChoice(nodeEnd(wrapNode(c.Hint)), posAdd(c.Rparen, 1)) +} + +func (t *TVFCallExpr) Pos() token.Pos { + return nodePos(wrapNode(t.Name)) +} + +func (t *TVFCallExpr) End() token.Pos { + return posChoice(nodeEnd(nodeChoice(wrapNode(t.Sample), wrapNode(t.Hint))), posAdd(t.Rparen, 1)) } func (e *ExprArg) Pos() token.Pos { @@ -430,6 +494,22 @@ func (l *LambdaArg) End() token.Pos { return nodeEnd(wrapNode(l.Expr)) } +func (m *ModelArg) Pos() token.Pos { + return m.Model +} + +func (m *ModelArg) End() token.Pos { + return nodeEnd(wrapNode(m.Name)) +} + +func (t *TableArg) Pos() token.Pos { + return t.Table +} + +func (t *TableArg) End() token.Pos { + return nodeEnd(wrapNode(t.Name)) +} + func (n *NamedArg) Pos() token.Pos { return nodePos(wrapNode(n.Name)) } @@ -510,6 +590,22 @@ func (a *AtTimeZone) End() token.Pos { return nodeEnd(wrapNode(a.Expr)) } +func (w *WithExprVar) Pos() token.Pos { + return nodePos(wrapNode(w.Name)) +} + +func (w *WithExprVar) End() token.Pos { + return nodeEnd(wrapNode(w.Expr)) +} + +func (w *WithExpr) Pos() token.Pos { + return w.With +} + +func (w *WithExpr) End() token.Pos { + return posAdd(w.Rparen, 1) +} + func (c *CastExpr) Pos() token.Pos { return c.Cast } @@ -1635,7 +1731,7 @@ func (a *ArraySchemaType) Pos() token.Pos { } func (a *ArraySchemaType) End() token.Pos { - return posAdd(a.Gt, 1) + return posChoice(posAdd(a.Rparen, 1), posAdd(a.Gt, 1)) } func (c *CreateSearchIndex) Pos() token.Pos { diff --git a/ast/sql.go b/ast/sql.go index 5197a27b..fe464b8f 100644 --- a/ast/sql.go +++ b/ast/sql.go @@ -80,7 +80,7 @@ func exprPrec(e Expr) prec { case *CallExpr, *CountStarExpr, *CastExpr, *ExtractExpr, *CaseExpr, *IfExpr, *ParenExpr, *ScalarSubQuery, *ArraySubQuery, *ExistsSubQuery, *Param, *Ident, *Path, *ArrayLiteral, *TupleStructLiteral, *TypedStructLiteral, *TypelessStructLiteral, *NullLiteral, *BoolLiteral, *IntLiteral, *FloatLiteral, *StringLiteral, *BytesLiteral, - *DateLiteral, *TimestampLiteral, *NumericLiteral, *JSONLiteral: + *DateLiteral, *TimestampLiteral, *NumericLiteral, *JSONLiteral, *WithExpr: return precLit case *IndexExpr, *SelectorExpr: return precSelector @@ -135,15 +135,16 @@ func paren(p prec, e Expr) string { // ================================================================================ func (q *QueryStatement) SQL() string { - var sql string - if q.Hint != nil { - sql += q.Hint.SQL() + " " - } - if q.With != nil { - sql += q.With.SQL() + " " - } - sql += q.Query.SQL() - return sql + return sqlOpt("", q.Hint, " ") + q.Query.SQL() +} + +func (q *Query) SQL() string { + return sqlOpt("", q.With, " ") + + q.Query.SQL() + + sqlOpt(" ", q.OrderBy, "") + + sqlOpt(" ", q.Limit, "") + + strOpt(len(q.PipeOperators) > 0, " ") + + sqlJoin(q.PipeOperators, " ") } func (h *Hint) SQL() string { @@ -173,15 +174,13 @@ func (c *CTE) SQL() string { func (s *Select) SQL() string { return "SELECT " + - strOpt(s.Distinct, "DISTINCT ") + + strOpt(s.AllOrDistinct != "", string(s.AllOrDistinct)+" ") + sqlOpt("", s.As, " ") + sqlJoin(s.Results, ", ") + sqlOpt(" ", s.From, "") + sqlOpt(" ", s.Where, "") + sqlOpt(" ", s.GroupBy, "") + - sqlOpt(" ", s.Having, "") + - sqlOpt(" ", s.OrderBy, "") + - sqlOpt(" ", s.Limit, "") + sqlOpt(" ", s.Having, "") } func (a *AsStruct) SQL() string { return "AS STRUCT" } @@ -191,43 +190,25 @@ func (a *AsValue) SQL() string { return "AS VALUE" } func (a *AsTypeName) SQL() string { return "AS " + a.TypeName.SQL() } func (c *CompoundQuery) SQL() string { - op := string(c.Op) - if c.Distinct { - op += " DISTINCT" - } else { - op += " ALL" - } - - sql := c.Queries[0].SQL() - for _, q := range c.Queries[1:] { - sql += " " + op + " " + q.SQL() - } - if c.OrderBy != nil { - sql += " " + c.OrderBy.SQL() - } - if c.Limit != nil { - sql += " " + c.Limit.SQL() - } - return sql + return sqlJoin(c.Queries, " "+string(c.Op)+" "+strOpt(c.AllOrDistinct != "", string(c.AllOrDistinct)+" ")) } func (s *SubQuery) SQL() string { - sql := "(" + s.Query.SQL() + ")" - if s.OrderBy != nil { - sql += " " + s.OrderBy.SQL() - } - if s.Limit != nil { - sql += " " + s.Limit.SQL() - } - return sql + return "(" + s.Query.SQL() + ")" } +func (s *StarModifierExcept) SQL() string { return "EXCEPT (" + sqlJoin(s.Columns, " ") + ")" } + +func (s *StarModifierReplaceItem) SQL() string { return s.Expr.SQL() + " AS " + s.Name.SQL() } + +func (s *StarModifierReplace) SQL() string { return "REPLACE (" + sqlJoin(s.Columns, ", ") + ")" } + func (s *Star) SQL() string { - return "*" + return "*" + sqlOpt(" ", s.Except, "") + sqlOpt(" ", s.Replace, "") } func (s *DotStar) SQL() string { - return s.Expr.SQL() + ".*" + return s.Expr.SQL() + ".*" + sqlOpt(" ", s.Except, "") + sqlOpt(" ", s.Replace, "") } func (a *Alias) SQL() string { @@ -297,6 +278,20 @@ func (o *Offset) SQL() string { return "OFFSET " + o.Value.SQL() } +// ================================================================================ +// +// Pipe Operators +// +// ================================================================================ + +func (p *PipeSelect) SQL() string { + return "|> SELECT " + strOpt(p.AllOrDistinct != "", string(p.AllOrDistinct)+" ") + sqlOpt("", p.As, " ") + sqlJoin(p.Results, ", ") +} + +func (p *PipeWhere) SQL() string { + return "|> WHERE " + p.Expr.SQL() +} + // ================================================================================ // // JOIN @@ -503,7 +498,8 @@ func (c *CallExpr) SQL() string { sqlJoin(c.NamedArgs, ", ") + sqlOpt(" ", c.NullHandling, "") + sqlOpt(" ", c.Having, "") + - ")" + ")" + + sqlOpt(" ", c.Hint, "") } func (l *LambdaArg) SQL() string { @@ -515,6 +511,15 @@ func (l *LambdaArg) SQL() string { l.Expr.SQL() } +func (c *TVFCallExpr) SQL() string { + return c.Name.SQL() + "(" + + sqlJoin(c.Args, ", ") + + strOpt(len(c.Args) > 0 && len(c.NamedArgs) > 0, ", ") + + sqlJoin(c.NamedArgs, ", ") + + ")" + + sqlOpt(" ", c.Hint, "") +} + func (n *NamedArg) SQL() string { return n.Name.SQL() + " => " + n.Value.SQL() } func (i *IgnoreNulls) SQL() string { return "IGNORE NULLS" } @@ -541,6 +546,14 @@ func (s *SequenceArg) SQL() string { return "SEQUENCE " + s.Expr.SQL() } +func (s *ModelArg) SQL() string { + return "MODEL " + s.Name.SQL() +} + +func (s *TableArg) SQL() string { + return "TABLE " + s.Name.SQL() +} + func (*CountStarExpr) SQL() string { return "COUNT(*)" } @@ -564,6 +577,12 @@ func (r *ReplaceFieldsExpr) SQL() string { return "REPLACE_FIELDS(" + r.Expr.SQL() + ", " + sqlJoin(r.Fields, ", ") + ")" } +func (n *WithExprVar) SQL() string { return n.Name.SQL() + " AS " + n.Expr.SQL() } + +func (w *WithExpr) SQL() string { + return "WITH(" + sqlJoin(w.Vars, ", ") + ", " + w.Expr.SQL() + ")" +} + func (c *CastExpr) SQL() string { return strOpt(c.Safe, "SAFE_") + "CAST(" + c.Expr.SQL() + " AS " + c.Type.SQL() + ")" } @@ -1057,32 +1076,16 @@ func (r *RenameTable) SQL() string { return "RENAME TABLE " + sqlJoin(r.Tos, ", func (r *RenameTableTo) SQL() string { return r.Old.SQL() + " TO " + r.New.SQL() } func (c *CreateIndex) SQL() string { - sql := "CREATE " - if c.Unique { - sql += "UNIQUE " - } - if c.NullFiltered { - sql += "NULL_FILTERED " - } - sql += "INDEX " - if c.IfNotExists { - sql += "IF NOT EXISTS " - } - sql += c.Name.SQL() + " ON " + c.TableName.SQL() + " (" - for i, k := range c.Keys { - if i != 0 { - sql += ", " - } - sql += k.SQL() - } - sql += ")" - if c.Storing != nil { - sql += " " + c.Storing.SQL() - } - if c.InterleaveIn != nil { - sql += c.InterleaveIn.SQL() - } - return sql + return "CREATE " + + strOpt(c.Unique, "UNIQUE ") + + strOpt(c.NullFiltered, "NULL_FILTERED ") + + "INDEX " + + strOpt(c.IfNotExists, "IF NOT EXISTS ") + + c.Name.SQL() + " ON " + c.TableName.SQL() + "(" + + sqlJoin(c.Keys, ", ") + + ")" + + sqlOpt(" ", c.Storing, "") + + sqlOpt("", c.InterleaveIn, "") } func (c *CreateVectorIndex) SQL() string { @@ -1381,7 +1384,7 @@ func (s *SizedSchemaType) SQL() string { } func (a *ArraySchemaType) SQL() string { - return "ARRAY<" + a.Item.SQL() + ">" + return "ARRAY<" + a.Item.SQL() + ">" + strOpt(len(a.NamedArgs) > 0, "("+sqlJoin(a.NamedArgs, ", ")+")") } // ================================================================================ diff --git a/go.mod b/go.mod index 080ad5ec..a91f42ee 100644 --- a/go.mod +++ b/go.mod @@ -2,17 +2,19 @@ module github.com/cloudspannerecosystem/memefish go 1.22.0 -toolchain go1.22.8 +toolchain go1.23.4 require ( github.com/MakeNowJust/heredoc/v2 v2.0.1 github.com/google/go-cmp v0.6.0 github.com/k0kubun/pp v1.3.1-0.20200204103551-99835366d1cc + github.com/k0kubun/pp/v3 v3.4.1 github.com/pmezard/go-difflib v1.0.0 ) require ( - github.com/mattn/go-colorable v0.1.4 // indirect - github.com/mattn/go-isatty v0.0.12 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect ) diff --git a/go.sum b/go.sum index 40b9b01f..595a205d 100644 --- a/go.sum +++ b/go.sum @@ -6,14 +6,19 @@ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/k0kubun/pp v1.3.1-0.20200204103551-99835366d1cc h1:XLjmW07gT7cG/wb6mavIrvAIWBYaTacPo8UOnxGSspA= github.com/k0kubun/pp v1.3.1-0.20200204103551-99835366d1cc/go.mod h1:qK2ivXw91omfE1uXcpR5kWbAMZRdDOnGbqWlZ7reRFk= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= +github.com/k0kubun/pp/v3 v3.4.1 h1:1WdFZDRRqe8UsR61N/2RoOZ3ziTEqgTPVqKrHeb779Y= +github.com/k0kubun/pp/v3 v3.4.1/go.mod h1:+SiNiqKnBfw1Nkj82Lh5bIeKQOAkPy6Xw9CAZUZ8npI= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= diff --git a/parser.go b/parser.go index 6f0c2f54..237938f6 100644 --- a/parser.go +++ b/parser.go @@ -57,7 +57,7 @@ func (p *Parser) ParseStatements() (stmts []ast.Statement, err error) { return } -// ParseQuery parses a SELECT query statement. +// ParseQuery parses a query statement. func (p *Parser) ParseQuery() (stmt *ast.QueryStatement, err error) { defer func() { if r := recover(); r != nil { @@ -210,7 +210,7 @@ func (p *Parser) ParseDMLs() (dmls []ast.DML, err error) { func (p *Parser) parseStatement() ast.Statement { switch { - case p.Token.Kind == "SELECT" || p.Token.Kind == "@" || p.Token.Kind == "WITH" || p.Token.Kind == "(": + case p.Token.Kind == "SELECT" || p.Token.Kind == "@" || p.Token.Kind == "WITH" || p.Token.Kind == "(" || p.Token.Kind == "FROM": return p.parseQueryStatement() case p.Token.Kind == "CREATE" || p.Token.IsKeywordLike("ALTER") || p.Token.IsKeywordLike("DROP") || p.Token.IsKeywordLike("RENAME") || p.Token.IsKeywordLike("GRANT") || p.Token.IsKeywordLike("REVOKE") || @@ -246,16 +246,89 @@ func (p *Parser) parseStatements(doParse func()) { func (p *Parser) parseQueryStatement() *ast.QueryStatement { hint := p.tryParseHint() - with := p.tryParseWith() query := p.parseQueryExpr() return &ast.QueryStatement{ Hint: hint, - With: with, Query: query, } } +func (p *Parser) parsePipeOperator() ast.PipeOperator { + pos := p.expect("|>").Pos + switch { + case p.Token.Kind == "SELECT": + p.nextToken() + + allOrDistinct := p.tryParseAllOrDistinct() + as := p.tryParseSelectAs() + results := p.parseSelectResults() + + return &ast.PipeSelect{ + Pipe: pos, + AllOrDistinct: allOrDistinct, + As: as, + Results: results, + } + case p.Token.Kind == "WHERE": + p.nextToken() + expr := p.parseExpr() + return &ast.PipeWhere{ + Pipe: pos, + Expr: expr, + } + default: + panic(p.errorfAtToken(&p.Token, "expected pipe operator name, but: %q", p.Token.AsString)) + } +} + +// parsePipeOperators parses pipe operators, which can be empty. +func (p *Parser) parsePipeOperators() []ast.PipeOperator { + var pipeOps []ast.PipeOperator + for { + if p.Token.Kind != "|>" { + break + } + + pipeOps = append(pipeOps, p.parsePipeOperator()) + } + return pipeOps +} + +// parseQuery consumes ORDER BY, LIMIT, and pipe operators. +func (p *Parser) parseQuery() *ast.Query { + with := p.tryParseWith() + + if p.Token.Kind == "WITH" { + panic(p.errorfAtToken(&p.Token, "expect query expression, but unexpected WITH")) + } + + query := p.parseQueryExpr() + + // If nested query expression is *ast.Query(with suffix), merge parsed WITH into it to avoid deep nest. + if q, ok := query.(*ast.Query); ok { + return &ast.Query{ + With: with, + Query: q.Query, + OrderBy: q.OrderBy, + Limit: q.Limit, + PipeOperators: q.PipeOperators, + } + } + + orderBy := p.tryParseOrderBy() + limit := p.tryParseLimit() + pipeOps := p.parsePipeOperators() + + return &ast.Query{ + With: with, + Query: query, + OrderBy: orderBy, + Limit: limit, + PipeOperators: pipeOps, + } +} + func (p *Parser) tryParseHint() *ast.Hint { if p.Token.Kind != "@" { return nil @@ -318,8 +391,19 @@ func (p *Parser) parseCTE() *ast.CTE { } func (p *Parser) parseQueryExpr() ast.QueryExpr { + // If WITH is appeared, it is treated as an outer node than compound query. + if p.Token.Kind == "WITH" { + return p.parseQuery() + } + query := p.parseSimpleQueryExpr() + // If the query is directly followed by ORDER BY, LIMIT or pipe operators, it won't be a compound query + switch p.Token.Kind { + case "ORDER", "LIMIT", "|>": + return p.parseQueryExprSuffix(query) + } + for { var op ast.SetOp switch p.Token.Kind { @@ -338,37 +422,54 @@ func (p *Parser) parseQueryExpr() ast.QueryExpr { opTok := p.Token p.nextToken() - var distinct bool - switch p.Token.Kind { - case "ALL": - distinct = false - case "DISTINCT": - distinct = true - default: - p.panicfAtToken(&p.Token, "expected token: ALL, DISTINCT, but: %s", p.Token.Kind) - } - p.nextToken() + allOrDistinct := p.parseAllOrDistinct() right := p.parseSimpleQueryExpr() if c, ok := query.(*ast.CompoundQuery); ok { - if !(c.Op == op && c.Distinct == distinct) { + if !(c.Op == op && c.AllOrDistinct == allOrDistinct) { p.panicfAtToken(&opTok, "all set operator at the same level must be the same, or wrap (...)") } c.Queries = append(c.Queries, right) } else { query = &ast.CompoundQuery{ - Op: op, - Distinct: distinct, - Queries: []ast.QueryExpr{query, right}, + Op: op, + AllOrDistinct: allOrDistinct, + Queries: []ast.QueryExpr{query, right}, } } } + // LIMIT, ORDER BY, pipe operators can be placed after a compound query. return p.parseQueryExprSuffix(query) } +func (p *Parser) parseFromQuery() *ast.FromQuery { + if p.Token.Kind != "FROM" { + panic(p.errorfAtToken(&p.Token, "expected 'FROM', got %s", p.Token.AsString)) + } + from := p.tryParseFrom() + + // Although it can be parsed, it is better to reject invalid GoogleSQL queries. + switch p.Token.Kind { + case "ORDER": + panic(p.errorfAtToken(&p.Token, "syntax error: ORDER BY not supported after FROM query; Consider using pipe operator `|> ORDER BY` or parentheses around the FROM query.")) + case "LIMIT": + panic(p.errorfAtToken(&p.Token, "syntax error: LIMIT not supported after FROM query; Consider using pipe operator `|> LIMIT` or parentheses around the FROM query.")) + } + + return &ast.FromQuery{From: from} +} + +// parseSimpleQueryExpr parses simple QueryExpr, which can be wrapped in Query or CompoundQuery. func (p *Parser) parseSimpleQueryExpr() ast.QueryExpr { - if p.Token.Kind == "(" { + switch p.Token.Kind { + // FROM and SELECT are the most primitive query form + case "FROM": + return p.parseFromQuery() + case "SELECT": + return p.parseSelect() + // Query with paren + case "(": lparen := p.expect("(").Pos query := p.parseQueryExpr() rparen := p.expect(")").Pos @@ -377,9 +478,9 @@ func (p *Parser) parseSimpleQueryExpr() ast.QueryExpr { Rparen: rparen, Query: query, } + default: + panic(p.errorfAtToken(&p.Token, `expected beginning of simple query "(", SELECT, FROM, but: %q`, p.Token.AsString)) } - - return p.parseSelect() } func (p *Parser) tryParseSelectAs() ast.SelectAs { @@ -411,11 +512,7 @@ func (p *Parser) tryParseSelectAs() ast.SelectAs { func (p *Parser) parseSelect() *ast.Select { sel := p.expect("SELECT").Pos - var distinct bool - if p.Token.Kind == "DISTINCT" { - p.nextToken() - distinct = true - } + allOrDistinct := p.tryParseAllOrDistinct() selectAs := p.tryParseSelectAs() results := p.parseSelectResults() from := p.tryParseFrom() @@ -424,14 +521,14 @@ func (p *Parser) parseSelect() *ast.Select { having := p.tryParseHaving() return &ast.Select{ - Select: sel, - Distinct: distinct, - As: selectAs, - Results: results, - From: from, - Where: where, - GroupBy: groupBy, - Having: having, + Select: sel, + AllOrDistinct: allOrDistinct, + As: selectAs, + Results: results, + From: from, + Where: where, + GroupBy: groupBy, + Having: having, } } @@ -450,11 +547,74 @@ func (p *Parser) parseSelectResults() []ast.SelectItem { return results } +// lookaheadStarModifierExcept is needed to distinct "* EXCEPT (columns)" and "* EXCEPT {ALL|DISTINCT}". +func (p *Parser) lookaheadStarModifierExcept() bool { + lexer := p.Lexer.Clone() + defer func() { + p.Lexer = lexer + }() + + if p.Token.Kind != "EXCEPT" { + return false + } + p.nextToken() + return p.Token.Kind == "(" +} + +func (p *Parser) tryParseStarModifierExcept() *ast.StarModifierExcept { + if !p.lookaheadStarModifierExcept() { + return nil + } + + pos := p.expect("EXCEPT").Pos + p.expect("(") + columns := parseCommaSeparatedList(p, p.parseIdent) + rparen := p.expect(")").Pos + + return &ast.StarModifierExcept{ + Except: pos, + Rparen: rparen, + Columns: columns, + } +} + +func (p *Parser) parseStarModifierReplaceItem() *ast.StarModifierReplaceItem { + expr := p.parseExpr() + p.expect("AS") + name := p.parseIdent() + + return &ast.StarModifierReplaceItem{ + Expr: expr, + Name: name, + } +} + +func (p *Parser) tryParseStarModifierReplace() *ast.StarModifierReplace { + if !p.Token.IsKeywordLike("REPLACE") { + return nil + } + + pos := p.expectKeywordLike("REPLACE").Pos + p.expect("(") + columns := parseCommaSeparatedList(p, p.parseStarModifierReplaceItem) + rparen := p.expect(")").Pos + + return &ast.StarModifierReplace{ + Replace: pos, + Rparen: rparen, + Columns: columns, + } +} + func (p *Parser) parseSelectItem() ast.SelectItem { if p.Token.Kind == "*" { pos := p.expect("*").Pos + except := p.tryParseStarModifierExcept() + replace := p.tryParseStarModifierReplace() return &ast.Star{ - Star: pos, + Star: pos, + Except: except, + Replace: replace, } } @@ -469,9 +629,13 @@ func (p *Parser) parseSelectItem() ast.SelectItem { if p.Token.Kind == "." { p.nextToken() pos := p.expect("*").Pos + except := p.tryParseStarModifierExcept() + replace := p.tryParseStarModifierReplace() return &ast.DotStar{ - Star: pos, - Expr: expr, + Star: pos, + Expr: expr, + Except: except, + Replace: replace, } } @@ -572,25 +736,50 @@ func (p *Parser) tryParseHaving() *ast.Having { } } +// parseQueryExprSuffix wraps QueryExpr if it is followed by ORDER BY, LIMIT, and/or pipe operators. +// It must not be called to *ast.Query itself because *ast.Query already consumes its suffix. func (p *Parser) parseQueryExprSuffix(e ast.QueryExpr) ast.QueryExpr { + // Query already consumes suffixes and currently it should be a logic bug. + if _, ok := e.(*ast.Query); ok { + panic(p.errorfAtToken(&p.Token, "invalid state of repeated processing of suffix of ast.Query. It is suspected a bug.")) + } + orderBy := p.tryParseOrderBy() limit := p.tryParseLimit() + pipeOps := p.parsePipeOperators() - switch e := e.(type) { - case *ast.Select: - e.OrderBy = orderBy - e.Limit = limit - case *ast.SubQuery: - e.OrderBy = orderBy - e.Limit = limit - case *ast.CompoundQuery: - e.OrderBy = orderBy - e.Limit = limit + if orderBy == nil && limit == nil && len(pipeOps) == 0 { + return e + } + return &ast.Query{ + Query: e, + OrderBy: orderBy, + Limit: limit, + PipeOperators: pipeOps, } +} - return e +func (p *Parser) tryParseAllOrDistinct() ast.AllOrDistinct { + switch p.Token.Kind { + case "ALL": + p.nextToken() + return ast.AllOrDistinctAll + case "DISTINCT": + p.nextToken() + return ast.AllOrDistinctDistinct + default: + // not specified + return "" + } } +func (p *Parser) parseAllOrDistinct() ast.AllOrDistinct { + if p.Token.Kind != "ALL" && p.Token.Kind != "DISTINCT" { + p.panicfAtToken(&p.Token, "expected token: ALL, DISTINCT, but: %s", p.Token.Kind) + } + + return p.tryParseAllOrDistinct() +} func (p *Parser) tryParseOrderBy() *ast.OrderBy { if p.Token.Kind != "ORDER" { return nil @@ -817,6 +1006,9 @@ func (p *Parser) parseSimpleTableExpr() ast.TableExpr { if p.Token.Kind == token.TokenIdent { ids := p.parseIdentOrPath() + if p.Token.Kind == "(" { + return p.parseTVFCallExpr(ids) + } if len(ids) == 1 { return p.parseTableNameSuffix(ids[0]) } @@ -826,6 +1018,63 @@ func (p *Parser) parseSimpleTableExpr() ast.TableExpr { panic(p.errorfAtToken(&p.Token, "expected token: (, UNNEST, , but: %s", p.Token.Kind)) } +func (p *Parser) parseTVFCallExpr(ids []*ast.Ident) *ast.TVFCallExpr { + p.expect("(") + + var args []ast.TVFArg + if p.Token.Kind != ")" { + for !p.lookaheadNamedArg() { + args = append(args, p.parseTVFArg()) + if p.Token.Kind != "," { + break + } + p.nextToken() + } + } + + var namedArgs []*ast.NamedArg + if p.lookaheadNamedArg() { + namedArgs = parseCommaSeparatedList(p, p.parseNamedArg) + } + + rparen := p.expect(")").Pos + hint := p.tryParseHint() + sample := p.tryParseTableSample() + + return &ast.TVFCallExpr{ + Rparen: rparen, + Name: &ast.Path{Idents: ids}, + Args: args, + NamedArgs: namedArgs, + Hint: hint, + Sample: sample, + } +} + +func (p *Parser) parseTVFArg() ast.TVFArg { + pos := p.Token.Pos + switch { + case p.Token.IsKeywordLike("TABLE"): + p.nextToken() + path := p.parsePath() + + return &ast.TableArg{ + Table: pos, + Name: path, + } + case p.Token.IsKeywordLike("MODEL"): + p.nextToken() + path := p.parsePath() + + return &ast.ModelArg{ + Model: pos, + Name: path, + } + default: + return p.parseExprArg() + } +} + func (p *Parser) parseIdentOrPath() []*ast.Ident { ids := []*ast.Ident{p.parseIdent()} for p.Token.Kind == "." { @@ -1451,6 +1700,8 @@ func (p *Parser) parseLit() ast.Expr { return p.parseExistsSubQuery() case "EXTRACT": return p.parseExtractExpr() + case "WITH": + return p.parseWithExpr() case "ARRAY": return p.parseArrayLiteralOrSubQuery() case "STRUCT": @@ -1553,6 +1804,8 @@ func (p *Parser) parseCall(id token.Token) ast.Expr { having := p.tryParseHavingModifier() rparen := p.expect(")").Pos + hint := p.tryParseHint() + return &ast.CallExpr{ Rparen: rparen, Func: fn, @@ -1561,6 +1814,7 @@ func (p *Parser) parseCall(id token.Token) ast.Expr { NamedArgs: namedArgs, NullHandling: nullHandling, Having: having, + Hint: hint, } } @@ -1577,19 +1831,25 @@ func (p *Parser) lookaheadNamedArg() bool { return p.Token.Kind == "=>" } -func (p *Parser) tryParseNamedArg() *ast.NamedArg { - if !p.lookaheadNamedArg() { - return nil - } +func (p *Parser) parseNamedArg() *ast.NamedArg { name := p.parseIdent() p.expect("=>") value := p.parseExpr() + return &ast.NamedArg{ Name: name, Value: value, } } +func (p *Parser) tryParseNamedArg() *ast.NamedArg { + if !p.lookaheadNamedArg() { + return nil + } + + return p.parseNamedArg() +} + func (p *Parser) lookaheadLambdaArg() bool { lexer := p.Lexer.Clone() defer func() { @@ -1915,6 +2175,47 @@ func (p *Parser) tryParseAtTimeZone() *ast.AtTimeZone { } } +func (p *Parser) parseWithExprVar() *ast.WithExprVar { + name := p.parseIdent() + p.expect("AS") + expr := p.parseExpr() + + return &ast.WithExprVar{ + Expr: expr, + Name: name, + } +} + +func (p *Parser) lookaheadWithExprVar() bool { + lexer := p.Lexer.Clone() + defer func() { + p.Lexer = lexer + }() + + p.parseIdent() + return p.Token.Kind == "AS" +} + +func (p *Parser) parseWithExpr() *ast.WithExpr { + with := p.expect("WITH").Pos + p.expect("(") + + var vars []*ast.WithExprVar + for p.lookaheadWithExprVar() { + vars = append(vars, p.parseWithExprVar()) + p.expect(",") + } + + expr := p.parseExpr() + rparen := p.expect(")").Pos + return &ast.WithExpr{ + With: with, + Rparen: rparen, + Vars: vars, + Expr: expr, + } +} + func (p *Parser) parseParenExpr() ast.Expr { paren := p.Token @@ -4101,10 +4402,21 @@ func (p *Parser) parseSchemaType() ast.SchemaType { p.expect("<") t := p.parseScalarSchemaType() end := p.expect(">").Pos + + var namedArgs []*ast.NamedArg + rparen := token.InvalidPos + if p.Token.Kind == "(" { + p.nextToken() + namedArgs = parseCommaSeparatedList(p, p.parseNamedArg) + rparen = p.expect(")").Pos + } + return &ast.ArraySchemaType{ - Array: pos, - Gt: end, - Item: t, + Array: pos, + Gt: end, + Item: t, + NamedArgs: namedArgs, + Rparen: rparen, } } diff --git a/parser_test.go b/parser_test.go index 1f5ef07d..ecc32f9d 100644 --- a/parser_test.go +++ b/parser_test.go @@ -12,16 +12,13 @@ import ( "github.com/cloudspannerecosystem/memefish" "github.com/cloudspannerecosystem/memefish/ast" "github.com/cloudspannerecosystem/memefish/token" - "github.com/k0kubun/pp" + "github.com/k0kubun/pp/v3" "github.com/pmezard/go-difflib/difflib" ) var update = flag.Bool("update", false, "update result files") func testParser(t *testing.T, inputPath, resultPath string, parse func(p *memefish.Parser) (ast.Node, error)) { - printer := pp.New() - printer.SetColoringEnabled(false) - if *update { _, err := os.Stat(resultPath) if err == nil { @@ -63,6 +60,10 @@ func testParser(t *testing.T, inputPath, resultPath string, parse func(p *memefi log.Fatalf("error on parsing input file: %v", err) } + pprinter := pp.New() + pprinter.SetColoringEnabled(false) + pprinter.SetOmitEmpty(true) + var buf bytes.Buffer fmt.Fprintf(&buf, "--- %s\n", in.Name()) @@ -70,7 +71,7 @@ func testParser(t *testing.T, inputPath, resultPath string, parse func(p *memefi fmt.Fprintln(&buf) fmt.Fprintf(&buf, "--- AST\n") - _, _ = printer.Fprintln(&buf, node) + _, _ = pprinter.Fprintln(&buf, node) fmt.Fprintln(&buf) fmt.Fprintf(&buf, "--- SQL\n") diff --git a/testdata/README.md b/testdata/README.md new file mode 100644 index 00000000..0b54181f --- /dev/null +++ b/testdata/README.md @@ -0,0 +1,32 @@ +# About testdata + +If you place `.sql` files containing GoogleSQL in the correct location in this directory, +they will be automatically tested. + +- input + - ddl: input of `ParseDDL()` and `ParseStatement()` + - dml: input of `ParseDML()` and `ParseStatement()` + - expr: input of `ParseExpr()` + - query: input of `ParseQuery()` and `ParseStatemen()` + +You can use this command in your project root to automatically update `testdata/result`. + +``` +$ go test --update +``` + +Note: You should carefully check the diff when committing the contents of `testdata/result`. + +## Tips + +You can use ZetaSQL to check if it's a valid GoogleSQL query. + +* This example requires to preload ZetaSQL docker container. See [Run with Docker](https://github.com/google/zetasql/tree/master?tab=readme-ov-file#run-with-docker). +* Currently, it is useful for query, DML, and expressions because DDL of Spanner GoogleSQL dialect is not compatible to ZetaSQL. + +```sh +# statement +$ docker run --rm --platform linux/amd64 zetasql execute_query --product_mode=external --mode=parse,unparse "$(cat testdata/input/query/pipe_from_where_select_distinct.sql)" +# or expression +$ docker run --rm --platform linux/amd64 zetasql execute_query --product_mode=external --sql_mode=expression --mode=parse,unparse "$(cat testdata/input/expr/array_literal_empty_with_types.sql)" ``` +``` \ No newline at end of file diff --git a/testdata/input/ddl/create_table_types.sql b/testdata/input/ddl/create_table_types.sql index d1d9c6f4..fb0379d0 100644 --- a/testdata/input/ddl/create_table_types.sql +++ b/testdata/input/ddl/create_table_types.sql @@ -12,4 +12,5 @@ create table types ( ab array, abs array, p examples.ProtoType, + af32vl array(vector_length=>128), ) primary key (i) diff --git a/testdata/input/dml/insert_cte_select.sql b/testdata/input/dml/insert_cte_select.sql new file mode 100644 index 00000000..7d3976e4 --- /dev/null +++ b/testdata/input/dml/insert_cte_select.sql @@ -0,0 +1,3 @@ +insert foo (foo, bar) +with cte AS (select 1 as foo, 2 as bar) +select * \ No newline at end of file diff --git a/testdata/input/dml/update_with_safe_ml_predict.sql b/testdata/input/dml/update_with_safe_ml_predict.sql new file mode 100644 index 00000000..67f25010 --- /dev/null +++ b/testdata/input/dml/update_with_safe_ml_predict.sql @@ -0,0 +1,12 @@ +-- https://cloud.google.com/spanner/docs/backfill-embeddings?hl=en#backfill +UPDATE products +SET + products.desc_embed = ( + SELECT embeddings.values + FROM SAFE.ML.PREDICT( + MODEL gecko_model, + (SELECT products.description AS content) + ) @{remote_udf_max_rows_per_rpc=200} + ), + products.desc_embed_model_version = 3 +WHERE products.desc_embed IS NULL \ No newline at end of file diff --git a/testdata/input/query/edge_case_dot_star_except.sql b/testdata/input/query/edge_case_dot_star_except.sql new file mode 100644 index 00000000..f5334b85 --- /dev/null +++ b/testdata/input/query/edge_case_dot_star_except.sql @@ -0,0 +1 @@ +SELECT (SELECT T.* EXCEPT (s)) AS n FROM (SELECT 1 AS n, "foo" AS s) AS T \ No newline at end of file diff --git a/testdata/input/query/edge_case_dot_star_except_all.sql b/testdata/input/query/edge_case_dot_star_except_all.sql new file mode 100644 index 00000000..f26b713d --- /dev/null +++ b/testdata/input/query/edge_case_dot_star_except_all.sql @@ -0,0 +1 @@ +SELECT (SELECT T.* EXCEPT ALL SELECT T.*) AS n FROM (SELECT 1 AS n) AS T \ No newline at end of file diff --git a/testdata/input/query/edge_case_dot_star_except_distinct.sql b/testdata/input/query/edge_case_dot_star_except_distinct.sql new file mode 100644 index 00000000..39ffc17a --- /dev/null +++ b/testdata/input/query/edge_case_dot_star_except_distinct.sql @@ -0,0 +1 @@ +SELECT (SELECT T.* EXCEPT DISTINCT SELECT T.*) AS n FROM (SELECT 1 AS n) AS T \ No newline at end of file diff --git a/testdata/input/query/from_query.sql b/testdata/input/query/from_query.sql new file mode 100644 index 00000000..1daff261 --- /dev/null +++ b/testdata/input/query/from_query.sql @@ -0,0 +1 @@ +FROM Singers \ No newline at end of file diff --git a/testdata/input/query/pipe_cte_from.sql b/testdata/input/query/pipe_cte_from.sql new file mode 100644 index 00000000..0dd33e3a --- /dev/null +++ b/testdata/input/query/pipe_cte_from.sql @@ -0,0 +1,2 @@ +WITH cte AS (SELECT 1) +FROM cte \ No newline at end of file diff --git a/testdata/input/query/pipe_from_select_all.sql b/testdata/input/query/pipe_from_select_all.sql new file mode 100644 index 00000000..79d438b4 --- /dev/null +++ b/testdata/input/query/pipe_from_select_all.sql @@ -0,0 +1,2 @@ +FROM Singers +|> SELECT ALL * \ No newline at end of file diff --git a/testdata/input/query/pipe_from_where_select_distinct.sql b/testdata/input/query/pipe_from_where_select_distinct.sql new file mode 100644 index 00000000..277fbc67 --- /dev/null +++ b/testdata/input/query/pipe_from_where_select_distinct.sql @@ -0,0 +1,3 @@ +FROM Singers +|> WHERE FirstName = "John" +|> SELECT DISTINCT * \ No newline at end of file diff --git a/testdata/input/query/select_dot_star.sql b/testdata/input/query/select_dot_star.sql new file mode 100644 index 00000000..b31bf796 --- /dev/null +++ b/testdata/input/query/select_dot_star.sql @@ -0,0 +1 @@ +SELECT T.* FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) T \ No newline at end of file diff --git a/testdata/input/query/select_dot_star_except.sql b/testdata/input/query/select_dot_star_except.sql new file mode 100644 index 00000000..13c2e43a --- /dev/null +++ b/testdata/input/query/select_dot_star_except.sql @@ -0,0 +1 @@ +SELECT T.* EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T \ No newline at end of file diff --git a/testdata/input/query/select_dot_star_except_replace.sql b/testdata/input/query/select_dot_star_except_replace.sql new file mode 100644 index 00000000..dba6dbe4 --- /dev/null +++ b/testdata/input/query/select_dot_star_except_replace.sql @@ -0,0 +1 @@ +SELECT T.* EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T \ No newline at end of file diff --git a/testdata/input/query/select_dot_star_replace.sql b/testdata/input/query/select_dot_star_replace.sql new file mode 100644 index 00000000..5379b2bf --- /dev/null +++ b/testdata/input/query/select_dot_star_replace.sql @@ -0,0 +1 @@ +SELECT T.* REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T \ No newline at end of file diff --git a/testdata/input/query/select_from_change_stream.sql b/testdata/input/query/select_from_change_stream.sql new file mode 100644 index 00000000..a649601a --- /dev/null +++ b/testdata/input/query/select_from_change_stream.sql @@ -0,0 +1,6 @@ +SELECT ChangeRecord FROM READ_SingersNameStream ( + start_timestamp => "2022-05-01T09:00:00Z", + end_timestamp => NULL, + partition_token => NULL, + heartbeat_milliseconds => 10000 +) \ No newline at end of file diff --git a/testdata/input/query/select_from_ml_predict_hint.sql b/testdata/input/query/select_from_ml_predict_hint.sql new file mode 100644 index 00000000..2d17a97c --- /dev/null +++ b/testdata/input/query/select_from_ml_predict_hint.sql @@ -0,0 +1,7 @@ +-- https://cloud.google.com/spanner/docs/ml-tutorial-generative-ai?hl=en#register_a_generative_ai_model_in_a_schema +SELECT content +FROM ML.PREDICT( + MODEL TextBison, + (SELECT "Is 13 prime?" AS prompt), + STRUCT(256 AS maxOutputTokens, 0.2 AS temperature, 40 as topK, 0.95 AS topP) +) @{remote_udf_max_rows_per_rpc=1} \ No newline at end of file diff --git a/testdata/input/query/select_from_ml_predict_simple.sql b/testdata/input/query/select_from_ml_predict_simple.sql new file mode 100644 index 00000000..8220177e --- /dev/null +++ b/testdata/input/query/select_from_ml_predict_simple.sql @@ -0,0 +1,2 @@ +SELECT id, color, value +FROM ML.PREDICT(MODEL DiamondAppraise, TABLE Diamonds) \ No newline at end of file diff --git a/testdata/input/query/select_from_ml_predict_textbison.sql b/testdata/input/query/select_from_ml_predict_textbison.sql new file mode 100644 index 00000000..6352ba90 --- /dev/null +++ b/testdata/input/query/select_from_ml_predict_textbison.sql @@ -0,0 +1,15 @@ +SELECT product_id, product_name, content +FROM ML.PREDICT( + MODEL TextBison, + (SELECT + product.id as product_id, + product.name as product_name, + CONCAT("Is this product safe for infants?", "\n", + "Product Name: ", product.name, "\n", + "Category Name: ", category.name, "\n", + "Product Description:", product.description) AS prompt + FROM + Products AS product JOIN Categories AS category + ON product.category_id = category.id), + STRUCT(100 AS maxOutputTokens) +) @{remote_udf_max_rows_per_rpc=1} \ No newline at end of file diff --git a/testdata/input/query/select_function_hints.sql b/testdata/input/query/select_function_hints.sql new file mode 100644 index 00000000..6998ca9e --- /dev/null +++ b/testdata/input/query/select_function_hints.sql @@ -0,0 +1,5 @@ +-- https://cloud.google.com/spanner/docs/reference/standard-sql/functions-reference#function_hints +SELECT + SUBSTRING(CAST(x AS STRING), 2, 5) AS w, + SUBSTRING(CAST(x AS STRING), 3, 7) AS y +FROM (SELECT SHA512(z) @{DISABLE_INLINE = TRUE} AS x FROM t) \ No newline at end of file diff --git a/testdata/input/query/select_star.sql b/testdata/input/query/select_star.sql new file mode 100644 index 00000000..a7cc8e70 --- /dev/null +++ b/testdata/input/query/select_star.sql @@ -0,0 +1 @@ +SELECT * FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) \ No newline at end of file diff --git a/testdata/input/query/select_star_except.sql b/testdata/input/query/select_star_except.sql new file mode 100644 index 00000000..789ca201 --- /dev/null +++ b/testdata/input/query/select_star_except.sql @@ -0,0 +1 @@ +SELECT * EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) \ No newline at end of file diff --git a/testdata/input/query/select_star_except_replace.sql b/testdata/input/query/select_star_except_replace.sql new file mode 100644 index 00000000..95cf78a1 --- /dev/null +++ b/testdata/input/query/select_star_except_replace.sql @@ -0,0 +1 @@ +SELECT * EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) \ No newline at end of file diff --git a/testdata/input/query/select_star_replace.sql b/testdata/input/query/select_star_replace.sql new file mode 100644 index 00000000..c5088ed1 --- /dev/null +++ b/testdata/input/query/select_star_replace.sql @@ -0,0 +1 @@ +SELECT * REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) \ No newline at end of file diff --git a/testdata/input/query/select_with.sql b/testdata/input/query/select_with.sql new file mode 100644 index 00000000..8df183ee --- /dev/null +++ b/testdata/input/query/select_with.sql @@ -0,0 +1,5 @@ +-- https://cloud.google.com/spanner/docs/reference/standard-sql/operators#with_expression +SELECT WITH(a AS '123', -- a is '123' + b AS CONCAT(a, '456'), -- b is '123456' + c AS '789', -- c is '789' + CONCAT(b, c)) AS result -- b + c is '123456789' \ No newline at end of file diff --git a/testdata/input/query/with_paren_query_limit.sql b/testdata/input/query/with_paren_query_limit.sql new file mode 100644 index 00000000..ffde33e5 --- /dev/null +++ b/testdata/input/query/with_paren_query_limit.sql @@ -0,0 +1 @@ +WITH cte AS (SELECT 1) (SELECT * FROM cte) LIMIT 1 \ No newline at end of file diff --git a/testdata/result/ddl/alter_change_stream_options.sql.txt b/testdata/result/ddl/alter_change_stream_options.sql.txt index 0069de75..b0214ab8 100644 --- a/testdata/result/ddl/alter_change_stream_options.sql.txt +++ b/testdata/result/ddl/alter_change_stream_options.sql.txt @@ -3,8 +3,7 @@ ALTER CHANGE STREAM change_stream_name SET OPTIONS (retention_period = '1d', val --- AST &ast.AlterChangeStream{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "change_stream_name", diff --git a/testdata/result/ddl/alter_change_stream_set_drop_for_all.sql.txt b/testdata/result/ddl/alter_change_stream_set_drop_for_all.sql.txt index 78744030..07c9db12 100644 --- a/testdata/result/ddl/alter_change_stream_set_drop_for_all.sql.txt +++ b/testdata/result/ddl/alter_change_stream_set_drop_for_all.sql.txt @@ -3,8 +3,7 @@ ALTER CHANGE STREAM change_stream_name DROP FOR ALL --- AST &ast.AlterChangeStream{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "change_stream_name", diff --git a/testdata/result/ddl/alter_change_stream_set_for_all.sql.txt b/testdata/result/ddl/alter_change_stream_set_for_all.sql.txt index 93247c77..a8dfc96e 100644 --- a/testdata/result/ddl/alter_change_stream_set_for_all.sql.txt +++ b/testdata/result/ddl/alter_change_stream_set_for_all.sql.txt @@ -3,8 +3,7 @@ ALTER CHANGE STREAM change_stream_name SET FOR ALL --- AST &ast.AlterChangeStream{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "change_stream_name", diff --git a/testdata/result/ddl/alter_change_stream_set_for_table_columns.sql.txt b/testdata/result/ddl/alter_change_stream_set_for_table_columns.sql.txt index ed5c412b..4b2104c9 100644 --- a/testdata/result/ddl/alter_change_stream_set_for_table_columns.sql.txt +++ b/testdata/result/ddl/alter_change_stream_set_for_table_columns.sql.txt @@ -3,8 +3,7 @@ ALTER CHANGE STREAM change_stream_name SET FOR table_name1(column1, column2), ta --- AST &ast.AlterChangeStream{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "change_stream_name", diff --git a/testdata/result/ddl/alter_database.sql.txt b/testdata/result/ddl/alter_database.sql.txt index 3fc122ab..7aee12b2 100644 --- a/testdata/result/ddl/alter_database.sql.txt +++ b/testdata/result/ddl/alter_database.sql.txt @@ -8,8 +8,7 @@ ALTER DATABASE dbname SET OPTIONS ( ) --- AST &ast.AlterDatabase{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 15, NameEnd: 21, Name: "dbname", diff --git a/testdata/result/ddl/alter_index_add_stored_column.sql.txt b/testdata/result/ddl/alter_index_add_stored_column.sql.txt index ae278e40..831651a3 100644 --- a/testdata/result/ddl/alter_index_add_stored_column.sql.txt +++ b/testdata/result/ddl/alter_index_add_stored_column.sql.txt @@ -3,8 +3,7 @@ alter index foo add stored column bar --- AST &ast.AlterIndex{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_index_drop_stored_column.sql.txt b/testdata/result/ddl/alter_index_drop_stored_column.sql.txt index 1a54ff45..d22dc9c7 100644 --- a/testdata/result/ddl/alter_index_drop_stored_column.sql.txt +++ b/testdata/result/ddl/alter_index_drop_stored_column.sql.txt @@ -3,8 +3,7 @@ alter index foo drop stored column bar --- AST &ast.AlterIndex{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_model.sql.txt b/testdata/result/ddl/alter_model.sql.txt index cb6cf129..9cb212f6 100644 --- a/testdata/result/ddl/alter_model.sql.txt +++ b/testdata/result/ddl/alter_model.sql.txt @@ -9,9 +9,7 @@ SET OPTIONS ( ) --- AST &ast.AlterModel{ - Alter: 0, - IfExists: false, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 12, NameEnd: 33, Name: "MyClassificationModel", @@ -30,7 +28,6 @@ SET OPTIONS ( Array: -1, Lbrack: 64, Rbrack: 227, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 74, diff --git a/testdata/result/ddl/alter_model_if_exists.sql.txt b/testdata/result/ddl/alter_model_if_exists.sql.txt index a585c656..f6884fd5 100644 --- a/testdata/result/ddl/alter_model_if_exists.sql.txt +++ b/testdata/result/ddl/alter_model_if_exists.sql.txt @@ -9,7 +9,6 @@ SET OPTIONS ( ) --- AST &ast.AlterModel{ - Alter: 0, IfExists: true, Name: &ast.Ident{ NamePos: 22, @@ -30,7 +29,6 @@ SET OPTIONS ( Array: -1, Lbrack: 74, Rbrack: 237, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 84, diff --git a/testdata/result/ddl/alter_proto_bundle_all.sql.txt b/testdata/result/ddl/alter_proto_bundle_all.sql.txt index feb37248..6d94cede 100644 --- a/testdata/result/ddl/alter_proto_bundle_all.sql.txt +++ b/testdata/result/ddl/alter_proto_bundle_all.sql.txt @@ -2,7 +2,6 @@ ALTER PROTO BUNDLE INSERT (package.Inserted) UPDATE (package.Updated) DELETE (package.Deleted) --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, Insert: &ast.AlterProtoBundleInsert{ Insert: 19, diff --git a/testdata/result/ddl/alter_proto_bundle_delete.sql.txt b/testdata/result/ddl/alter_proto_bundle_delete.sql.txt index ca333576..663b0159 100644 --- a/testdata/result/ddl/alter_proto_bundle_delete.sql.txt +++ b/testdata/result/ddl/alter_proto_bundle_delete.sql.txt @@ -2,10 +2,7 @@ ALTER PROTO BUNDLE DELETE(`examples.shipping.OrderHistory`) --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, - Insert: (*ast.AlterProtoBundleInsert)(nil), - Update: (*ast.AlterProtoBundleUpdate)(nil), Delete: &ast.AlterProtoBundleDelete{ Delete: 19, Types: &ast.ProtoBundleTypes{ diff --git a/testdata/result/ddl/alter_proto_bundle_insert.sql.txt b/testdata/result/ddl/alter_proto_bundle_insert.sql.txt index 3b82c6c1..470928dc 100644 --- a/testdata/result/ddl/alter_proto_bundle_insert.sql.txt +++ b/testdata/result/ddl/alter_proto_bundle_insert.sql.txt @@ -4,7 +4,6 @@ ALTER PROTO BUNDLE INSERT ( ) --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, Insert: &ast.AlterProtoBundleInsert{ Insert: 19, @@ -34,8 +33,6 @@ ALTER PROTO BUNDLE INSERT ( }, }, }, - Update: (*ast.AlterProtoBundleUpdate)(nil), - Delete: (*ast.AlterProtoBundleDelete)(nil), } --- SQL diff --git a/testdata/result/ddl/alter_proto_bundle_noop.sql.txt b/testdata/result/ddl/alter_proto_bundle_noop.sql.txt index aa40ccc7..e33290f1 100644 --- a/testdata/result/ddl/alter_proto_bundle_noop.sql.txt +++ b/testdata/result/ddl/alter_proto_bundle_noop.sql.txt @@ -2,11 +2,7 @@ ALTER PROTO BUNDLE --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, - Insert: (*ast.AlterProtoBundleInsert)(nil), - Update: (*ast.AlterProtoBundleUpdate)(nil), - Delete: (*ast.AlterProtoBundleDelete)(nil), } --- SQL diff --git a/testdata/result/ddl/alter_proto_bundle_update.sql.txt b/testdata/result/ddl/alter_proto_bundle_update.sql.txt index 19f249b1..45376eb4 100644 --- a/testdata/result/ddl/alter_proto_bundle_update.sql.txt +++ b/testdata/result/ddl/alter_proto_bundle_update.sql.txt @@ -2,9 +2,7 @@ ALTER PROTO BUNDLE UPDATE(`examples.shipping.Order`) --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, - Insert: (*ast.AlterProtoBundleInsert)(nil), Update: &ast.AlterProtoBundleUpdate{ Update: 19, Types: &ast.ProtoBundleTypes{ @@ -23,7 +21,6 @@ ALTER PROTO BUNDLE UPDATE(`examples.shipping.Order`) }, }, }, - Delete: (*ast.AlterProtoBundleDelete)(nil), } --- SQL diff --git a/testdata/result/ddl/alter_search_index_add_stored_column.sql.txt b/testdata/result/ddl/alter_search_index_add_stored_column.sql.txt index e27c4f83..f0b3a65b 100644 --- a/testdata/result/ddl/alter_search_index_add_stored_column.sql.txt +++ b/testdata/result/ddl/alter_search_index_add_stored_column.sql.txt @@ -2,8 +2,7 @@ ALTER SEARCH INDEX AlbumsIndex ADD STORED COLUMN Genre --- AST &ast.AlterSearchIndex{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 19, NameEnd: 30, Name: "AlbumsIndex", diff --git a/testdata/result/ddl/alter_search_index_drop_stored_column.sql.txt b/testdata/result/ddl/alter_search_index_drop_stored_column.sql.txt index 1a3f12bf..b7ac0f3d 100644 --- a/testdata/result/ddl/alter_search_index_drop_stored_column.sql.txt +++ b/testdata/result/ddl/alter_search_index_drop_stored_column.sql.txt @@ -2,8 +2,7 @@ ALTER SEARCH INDEX AlbumsIndex DROP STORED COLUMN Genre --- AST &ast.AlterSearchIndex{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 19, NameEnd: 30, Name: "AlbumsIndex", diff --git a/testdata/result/ddl/alter_sequence_no_skip_range.sql.txt b/testdata/result/ddl/alter_sequence_no_skip_range.sql.txt index affc7ce0..a37cc758 100644 --- a/testdata/result/ddl/alter_sequence_no_skip_range.sql.txt +++ b/testdata/result/ddl/alter_sequence_no_skip_range.sql.txt @@ -3,8 +3,7 @@ ALTER SEQUENCE my_sequence NO SKIP RANGE --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -13,10 +12,7 @@ ALTER SEQUENCE my_sequence NO SKIP RANGE }, }, }, - Options: (*ast.Options)(nil), - RestartCounterWith: (*ast.RestartCounterWith)(nil), - SkipRange: (*ast.SkipRange)(nil), - NoSkipRange: &ast.NoSkipRange{ + NoSkipRange: &ast.NoSkipRange{ No: 27, Range: 35, }, diff --git a/testdata/result/ddl/alter_sequence_restart_counter_with.sql.txt b/testdata/result/ddl/alter_sequence_restart_counter_with.sql.txt index f16f75e3..013ce56a 100644 --- a/testdata/result/ddl/alter_sequence_restart_counter_with.sql.txt +++ b/testdata/result/ddl/alter_sequence_restart_counter_with.sql.txt @@ -2,8 +2,7 @@ ALTER SEQUENCE my_sequence RESTART COUNTER WITH 1000 --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -12,7 +11,6 @@ ALTER SEQUENCE my_sequence RESTART COUNTER WITH 1000 }, }, }, - Options: (*ast.Options)(nil), RestartCounterWith: &ast.RestartCounterWith{ Restart: 27, Counter: &ast.IntLiteral{ @@ -22,8 +20,6 @@ ALTER SEQUENCE my_sequence RESTART COUNTER WITH 1000 Value: "1000", }, }, - SkipRange: (*ast.SkipRange)(nil), - NoSkipRange: (*ast.NoSkipRange)(nil), } --- SQL diff --git a/testdata/result/ddl/alter_sequence_set_options.sql.txt b/testdata/result/ddl/alter_sequence_set_options.sql.txt index b8c2dcd4..cf788a6d 100644 --- a/testdata/result/ddl/alter_sequence_set_options.sql.txt +++ b/testdata/result/ddl/alter_sequence_set_options.sql.txt @@ -3,8 +3,7 @@ ALTER SEQUENCE my_sequence SET OPTIONS (skip_range_min=1, skip_range_max=1234567 --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -45,9 +44,6 @@ ALTER SEQUENCE my_sequence SET OPTIONS (skip_range_min=1, skip_range_max=1234567 }, }, }, - RestartCounterWith: (*ast.RestartCounterWith)(nil), - SkipRange: (*ast.SkipRange)(nil), - NoSkipRange: (*ast.NoSkipRange)(nil), } --- SQL diff --git a/testdata/result/ddl/alter_sequence_skip_range.sql.txt b/testdata/result/ddl/alter_sequence_skip_range.sql.txt index fcd1d3a8..8e4b6324 100644 --- a/testdata/result/ddl/alter_sequence_skip_range.sql.txt +++ b/testdata/result/ddl/alter_sequence_skip_range.sql.txt @@ -3,8 +3,7 @@ ALTER SEQUENCE my_sequence SKIP RANGE 1, 1234567 --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -13,9 +12,7 @@ ALTER SEQUENCE my_sequence SKIP RANGE 1, 1234567 }, }, }, - Options: (*ast.Options)(nil), - RestartCounterWith: (*ast.RestartCounterWith)(nil), - SkipRange: &ast.SkipRange{ + SkipRange: &ast.SkipRange{ Skip: 27, Min: &ast.IntLiteral{ ValuePos: 38, @@ -30,7 +27,6 @@ ALTER SEQUENCE my_sequence SKIP RANGE 1, 1234567 Value: "1234567", }, }, - NoSkipRange: (*ast.NoSkipRange)(nil), } --- SQL diff --git a/testdata/result/ddl/alter_statistics.sql.txt b/testdata/result/ddl/alter_statistics.sql.txt index 5e513edd..d5b5b3bb 100644 --- a/testdata/result/ddl/alter_statistics.sql.txt +++ b/testdata/result/ddl/alter_statistics.sql.txt @@ -2,8 +2,7 @@ ALTER STATISTICS auto_20191128_14_47_22UTC SET OPTIONS (allow_gc=false) --- AST &ast.AlterStatistics{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 17, NameEnd: 42, Name: "auto_20191128_14_47_22UTC", @@ -20,7 +19,6 @@ ALTER STATISTICS auto_20191128_14_47_22UTC SET OPTIONS (allow_gc=false) }, Value: &ast.BoolLiteral{ ValuePos: 65, - Value: false, }, }, }, diff --git a/testdata/result/ddl/alter_table_add_check.sql.txt b/testdata/result/ddl/alter_table_add_check.sql.txt index 12790e88..16e305bb 100644 --- a/testdata/result/ddl/alter_table_add_check.sql.txt +++ b/testdata/result/ddl/alter_table_add_check.sql.txt @@ -3,8 +3,7 @@ alter table foo add check (c1 > 0) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -16,9 +15,7 @@ alter table foo add check (c1 > 0) TableAlteration: &ast.AddTableConstraint{ Add: 16, TableConstraint: &ast.TableConstraint{ - ConstraintPos: 0, - Name: (*ast.Ident)(nil), - Constraint: &ast.Check{ + Constraint: &ast.Check{ Check: 20, Rparen: 33, Expr: &ast.BinaryExpr{ diff --git a/testdata/result/ddl/alter_table_add_column.sql.txt b/testdata/result/ddl/alter_table_add_column.sql.txt index 4ed7b407..a2e5b008 100644 --- a/testdata/result/ddl/alter_table_add_column.sql.txt +++ b/testdata/result/ddl/alter_table_add_column.sql.txt @@ -2,8 +2,7 @@ alter table foo add column baz string(max) not null --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -13,9 +12,8 @@ alter table foo add column baz string(max) not null }, }, TableAlteration: &ast.AddColumn{ - Add: 16, - IfNotExists: false, - Column: &ast.ColumnDef{ + Add: 16, + Column: &ast.ColumnDef{ Null: 47, Name: &ast.Ident{ NamePos: 27, @@ -27,14 +25,9 @@ alter table foo add column baz string(max) not null Rparen: 41, Name: "STRING", Max: true, - Size: nil, }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, }, } diff --git a/testdata/result/ddl/alter_table_add_column_if_not_exists.sql.txt b/testdata/result/ddl/alter_table_add_column_if_not_exists.sql.txt index 3b707a0c..635672e2 100644 --- a/testdata/result/ddl/alter_table_add_column_if_not_exists.sql.txt +++ b/testdata/result/ddl/alter_table_add_column_if_not_exists.sql.txt @@ -3,8 +3,7 @@ alter table foo add column if not exists baz string(max) not null --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -28,14 +27,9 @@ alter table foo add column if not exists baz string(max) not null Rparen: 55, Name: "STRING", Max: true, - Size: nil, }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, }, } diff --git a/testdata/result/ddl/alter_table_add_column_with_if_expression.sql.txt b/testdata/result/ddl/alter_table_add_column_with_if_expression.sql.txt index 7698c23c..181f03d3 100644 --- a/testdata/result/ddl/alter_table_add_column_with_if_expression.sql.txt +++ b/testdata/result/ddl/alter_table_add_column_with_if_expression.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND status != "SCHEDULING", TIMESTAMP_ADD(updated_at, INTERVAL 120 DAY), NULL)) STORED --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -13,9 +12,8 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND sta }, }, TableAlteration: &ast.AddColumn{ - Add: 16, - IfNotExists: false, - Column: &ast.ColumnDef{ + Add: 16, + Column: &ast.ColumnDef{ Null: -1, Name: &ast.Ident{ NamePos: 27, @@ -26,8 +24,6 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND sta NamePos: 38, Name: "TIMESTAMP", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), GeneratedExpr: &ast.GeneratedColumnExpr{ As: 48, Stored: 153, @@ -71,8 +67,7 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND sta NameEnd: 114, Name: "TIMESTAMP_ADD", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 115, @@ -95,18 +90,13 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND sta }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, ElseResult: &ast.NullLiteral{ Null: 146, }, }, }, - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, } diff --git a/testdata/result/ddl/alter_table_add_constraint_check.sql.txt b/testdata/result/ddl/alter_table_add_constraint_check.sql.txt index c7b6bd73..03292861 100644 --- a/testdata/result/ddl/alter_table_add_constraint_check.sql.txt +++ b/testdata/result/ddl/alter_table_add_constraint_check.sql.txt @@ -3,8 +3,7 @@ alter table foo add constraint cname check (c1 > 0) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_add_constraint_foreign_key.sql.txt b/testdata/result/ddl/alter_table_add_constraint_foreign_key.sql.txt index 14f2f1db..b0c986d8 100644 --- a/testdata/result/ddl/alter_table_add_constraint_foreign_key.sql.txt +++ b/testdata/result/ddl/alter_table_add_constraint_foreign_key.sql.txt @@ -3,8 +3,7 @@ alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2ke --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -59,7 +58,6 @@ alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2ke Name: "t2key2", }, }, - OnDelete: "", }, }, }, diff --git a/testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt b/testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt index 5763ea75..7e7ab779 100644 --- a/testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt +++ b/testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt @@ -3,8 +3,7 @@ alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2ke --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt b/testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt index 80052ce0..080c4819 100644 --- a/testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt +++ b/testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt @@ -3,8 +3,7 @@ alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2ke --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_add_foreign_key.sql.txt b/testdata/result/ddl/alter_table_add_foreign_key.sql.txt index 040d5f20..510a9c43 100644 --- a/testdata/result/ddl/alter_table_add_foreign_key.sql.txt +++ b/testdata/result/ddl/alter_table_add_foreign_key.sql.txt @@ -3,8 +3,7 @@ alter table foo add foreign key (bar) references t2 (t2key1) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -16,9 +15,7 @@ alter table foo add foreign key (bar) references t2 (t2key1) TableAlteration: &ast.AddTableConstraint{ Add: 16, TableConstraint: &ast.TableConstraint{ - ConstraintPos: 0, - Name: (*ast.Ident)(nil), - Constraint: &ast.ForeignKey{ + Constraint: &ast.ForeignKey{ Foreign: 20, Rparen: 59, OnDeleteEnd: -1, @@ -45,7 +42,6 @@ alter table foo add foreign key (bar) references t2 (t2key1) Name: "t2key1", }, }, - OnDelete: "", }, }, }, diff --git a/testdata/result/ddl/alter_table_add_row_deletion_policy.sql.txt b/testdata/result/ddl/alter_table_add_row_deletion_policy.sql.txt index 4838ae3c..091ec583 100644 --- a/testdata/result/ddl/alter_table_add_row_deletion_policy.sql.txt +++ b/testdata/result/ddl/alter_table_add_row_deletion_policy.sql.txt @@ -3,8 +3,7 @@ alter table foo add row deletion policy ( older_than ( bar, interval 30 day )) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_add_synonym.sql.txt b/testdata/result/ddl/alter_table_add_synonym.sql.txt index 0f384a60..cc54b865 100644 --- a/testdata/result/ddl/alter_table_add_synonym.sql.txt +++ b/testdata/result/ddl/alter_table_add_synonym.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE Singers ADD SYNONYM SingersTest --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_alter_column.sql.txt b/testdata/result/ddl/alter_table_alter_column.sql.txt index 13e95b83..254ad98c 100644 --- a/testdata/result/ddl/alter_table_alter_column.sql.txt +++ b/testdata/result/ddl/alter_table_alter_column.sql.txt @@ -2,8 +2,7 @@ alter table foo alter column foo string(256) not null --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -24,7 +23,6 @@ alter table foo alter column foo string(256) not null NamePos: 33, Rparen: 43, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 40, ValueEnd: 43, @@ -32,9 +30,8 @@ alter table foo alter column foo string(256) not null Value: "256", }, }, - Null: 49, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), + Null: 49, + NotNull: true, }, }, } diff --git a/testdata/result/ddl/alter_table_alter_column_alter_identity_restart_counter_with.sql.txt b/testdata/result/ddl/alter_table_alter_column_alter_identity_restart_counter_with.sql.txt index 8240d64e..535a260e 100644 --- a/testdata/result/ddl/alter_table_alter_column_alter_identity_restart_counter_with.sql.txt +++ b/testdata/result/ddl/alter_table_alter_column_alter_identity_restart_counter_with.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN id ALTER IDENTITY RESTART COUNTER WITH 1000 --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_alter_column_alter_identity_set_no_skip_range.sql.txt b/testdata/result/ddl/alter_table_alter_column_alter_identity_set_no_skip_range.sql.txt index 29e2961c..0d133c9e 100644 --- a/testdata/result/ddl/alter_table_alter_column_alter_identity_set_no_skip_range.sql.txt +++ b/testdata/result/ddl/alter_table_alter_column_alter_identity_set_no_skip_range.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN id ALTER IDENTITY SET NO SKIP RANGE --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_alter_column_alter_identity_set_skip_range.sql.txt b/testdata/result/ddl/alter_table_alter_column_alter_identity_set_skip_range.sql.txt index a58303b0..59da1659 100644 --- a/testdata/result/ddl/alter_table_alter_column_alter_identity_set_skip_range.sql.txt +++ b/testdata/result/ddl/alter_table_alter_column_alter_identity_set_skip_range.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN id ALTER IDENTITY SET SKIP RANGE 1, 1234567 --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_alter_column_drop_default.sql.txt b/testdata/result/ddl/alter_table_alter_column_drop_default.sql.txt index 21b4175f..8b5e7026 100644 --- a/testdata/result/ddl/alter_table_alter_column_drop_default.sql.txt +++ b/testdata/result/ddl/alter_table_alter_column_drop_default.sql.txt @@ -2,8 +2,7 @@ alter table foo alter column foo drop default --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_alter_column_set.sql.txt b/testdata/result/ddl/alter_table_alter_column_set.sql.txt index 79eebcf1..5ead03f4 100644 --- a/testdata/result/ddl/alter_table_alter_column_set.sql.txt +++ b/testdata/result/ddl/alter_table_alter_column_set.sql.txt @@ -2,8 +2,7 @@ alter table foo alter column foo set options(allow_commit_timestamp = true) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_alter_column_set_default.sql.txt b/testdata/result/ddl/alter_table_alter_column_set_default.sql.txt index 61bfd3cc..5b75eba2 100644 --- a/testdata/result/ddl/alter_table_alter_column_set_default.sql.txt +++ b/testdata/result/ddl/alter_table_alter_column_set_default.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN output SET DEFAULT("") --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -27,7 +26,6 @@ ALTER TABLE actions ALTER COLUMN output SET DEFAULT("") Expr: &ast.StringLiteral{ ValuePos: 52, ValueEnd: 54, - Value: "", }, }, }, diff --git a/testdata/result/ddl/alter_table_alter_column_with_default.sql.txt b/testdata/result/ddl/alter_table_alter_column_with_default.sql.txt index 1df22088..94a7fc3a 100644 --- a/testdata/result/ddl/alter_table_alter_column_with_default.sql.txt +++ b/testdata/result/ddl/alter_table_alter_column_with_default.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN output STRING(MAX) NOT NULL DEFAULT("") --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -25,7 +24,6 @@ ALTER TABLE actions ALTER COLUMN output STRING(MAX) NOT NULL DEFAULT("") Rparen: 50, Name: "STRING", Max: true, - Size: nil, }, Null: 56, NotNull: true, @@ -35,7 +33,6 @@ ALTER TABLE actions ALTER COLUMN output STRING(MAX) NOT NULL DEFAULT("") Expr: &ast.StringLiteral{ ValuePos: 69, ValueEnd: 71, - Value: "", }, }, }, diff --git a/testdata/result/ddl/alter_table_drop_column.sql.txt b/testdata/result/ddl/alter_table_drop_column.sql.txt index 0a21940d..f279716f 100644 --- a/testdata/result/ddl/alter_table_drop_column.sql.txt +++ b/testdata/result/ddl/alter_table_drop_column.sql.txt @@ -3,8 +3,7 @@ alter table foo drop column bar --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_drop_constraint.sql.txt b/testdata/result/ddl/alter_table_drop_constraint.sql.txt index cd868b07..72380fbe 100644 --- a/testdata/result/ddl/alter_table_drop_constraint.sql.txt +++ b/testdata/result/ddl/alter_table_drop_constraint.sql.txt @@ -3,8 +3,7 @@ alter table foo drop constraint bar --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_drop_row_deletion_policy.sql.txt b/testdata/result/ddl/alter_table_drop_row_deletion_policy.sql.txt index 79604aa1..ea5aecd9 100644 --- a/testdata/result/ddl/alter_table_drop_row_deletion_policy.sql.txt +++ b/testdata/result/ddl/alter_table_drop_row_deletion_policy.sql.txt @@ -3,8 +3,7 @@ alter table foo drop row deletion policy --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_drop_synonym.sql.txt b/testdata/result/ddl/alter_table_drop_synonym.sql.txt index f5233212..bdd9f37e 100644 --- a/testdata/result/ddl/alter_table_drop_synonym.sql.txt +++ b/testdata/result/ddl/alter_table_drop_synonym.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE Singers DROP SYNONYM SingersTest --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_rename_to.sql.txt b/testdata/result/ddl/alter_table_rename_to.sql.txt index 1e7c36a3..d195bd73 100644 --- a/testdata/result/ddl/alter_table_rename_to.sql.txt +++ b/testdata/result/ddl/alter_table_rename_to.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE Singers RENAME TO SingersNew --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -19,7 +18,6 @@ ALTER TABLE Singers RENAME TO SingersNew NameEnd: 40, Name: "SingersNew", }, - AddSynonym: (*ast.AddSynonym)(nil), }, } diff --git a/testdata/result/ddl/alter_table_rename_to_add_synonym.sql.txt b/testdata/result/ddl/alter_table_rename_to_add_synonym.sql.txt index 868eeb4e..bc921657 100644 --- a/testdata/result/ddl/alter_table_rename_to_add_synonym.sql.txt +++ b/testdata/result/ddl/alter_table_rename_to_add_synonym.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE Singers RENAME TO SingersNew, ADD SYNONYM Singers --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_replace_row_deletion_policy.sql.txt b/testdata/result/ddl/alter_table_replace_row_deletion_policy.sql.txt index 3fe645be..36397cad 100644 --- a/testdata/result/ddl/alter_table_replace_row_deletion_policy.sql.txt +++ b/testdata/result/ddl/alter_table_replace_row_deletion_policy.sql.txt @@ -3,8 +3,7 @@ alter table foo replace row deletion policy ( older_than ( bar, interval 30 day --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_set_on_delete.sql.txt b/testdata/result/ddl/alter_table_set_on_delete.sql.txt index 366965fd..c87c0894 100644 --- a/testdata/result/ddl/alter_table_set_on_delete.sql.txt +++ b/testdata/result/ddl/alter_table_set_on_delete.sql.txt @@ -2,8 +2,7 @@ alter table foo set on delete cascade --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/alter_table_set_on_delete_no_action.sql.txt b/testdata/result/ddl/alter_table_set_on_delete_no_action.sql.txt index 33386763..45ba919c 100644 --- a/testdata/result/ddl/alter_table_set_on_delete_no_action.sql.txt +++ b/testdata/result/ddl/alter_table_set_on_delete_no_action.sql.txt @@ -2,8 +2,7 @@ alter table foo set on delete no action --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/analyze.sql.txt b/testdata/result/ddl/analyze.sql.txt index 44a712f1..0dcf9198 100644 --- a/testdata/result/ddl/analyze.sql.txt +++ b/testdata/result/ddl/analyze.sql.txt @@ -1,9 +1,7 @@ --- analyze.sql ANALYZE --- AST -&ast.Analyze{ - Analyze: 0, -} +&ast.Analyze{} --- SQL ANALYZE diff --git a/testdata/result/ddl/create_change_stream.sql.txt b/testdata/result/ddl/create_change_stream.sql.txt index 323175f1..195b135d 100644 --- a/testdata/result/ddl/create_change_stream.sql.txt +++ b/testdata/result/ddl/create_change_stream.sql.txt @@ -3,14 +3,11 @@ CREATE CHANGE STREAM change_stream_name --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", }, - For: nil, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/ddl/create_change_stream_for_all.sql.txt b/testdata/result/ddl/create_change_stream_for_all.sql.txt index ae3ae9de..454e5db2 100644 --- a/testdata/result/ddl/create_change_stream_for_all.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_all.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR ALL --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -13,7 +12,6 @@ CREATE CHANGE STREAM change_stream_name FOR ALL For: 40, All: 48, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/ddl/create_change_stream_for_multiple_table_columns.sql.txt b/testdata/result/ddl/create_change_stream_for_multiple_table_columns.sql.txt index 7f223ba7..6bfce3fb 100644 --- a/testdata/result/ddl/create_change_stream_for_multiple_table_columns.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_multiple_table_columns.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name1(column1, column2), table --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -54,7 +53,6 @@ CREATE CHANGE STREAM change_stream_name FOR table_name1(column1, column2), table }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/ddl/create_change_stream_for_table.sql.txt b/testdata/result/ddl/create_change_stream_for_table.sql.txt index e208fda4..ebde8b19 100644 --- a/testdata/result/ddl/create_change_stream_for_table.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_table.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -13,17 +12,14 @@ CREATE CHANGE STREAM change_stream_name FOR table_name For: 40, Tables: []*ast.ChangeStreamForTable{ &ast.ChangeStreamForTable{ - Rparen: 0, TableName: &ast.Ident{ NamePos: 44, NameEnd: 54, Name: "table_name", }, - Columns: []*ast.Ident(nil), }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/ddl/create_change_stream_for_table_column.sql.txt b/testdata/result/ddl/create_change_stream_for_table_column.sql.txt index 8829eac0..3be46ca1 100644 --- a/testdata/result/ddl/create_change_stream_for_table_column.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_table_column.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name(column) --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -29,7 +28,6 @@ CREATE CHANGE STREAM change_stream_name FOR table_name(column) }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/ddl/create_change_stream_for_table_columns.sql.txt b/testdata/result/ddl/create_change_stream_for_table_columns.sql.txt index 320c4dd3..872ff41f 100644 --- a/testdata/result/ddl/create_change_stream_for_table_columns.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_table_columns.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name(column1, column2) --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -34,7 +33,6 @@ CREATE CHANGE STREAM change_stream_name FOR table_name(column1, column2) }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/ddl/create_change_stream_for_tables.sql.txt b/testdata/result/ddl/create_change_stream_for_tables.sql.txt index d152e46e..3cfd2415 100644 --- a/testdata/result/ddl/create_change_stream_for_tables.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_tables.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name1, table_name2 --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -13,26 +12,21 @@ CREATE CHANGE STREAM change_stream_name FOR table_name1, table_name2 For: 40, Tables: []*ast.ChangeStreamForTable{ &ast.ChangeStreamForTable{ - Rparen: 0, TableName: &ast.Ident{ NamePos: 44, NameEnd: 55, Name: "table_name1", }, - Columns: []*ast.Ident(nil), }, &ast.ChangeStreamForTable{ - Rparen: 0, TableName: &ast.Ident{ NamePos: 57, NameEnd: 68, Name: "table_name2", }, - Columns: []*ast.Ident(nil), }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/ddl/create_change_stream_for_tables_with_option.sql.txt b/testdata/result/ddl/create_change_stream_for_tables_with_option.sql.txt index 7f1778ce..9077f8c5 100644 --- a/testdata/result/ddl/create_change_stream_for_tables_with_option.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_tables_with_option.sql.txt @@ -4,8 +4,7 @@ OPTIONS(retention_period = '1d') --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", diff --git a/testdata/result/ddl/create_change_stream_for_tables_with_option_null.sql.txt b/testdata/result/ddl/create_change_stream_for_tables_with_option_null.sql.txt index 1ff7f957..5f569192 100644 --- a/testdata/result/ddl/create_change_stream_for_tables_with_option_null.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_tables_with_option_null.sql.txt @@ -4,8 +4,7 @@ OPTIONS(retention_period = null) --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", diff --git a/testdata/result/ddl/create_change_stream_for_tables_with_options.sql.txt b/testdata/result/ddl/create_change_stream_for_tables_with_options.sql.txt index ecb43509..8dbce278 100644 --- a/testdata/result/ddl/create_change_stream_for_tables_with_options.sql.txt +++ b/testdata/result/ddl/create_change_stream_for_tables_with_options.sql.txt @@ -4,8 +4,7 @@ OPTIONS(retention_period = '1d', value_capture_type = 'NEW_ROW') --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", diff --git a/testdata/result/ddl/create_database.sql.txt b/testdata/result/ddl/create_database.sql.txt index 85282278..54a7523e 100644 --- a/testdata/result/ddl/create_database.sql.txt +++ b/testdata/result/ddl/create_database.sql.txt @@ -3,8 +3,7 @@ create database foo_bar_baz --- AST &ast.CreateDatabase{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 16, NameEnd: 27, Name: "foo_bar_baz", diff --git a/testdata/result/ddl/create_index.sql.txt b/testdata/result/ddl/create_index.sql.txt index 568a898e..f29910dd 100644 --- a/testdata/result/ddl/create_index.sql.txt +++ b/testdata/result/ddl/create_index.sql.txt @@ -6,12 +6,8 @@ create index foo_bar on foo ( --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 53, - Unique: false, - NullFiltered: false, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 53, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -49,9 +45,7 @@ create index foo_bar on foo ( Dir: "ASC", }, }, - Storing: (*ast.Storing)(nil), - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE INDEX foo_bar ON foo (bar DESC, baz ASC) +CREATE INDEX foo_bar ON foo(bar DESC, baz ASC) diff --git a/testdata/result/ddl/create_index_if_not_exists.sql.txt b/testdata/result/ddl/create_index_if_not_exists.sql.txt index 760d3db7..824fd9e4 100644 --- a/testdata/result/ddl/create_index_if_not_exists.sql.txt +++ b/testdata/result/ddl/create_index_if_not_exists.sql.txt @@ -3,12 +3,9 @@ create index if not exists foo_bar on foo (bar) --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 46, - Unique: false, - NullFiltered: false, - IfNotExists: true, - Name: &ast.Path{ + Rparen: 46, + IfNotExists: true, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 27, @@ -34,12 +31,9 @@ create index if not exists foo_bar on foo (bar) NameEnd: 46, Name: "bar", }, - Dir: "", }, }, - Storing: (*ast.Storing)(nil), - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE INDEX IF NOT EXISTS foo_bar ON foo (bar) +CREATE INDEX IF NOT EXISTS foo_bar ON foo(bar) diff --git a/testdata/result/ddl/create_index_interleave.sql.txt b/testdata/result/ddl/create_index_interleave.sql.txt index c4efd04e..5dffda20 100644 --- a/testdata/result/ddl/create_index_interleave.sql.txt +++ b/testdata/result/ddl/create_index_interleave.sql.txt @@ -6,12 +6,8 @@ create index foo_bar on foo ( --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 41, - Unique: false, - NullFiltered: false, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 41, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -62,4 +58,4 @@ create index foo_bar on foo ( } --- SQL -CREATE INDEX foo_bar ON foo (foo DESC) STORING (bar), INTERLEAVE IN foobar +CREATE INDEX foo_bar ON foo(foo DESC) STORING (bar), INTERLEAVE IN foobar diff --git a/testdata/result/ddl/create_index_storing.sql.txt b/testdata/result/ddl/create_index_storing.sql.txt index 3c538ded..5f0a2dbf 100644 --- a/testdata/result/ddl/create_index_storing.sql.txt +++ b/testdata/result/ddl/create_index_storing.sql.txt @@ -5,12 +5,8 @@ create index foo_bar on foo ( --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 40, - Unique: false, - NullFiltered: false, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 40, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -55,8 +51,7 @@ create index foo_bar on foo ( }, }, }, - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE INDEX foo_bar ON foo (bar ASC) STORING (foo, baz) +CREATE INDEX foo_bar ON foo(bar ASC) STORING (foo, baz) diff --git a/testdata/result/ddl/create_model.sql.txt b/testdata/result/ddl/create_model.sql.txt index 8ef0fbe3..de647cb2 100644 --- a/testdata/result/ddl/create_model.sql.txt +++ b/testdata/result/ddl/create_model.sql.txt @@ -15,11 +15,8 @@ OPTIONS ( ) --- AST &ast.CreateModel{ - Create: 0, - Remote: 183, - OrReplace: false, - IfNotExists: false, - Name: &ast.Ident{ + Remote: 183, + Name: &ast.Ident{ NamePos: 13, NameEnd: 34, Name: "MyClassificationModel", @@ -38,7 +35,6 @@ OPTIONS ( NamePos: 52, Name: "FLOAT64", }, - Options: (*ast.Options)(nil), }, &ast.CreateModelColumn{ Name: &ast.Ident{ @@ -51,9 +47,7 @@ OPTIONS ( Rparen: 82, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, &ast.CreateModelColumn{ Name: &ast.Ident{ @@ -62,17 +56,16 @@ OPTIONS ( Name: "tag_array", }, DataType: &ast.ArraySchemaType{ - Array: 97, - Gt: 114, - Item: &ast.SizedSchemaType{ + Array: 97, + Gt: 114, + Rparen: -1, + Item: &ast.SizedSchemaType{ NamePos: 103, Rparen: 113, Name: "STRING", Max: true, - Size: nil, }, }, - Options: (*ast.Options)(nil), }, }, OutputColumns: []*ast.CreateModelColumn{ @@ -83,14 +76,14 @@ OPTIONS ( Name: "scores", }, DataType: &ast.ArraySchemaType{ - Array: 136, - Gt: 149, - Item: &ast.ScalarSchemaType{ + Array: 136, + Gt: 149, + Rparen: -1, + Item: &ast.ScalarSchemaType{ NamePos: 142, Name: "FLOAT64", }, }, - Options: (*ast.Options)(nil), }, &ast.CreateModelColumn{ Name: &ast.Ident{ @@ -99,17 +92,16 @@ OPTIONS ( Name: "classes", }, DataType: &ast.ArraySchemaType{ - Array: 162, - Gt: 179, - Item: &ast.SizedSchemaType{ + Array: 162, + Gt: 179, + Rparen: -1, + Item: &ast.SizedSchemaType{ NamePos: 168, Rparen: 178, Name: "STRING", Max: true, - Size: nil, }, }, - Options: (*ast.Options)(nil), }, }, }, diff --git a/testdata/result/ddl/create_model_if_not_exists.sql.txt b/testdata/result/ddl/create_model_if_not_exists.sql.txt index dfaea744..05f2efaa 100644 --- a/testdata/result/ddl/create_model_if_not_exists.sql.txt +++ b/testdata/result/ddl/create_model_if_not_exists.sql.txt @@ -8,9 +8,7 @@ REMOTE OPTIONS ( ) --- AST &ast.CreateModel{ - Create: 0, Remote: 93, - OrReplace: false, IfNotExists: true, Name: &ast.Ident{ NamePos: 13, @@ -32,9 +30,7 @@ REMOTE OPTIONS ( Rparen: 61, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, }, OutputColumns: []*ast.CreateModelColumn{ @@ -49,9 +45,7 @@ REMOTE OPTIONS ( Rparen: 90, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, }, }, diff --git a/testdata/result/ddl/create_or_replace_model.sql.txt b/testdata/result/ddl/create_or_replace_model.sql.txt index 7f9f4a2c..9955be94 100644 --- a/testdata/result/ddl/create_or_replace_model.sql.txt +++ b/testdata/result/ddl/create_or_replace_model.sql.txt @@ -8,11 +8,9 @@ REMOTE OPTIONS ( ) --- AST &ast.CreateModel{ - Create: 0, - Remote: 90, - OrReplace: true, - IfNotExists: false, - Name: &ast.Ident{ + Remote: 90, + OrReplace: true, + Name: &ast.Ident{ NamePos: 24, NameEnd: 33, Name: "GeminiPro", @@ -32,9 +30,7 @@ REMOTE OPTIONS ( Rparen: 58, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, }, OutputColumns: []*ast.CreateModelColumn{ @@ -49,9 +45,7 @@ REMOTE OPTIONS ( Rparen: 87, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, }, }, diff --git a/testdata/result/ddl/create_or_replace_view.sql.txt b/testdata/result/ddl/create_or_replace_view.sql.txt index f66ace7f..59a20e48 100644 --- a/testdata/result/ddl/create_or_replace_view.sql.txt +++ b/testdata/result/ddl/create_or_replace_view.sql.txt @@ -8,8 +8,7 @@ from singers --- AST &ast.CreateView{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 23, @@ -21,10 +20,8 @@ from singers OrReplace: true, SecurityType: "INVOKER", Query: &ast.Select{ - Select: 59, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 59, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -107,16 +104,8 @@ from singers NameEnd: 169, Name: "singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/ddl/create_placement.sql.txt b/testdata/result/ddl/create_placement.sql.txt index efbb1bc0..4cae85d1 100644 --- a/testdata/result/ddl/create_placement.sql.txt +++ b/testdata/result/ddl/create_placement.sql.txt @@ -2,8 +2,7 @@ CREATE PLACEMENT `europeplacement` OPTIONS (instance_partition="europe-partition") --- AST &ast.CreatePlacement{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 17, NameEnd: 34, Name: "europeplacement", diff --git a/testdata/result/ddl/create_role.sql.txt b/testdata/result/ddl/create_role.sql.txt index 1ee359a6..272ed16b 100644 --- a/testdata/result/ddl/create_role.sql.txt +++ b/testdata/result/ddl/create_role.sql.txt @@ -3,8 +3,7 @@ CREATE ROLE hr_manager --- AST &ast.CreateRole{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 12, NameEnd: 22, Name: "hr_manager", diff --git a/testdata/result/ddl/create_schema.sql.txt b/testdata/result/ddl/create_schema.sql.txt index 2b04f8f5..0d7bd8cd 100644 --- a/testdata/result/ddl/create_schema.sql.txt +++ b/testdata/result/ddl/create_schema.sql.txt @@ -2,8 +2,7 @@ CREATE SCHEMA sch1 --- AST &ast.CreateSchema{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 14, NameEnd: 18, Name: "sch1", diff --git a/testdata/result/ddl/create_search_index_full.sql.txt b/testdata/result/ddl/create_search_index_full.sql.txt index 299f2fe0..3f4d4b09 100644 --- a/testdata/result/ddl/create_search_index_full.sql.txt +++ b/testdata/result/ddl/create_search_index_full.sql.txt @@ -9,8 +9,7 @@ WHERE Genre IS NOT NULL AND ReleaseTimestamp IS NOT NULL OPTIONS(sort_order_sharding=true) --- AST &ast.CreateSearchIndex{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 35, Name: "AlbumsIndexFull", @@ -61,8 +60,7 @@ OPTIONS(sort_order_sharding=true) NameEnd: 137, Name: "ReleaseTimestamp", }, - Collate: (*ast.Collate)(nil), - Dir: "DESC", + Dir: "DESC", }, }, }, diff --git a/testdata/result/ddl/create_search_index_null_filtered.sql.txt b/testdata/result/ddl/create_search_index_null_filtered.sql.txt index f1fab7c1..d5729a3a 100644 --- a/testdata/result/ddl/create_search_index_null_filtered.sql.txt +++ b/testdata/result/ddl/create_search_index_null_filtered.sql.txt @@ -5,8 +5,7 @@ STORING(Genre) WHERE Genre IS NOT NULL --- AST &ast.CreateSearchIndex{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 31, Name: "AlbumsIndex", @@ -35,9 +34,7 @@ WHERE Genre IS NOT NULL }, }, }, - PartitionColumns: []*ast.Ident(nil), - OrderBy: (*ast.OrderBy)(nil), - Where: &ast.Where{ + Where: &ast.Where{ Where: 76, Expr: &ast.IsNullExpr{ Null: 95, @@ -49,8 +46,6 @@ WHERE Genre IS NOT NULL }, }, }, - Interleave: (*ast.InterleaveIn)(nil), - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/ddl/create_search_index_simple.sql.txt b/testdata/result/ddl/create_search_index_simple.sql.txt index 60072aa5..157fa39d 100644 --- a/testdata/result/ddl/create_search_index_simple.sql.txt +++ b/testdata/result/ddl/create_search_index_simple.sql.txt @@ -22,13 +22,7 @@ CREATE SEARCH INDEX AlbumsIndex Name: "AlbumTitle_Tokens", }, }, - Rparen: 84, - Storing: (*ast.Storing)(nil), - PartitionColumns: []*ast.Ident(nil), - OrderBy: (*ast.OrderBy)(nil), - Where: (*ast.Where)(nil), - Interleave: (*ast.InterleaveIn)(nil), - Options: (*ast.Options)(nil), + Rparen: 84, } --- SQL diff --git a/testdata/result/ddl/create_sequance.sql.txt b/testdata/result/ddl/create_sequance.sql.txt index ffb91fe6..e38e825b 100644 --- a/testdata/result/ddl/create_sequance.sql.txt +++ b/testdata/result/ddl/create_sequance.sql.txt @@ -7,8 +7,7 @@ CREATE SEQUENCE IF NOT EXISTS MySequence OPTIONS ( --- AST &ast.CreateSequence{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 30, @@ -18,7 +17,6 @@ CREATE SEQUENCE IF NOT EXISTS MySequence OPTIONS ( }, }, IfNotExists: true, - Params: []ast.SequenceParam(nil), Options: &ast.Options{ Options: 41, Rparen: 172, diff --git a/testdata/result/ddl/create_table.sql.txt b/testdata/result/ddl/create_table.sql.txt index 9f7692d8..f3d84cdf 100644 --- a/testdata/result/ddl/create_table.sql.txt +++ b/testdata/result/ddl/create_table.sql.txt @@ -16,10 +16,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 573, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 573, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -40,12 +38,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: 50, @@ -58,12 +51,8 @@ create table foo ( NamePos: 38, Name: "FLOAT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 78, @@ -76,7 +65,6 @@ create table foo ( NamePos: 62, Rparen: 72, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 69, ValueEnd: 72, @@ -84,12 +72,9 @@ create table foo ( Value: "255", }, }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: &ast.Options{ + NotNull: true, + Hidden: -1, + Options: &ast.Options{ Options: 83, Rparen: 120, Records: []*ast.OptionsDef{ @@ -117,7 +102,6 @@ create table foo ( NamePos: 129, Rparen: 139, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 136, ValueEnd: 139, @@ -126,7 +110,6 @@ create table foo ( }, }, NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), GeneratedExpr: &ast.GeneratedColumnExpr{ As: 150, Stored: 172, @@ -138,8 +121,7 @@ create table foo ( NameEnd: 160, Name: "concat", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 161, @@ -155,14 +137,9 @@ create table foo ( }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -175,12 +152,7 @@ create table foo ( NamePos: 487, Name: "JSON", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: 515, @@ -204,23 +176,14 @@ create table foo ( NameEnd: 546, Name: "current_timestamp", }, - Distinct: false, - Args: []ast.Arg(nil), - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, TableConstraints: []*ast.TableConstraint{ &ast.TableConstraint{ ConstraintPos: -1, - Name: (*ast.Ident)(nil), Constraint: &ast.ForeignKey{ Foreign: 182, Rparen: 221, @@ -248,12 +211,10 @@ create table foo ( Name: "t2key1", }, }, - OnDelete: "", }, }, &ast.TableConstraint{ ConstraintPos: -1, - Name: (*ast.Ident)(nil), Constraint: &ast.ForeignKey{ Foreign: 226, Rparen: 265, @@ -286,7 +247,6 @@ create table foo ( }, &ast.TableConstraint{ ConstraintPos: -1, - Name: (*ast.Ident)(nil), Constraint: &ast.ForeignKey{ Foreign: 288, Rparen: 327, @@ -361,12 +321,10 @@ create table foo ( Name: "t2key2", }, }, - OnDelete: "", }, }, &ast.TableConstraint{ ConstraintPos: -1, - Name: (*ast.Ident)(nil), Constraint: &ast.Check{ Check: 427, Rparen: 441, @@ -421,7 +379,6 @@ create table foo ( NameEnd: 568, Name: "foo", }, - Dir: "", }, &ast.IndexKey{ DirPos: -1, @@ -430,12 +387,8 @@ create table foo ( NameEnd: 573, Name: "bar", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_cluster.sql.txt b/testdata/result/ddl/create_table_cluster.sql.txt index bcce26e8..bacaadc3 100644 --- a/testdata/result/ddl/create_table_cluster.sql.txt +++ b/testdata/result/ddl/create_table_cluster.sql.txt @@ -7,10 +7,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 59, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 59, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -31,12 +29,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -49,18 +42,10 @@ create table foo ( NamePos: 38, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey(nil), - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 60, OnDeleteEnd: -1, TableName: &ast.Path{ @@ -72,9 +57,7 @@ create table foo ( }, }, }, - OnDelete: "", }, - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_cluster_and_row_deletion_policy.sql.txt b/testdata/result/ddl/create_table_cluster_and_row_deletion_policy.sql.txt index b10f3b8e..0f37325d 100644 --- a/testdata/result/ddl/create_table_cluster_and_row_deletion_policy.sql.txt +++ b/testdata/result/ddl/create_table_cluster_and_row_deletion_policy.sql.txt @@ -9,10 +9,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 77, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 77, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -33,12 +31,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -51,12 +44,7 @@ create table foo ( NamePos: 38, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -69,18 +57,10 @@ create table foo ( NamePos: 51, Name: "TIMESTAMP", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey(nil), - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 78, OnDeleteEnd: -1, TableName: &ast.Path{ @@ -92,7 +72,6 @@ create table foo ( }, }, }, - OnDelete: "", }, RowDeletionPolicy: &ast.CreateRowDeletionPolicy{ Comma: 109, diff --git a/testdata/result/ddl/create_table_cluster_on_delete_no_action.sql.txt b/testdata/result/ddl/create_table_cluster_on_delete_no_action.sql.txt index cef4f6b3..393b0989 100644 --- a/testdata/result/ddl/create_table_cluster_on_delete_no_action.sql.txt +++ b/testdata/result/ddl/create_table_cluster_on_delete_no_action.sql.txt @@ -6,10 +6,8 @@ create table foo ( on delete no action --- AST &ast.CreateTable{ - Create: 0, - Rparen: 50, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 50, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -30,16 +28,10 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -47,11 +39,9 @@ create table foo ( NameEnd: 50, Name: "foo", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 51, OnDeleteEnd: 115, TableName: &ast.Path{ @@ -65,7 +55,6 @@ create table foo ( }, OnDelete: "ON DELETE NO ACTION", }, - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_cluster_set_on_delete.sql.txt b/testdata/result/ddl/create_table_cluster_set_on_delete.sql.txt index 57616e41..8f8605c5 100644 --- a/testdata/result/ddl/create_table_cluster_set_on_delete.sql.txt +++ b/testdata/result/ddl/create_table_cluster_set_on_delete.sql.txt @@ -6,10 +6,8 @@ create table foo ( on delete cascade --- AST &ast.CreateTable{ - Create: 0, - Rparen: 49, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 49, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -30,16 +28,10 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -47,11 +39,9 @@ create table foo ( NameEnd: 49, Name: "foo", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 50, OnDeleteEnd: 112, TableName: &ast.Path{ @@ -65,7 +55,6 @@ create table foo ( }, OnDelete: "ON DELETE CASCADE", }, - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_fulltext_albums.sql.txt b/testdata/result/ddl/create_table_fulltext_albums.sql.txt index 3bacaa14..7f90a442 100644 --- a/testdata/result/ddl/create_table_fulltext_albums.sql.txt +++ b/testdata/result/ddl/create_table_fulltext_albums.sql.txt @@ -11,10 +11,9 @@ CREATE TABLE Albums ( ) PRIMARY KEY(AlbumId) --- AST &ast.CreateTable{ - Create: 105, - Rparen: 575, - IfNotExists: false, - Name: &ast.Path{ + Create: 105, + Rparen: 575, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 118, @@ -36,14 +35,9 @@ CREATE TABLE Albums ( Rparen: 169, Name: "STRING", Max: true, - Size: nil, - }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + }, + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 224, @@ -56,12 +50,8 @@ CREATE TABLE Albums ( NamePos: 214, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 281, @@ -74,12 +64,8 @@ CREATE TABLE Albums ( NamePos: 271, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -93,14 +79,8 @@ CREATE TABLE Albums ( Rparen: 332, Name: "STRING", Max: true, - Size: nil, - }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + }, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -113,12 +93,7 @@ CREATE TABLE Albums ( NamePos: 366, Name: "FLOAT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -131,8 +106,6 @@ CREATE TABLE Albums ( NamePos: 417, Name: "TOKENLIST", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), GeneratedExpr: &ast.GeneratedColumnExpr{ As: 427, Stored: -1, @@ -144,8 +117,7 @@ CREATE TABLE Albums ( NameEnd: 448, Name: "TOKENIZE_FULLTEXT", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 449, @@ -154,14 +126,9 @@ CREATE TABLE Albums ( }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: 462, - Options: (*ast.Options)(nil), + Hidden: 462, }, &ast.ColumnDef{ Null: -1, @@ -174,8 +141,6 @@ CREATE TABLE Albums ( NamePos: 508, Name: "TOKENLIST", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), GeneratedExpr: &ast.GeneratedColumnExpr{ As: 518, Stored: -1, @@ -187,8 +152,7 @@ CREATE TABLE Albums ( NameEnd: 537, Name: "TOKENIZE_NUMBER", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 538, @@ -197,18 +161,12 @@ CREATE TABLE Albums ( }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: 547, - Options: (*ast.Options)(nil), + Hidden: 547, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -216,12 +174,8 @@ CREATE TABLE Albums ( NameEnd: 575, Name: "AlbumId", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_if_not_exists.sql.txt b/testdata/result/ddl/create_table_if_not_exists.sql.txt index 54bf5846..b7b52448 100644 --- a/testdata/result/ddl/create_table_if_not_exists.sql.txt +++ b/testdata/result/ddl/create_table_if_not_exists.sql.txt @@ -6,7 +6,6 @@ create table if not exists foo ( --- AST &ast.CreateTable{ - Create: 0, Rparen: 93, IfNotExists: true, Name: &ast.Path{ @@ -30,12 +29,7 @@ create table if not exists foo ( NamePos: 39, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: 64, @@ -48,16 +42,11 @@ create table if not exists foo ( NamePos: 52, Name: "FLOAT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -65,7 +54,6 @@ create table if not exists foo ( NameEnd: 88, Name: "foo", }, - Dir: "", }, &ast.IndexKey{ DirPos: -1, @@ -74,12 +62,8 @@ create table if not exists foo ( NameEnd: 93, Name: "bar", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_row_deletion_policy.sql.txt b/testdata/result/ddl/create_table_row_deletion_policy.sql.txt index 4ccdd66f..047b3cf6 100644 --- a/testdata/result/ddl/create_table_row_deletion_policy.sql.txt +++ b/testdata/result/ddl/create_table_row_deletion_policy.sql.txt @@ -8,10 +8,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 77, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 77, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -32,12 +30,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -50,12 +43,7 @@ create table foo ( NamePos: 38, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -68,18 +56,9 @@ create table foo ( NamePos: 51, Name: "TIMESTAMP", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey(nil), - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), RowDeletionPolicy: &ast.CreateRowDeletionPolicy{ Comma: 78, RowDeletionPolicy: &ast.RowDeletionPolicy{ diff --git a/testdata/result/ddl/create_table_synonyms.sql.txt b/testdata/result/ddl/create_table_synonyms.sql.txt index 0cdf1a53..1346e7d5 100644 --- a/testdata/result/ddl/create_table_synonyms.sql.txt +++ b/testdata/result/ddl/create_table_synonyms.sql.txt @@ -6,10 +6,8 @@ CREATE TABLE Singers ( ) PRIMARY KEY (SingerId) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 126, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 126, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -30,12 +28,8 @@ CREATE TABLE Singers ( NamePos: 36, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -48,7 +42,6 @@ CREATE TABLE Singers ( NamePos: 67, Rparen: 78, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 74, ValueEnd: 78, @@ -56,16 +49,10 @@ CREATE TABLE Singers ( Value: "1024", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -73,7 +60,6 @@ CREATE TABLE Singers ( NameEnd: 126, Name: "SingerId", }, - Dir: "", }, }, Synonyms: []*ast.Synonym{ @@ -87,8 +73,6 @@ CREATE TABLE Singers ( }, }, }, - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_synonyms_abnormal.sql.txt b/testdata/result/ddl/create_table_synonyms_abnormal.sql.txt index 4c2f1993..43efa244 100644 --- a/testdata/result/ddl/create_table_synonyms_abnormal.sql.txt +++ b/testdata/result/ddl/create_table_synonyms_abnormal.sql.txt @@ -8,10 +8,9 @@ CREATE TABLE Singers ( ) PRIMARY KEY (SingerId) --- AST &ast.CreateTable{ - Create: 45, - Rparen: 194, - IfNotExists: false, - Name: &ast.Path{ + Create: 45, + Rparen: 194, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 58, @@ -32,12 +31,8 @@ CREATE TABLE Singers ( NamePos: 104, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -50,7 +45,6 @@ CREATE TABLE Singers ( NamePos: 135, Rparen: 146, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 142, ValueEnd: 146, @@ -58,16 +52,10 @@ CREATE TABLE Singers ( Value: "1024", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -75,7 +63,6 @@ CREATE TABLE Singers ( NameEnd: 194, Name: "SingerId", }, - Dir: "", }, }, Synonyms: []*ast.Synonym{ @@ -98,8 +85,6 @@ CREATE TABLE Singers ( }, }, }, - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_trailing_comma.sql.txt b/testdata/result/ddl/create_table_trailing_comma.sql.txt index 013c1a92..0e7ddcdb 100644 --- a/testdata/result/ddl/create_table_trailing_comma.sql.txt +++ b/testdata/result/ddl/create_table_trailing_comma.sql.txt @@ -9,10 +9,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 83, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 83, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -33,12 +31,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -51,16 +44,10 @@ create table foo ( NamePos: 38, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: 66, Name: &ast.Ident{ @@ -80,9 +67,6 @@ create table foo ( Dir: "DESC", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_types.sql.txt b/testdata/result/ddl/create_table_types.sql.txt index e9a93352..0dd70563 100644 --- a/testdata/result/ddl/create_table_types.sql.txt +++ b/testdata/result/ddl/create_table_types.sql.txt @@ -13,14 +13,13 @@ create table types ( ab array, abs array, p examples.ProtoType, + af32vl array(vector_length=>128), ) primary key (i) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 252, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 297, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -41,12 +40,7 @@ create table types ( NamePos: 25, Name: "BOOL", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -59,12 +53,7 @@ create table types ( NamePos: 35, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -77,12 +66,7 @@ create table types ( NamePos: 48, Name: "FLOAT32", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -95,12 +79,7 @@ create table types ( NamePos: 61, Name: "FLOAT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -113,12 +92,7 @@ create table types ( NamePos: 74, Name: "DATE", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -131,12 +105,7 @@ create table types ( NamePos: 84, Name: "TIMESTAMP", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -149,7 +118,6 @@ create table types ( NamePos: 99, Rparen: 109, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 106, ValueEnd: 109, @@ -157,12 +125,7 @@ create table types ( Value: "256", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -176,14 +139,8 @@ create table types ( Rparen: 129, Name: "STRING", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -196,7 +153,6 @@ create table types ( NamePos: 137, Rparen: 146, Name: "BYTES", - Max: false, Size: &ast.IntLiteral{ ValuePos: 143, ValueEnd: 146, @@ -204,12 +160,7 @@ create table types ( Value: "256", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -223,14 +174,8 @@ create table types ( Rparen: 166, Name: "BYTES", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -240,19 +185,15 @@ create table types ( Name: "ab", }, Type: &ast.ArraySchemaType{ - Array: 174, - Gt: 184, - Item: &ast.ScalarSchemaType{ + Array: 174, + Gt: 184, + Rparen: -1, + Item: &ast.ScalarSchemaType{ NamePos: 180, Name: "BOOL", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -262,22 +203,17 @@ create table types ( Name: "abs", }, Type: &ast.ArraySchemaType{ - Array: 193, - Gt: 209, - Item: &ast.SizedSchemaType{ + Array: 193, + Gt: 209, + Rparen: -1, + Item: &ast.SizedSchemaType{ NamePos: 199, Rparen: 208, Name: "BYTES", Max: true, - Size: nil, }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -300,30 +236,53 @@ create table types ( }, }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, + }, + &ast.ColumnDef{ + Null: -1, + Name: &ast.Ident{ + NamePos: 238, + NameEnd: 244, + Name: "af32vl", + }, + Type: &ast.ArraySchemaType{ + Array: 245, + Gt: 258, + Rparen: 278, + Item: &ast.ScalarSchemaType{ + NamePos: 251, + Name: "FLOAT32", + }, + NamedArgs: []*ast.NamedArg{ + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 260, + NameEnd: 273, + Name: "vector_length", + }, + Value: &ast.IntLiteral{ + ValuePos: 275, + ValueEnd: 278, + Base: 10, + Value: "128", + }, + }, + }, + }, + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ - NamePos: 251, - NameEnd: 252, + NamePos: 296, + NameEnd: 297, Name: "i", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL -CREATE TABLE types (b BOOL, i INT64, f32 FLOAT32, f FLOAT64, d DATE, t TIMESTAMP, s STRING(256), smax STRING(MAX), bs BYTES(256), bsmax BYTES(MAX), ab ARRAY, abs ARRAY, p examples.ProtoType) PRIMARY KEY (i) +CREATE TABLE types (b BOOL, i INT64, f32 FLOAT32, f FLOAT64, d DATE, t TIMESTAMP, s STRING(256), smax STRING(MAX), bs BYTES(256), bsmax BYTES(MAX), ab ARRAY, abs ARRAY, p examples.ProtoType, af32vl ARRAY(vector_length => 128)) PRIMARY KEY (i) diff --git a/testdata/result/ddl/create_table_with_identity_columns.sql.txt b/testdata/result/ddl/create_table_with_identity_columns.sql.txt index 8b13d846..61c5f53b 100644 --- a/testdata/result/ddl/create_table_with_identity_columns.sql.txt +++ b/testdata/result/ddl/create_table_with_identity_columns.sql.txt @@ -11,10 +11,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 457, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 457, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -35,9 +33,6 @@ create table foo ( NamePos: 26, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), IdentityColumn: &ast.IdentityColumn{ Generated: 32, Identity: 56, @@ -72,8 +67,7 @@ create table foo ( }, }, }, - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -86,9 +80,6 @@ create table foo ( NamePos: 158, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), IdentityColumn: &ast.IdentityColumn{ Generated: 164, Identity: 188, @@ -108,8 +99,7 @@ create table foo ( }, }, }, - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -122,9 +112,6 @@ create table foo ( NamePos: 269, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), IdentityColumn: &ast.IdentityColumn{ Generated: 275, Identity: 299, @@ -150,8 +137,7 @@ create table foo ( }, }, }, - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -164,9 +150,6 @@ create table foo ( NamePos: 375, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), IdentityColumn: &ast.IdentityColumn{ Generated: 381, Identity: 405, @@ -177,12 +160,10 @@ create table foo ( }, }, }, - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -190,12 +171,8 @@ create table foo ( NameEnd: 457, Name: "id", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_table_with_sequence_function.sql.txt b/testdata/result/ddl/create_table_with_sequence_function.sql.txt index 0eb6c3c7..cb4bd4d0 100644 --- a/testdata/result/ddl/create_table_with_sequence_function.sql.txt +++ b/testdata/result/ddl/create_table_with_sequence_function.sql.txt @@ -8,10 +8,8 @@ CREATE TABLE foo --- AST &ast.CreateTable{ - Create: 0, - Rparen: 143, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 143, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -32,7 +30,6 @@ CREATE TABLE foo NamePos: 27, Name: "INT64", }, - NotNull: false, DefaultExpr: &ast.ColumnDefaultExpr{ Default: 33, Rparen: 88, @@ -43,8 +40,7 @@ CREATE TABLE foo NameEnd: 65, Name: "GET_NEXT_SEQUENCE_VALUE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.SequenceArg{ Sequence: 66, Expr: &ast.Ident{ @@ -54,15 +50,9 @@ CREATE TABLE foo }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -76,14 +66,8 @@ CREATE TABLE foo Rparen: 110, Name: "STRING", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -96,16 +80,10 @@ CREATE TABLE foo NamePos: 121, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -113,12 +91,8 @@ CREATE TABLE foo NameEnd: 143, Name: "id", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/create_uniq_null_filtered_index.sql.txt b/testdata/result/ddl/create_uniq_null_filtered_index.sql.txt index 8337e5b6..c6f2a636 100644 --- a/testdata/result/ddl/create_uniq_null_filtered_index.sql.txt +++ b/testdata/result/ddl/create_uniq_null_filtered_index.sql.txt @@ -3,11 +3,9 @@ create unique null_filtered index foo_bar on foo (foo) --- AST &ast.CreateIndex{ - Create: 0, Rparen: 53, Unique: true, NullFiltered: true, - IfNotExists: false, Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ @@ -34,12 +32,9 @@ create unique null_filtered index foo_bar on foo (foo) NameEnd: 53, Name: "foo", }, - Dir: "", }, }, - Storing: (*ast.Storing)(nil), - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE UNIQUE NULL_FILTERED INDEX foo_bar ON foo (foo) +CREATE UNIQUE NULL_FILTERED INDEX foo_bar ON foo(foo) diff --git a/testdata/result/ddl/create_vector_index.sql.txt b/testdata/result/ddl/create_vector_index.sql.txt index ed7d5a6c..e2b93b86 100644 --- a/testdata/result/ddl/create_vector_index.sql.txt +++ b/testdata/result/ddl/create_vector_index.sql.txt @@ -3,7 +3,6 @@ CREATE VECTOR INDEX IF NOT EXISTS hello_vector_index ON hello(embedding) OPTIONS(distance_type = 'COSINE') --- AST &ast.CreateVectorIndex{ - Create: 0, IfNotExists: true, Name: &ast.Ident{ NamePos: 34, @@ -20,7 +19,6 @@ OPTIONS(distance_type = 'COSINE') NameEnd: 71, Name: "embedding", }, - Where: (*ast.Where)(nil), Options: &ast.Options{ Options: 73, Rparen: 105, diff --git a/testdata/result/ddl/create_vector_index_where_column_not_null.sql.txt b/testdata/result/ddl/create_vector_index_where_column_not_null.sql.txt index 965499aa..b77f7dea 100644 --- a/testdata/result/ddl/create_vector_index_where_column_not_null.sql.txt +++ b/testdata/result/ddl/create_vector_index_where_column_not_null.sql.txt @@ -4,9 +4,7 @@ WHERE embedding IS NOT NULL OPTIONS(distance_type = 'COSINE') --- AST &ast.CreateVectorIndex{ - Create: 0, - IfNotExists: false, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "hello_vector_index", diff --git a/testdata/result/ddl/create_view.sql.txt b/testdata/result/ddl/create_view.sql.txt index 09d3e5f3..7842821f 100644 --- a/testdata/result/ddl/create_view.sql.txt +++ b/testdata/result/ddl/create_view.sql.txt @@ -8,8 +8,7 @@ from singers --- AST &ast.CreateView{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -18,13 +17,10 @@ from singers }, }, }, - OrReplace: false, SecurityType: "INVOKER", Query: &ast.Select{ - Select: 48, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 48, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -107,16 +103,8 @@ from singers NameEnd: 158, Name: "singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/ddl/create_view_sql_security_definer.sql.txt b/testdata/result/ddl/create_view_sql_security_definer.sql.txt index 345b29a3..a04d0c2f 100644 --- a/testdata/result/ddl/create_view_sql_security_definer.sql.txt +++ b/testdata/result/ddl/create_view_sql_security_definer.sql.txt @@ -8,8 +8,7 @@ from singers --- AST &ast.CreateView{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -18,13 +17,10 @@ from singers }, }, }, - OrReplace: false, SecurityType: "DEFINER", Query: &ast.Select{ - Select: 48, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 48, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -107,16 +103,8 @@ from singers NameEnd: 158, Name: "singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/ddl/drop_change_stream.sql.txt b/testdata/result/ddl/drop_change_stream.sql.txt index ecbe86f7..edac2ca2 100644 --- a/testdata/result/ddl/drop_change_stream.sql.txt +++ b/testdata/result/ddl/drop_change_stream.sql.txt @@ -3,7 +3,6 @@ DROP CHANGE STREAM change_stream_name --- AST &ast.DropChangeStream{ - Drop: 0, Name: &ast.Ident{ NamePos: 19, NameEnd: 37, diff --git a/testdata/result/ddl/drop_index.sql.txt b/testdata/result/ddl/drop_index.sql.txt index 47ac6572..1896e268 100644 --- a/testdata/result/ddl/drop_index.sql.txt +++ b/testdata/result/ddl/drop_index.sql.txt @@ -3,9 +3,7 @@ drop index foo_bar --- AST &ast.DropIndex{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 11, diff --git a/testdata/result/ddl/drop_index_if_exists.sql.txt b/testdata/result/ddl/drop_index_if_exists.sql.txt index 54cf0a6a..5b190902 100644 --- a/testdata/result/ddl/drop_index_if_exists.sql.txt +++ b/testdata/result/ddl/drop_index_if_exists.sql.txt @@ -3,7 +3,6 @@ drop index if exists foo_bar --- AST &ast.DropIndex{ - Drop: 0, IfExists: true, Name: &ast.Path{ Idents: []*ast.Ident{ diff --git a/testdata/result/ddl/drop_model.sql.txt b/testdata/result/ddl/drop_model.sql.txt index be705286..c75558e9 100644 --- a/testdata/result/ddl/drop_model.sql.txt +++ b/testdata/result/ddl/drop_model.sql.txt @@ -2,9 +2,7 @@ DROP MODEL MyClassificationModel --- AST &ast.DropModel{ - Drop: 0, - IfExists: false, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 11, NameEnd: 32, Name: "MyClassificationModel", diff --git a/testdata/result/ddl/drop_model_if_exists.sql.txt b/testdata/result/ddl/drop_model_if_exists.sql.txt index 67ac03dc..99e670a2 100644 --- a/testdata/result/ddl/drop_model_if_exists.sql.txt +++ b/testdata/result/ddl/drop_model_if_exists.sql.txt @@ -2,7 +2,6 @@ DROP MODEL IF EXISTS MyClassificationModel --- AST &ast.DropModel{ - Drop: 0, IfExists: true, Name: &ast.Ident{ NamePos: 21, diff --git a/testdata/result/ddl/drop_proto_bunldle.sql.txt b/testdata/result/ddl/drop_proto_bunldle.sql.txt index b36d664b..3f5c6f02 100644 --- a/testdata/result/ddl/drop_proto_bunldle.sql.txt +++ b/testdata/result/ddl/drop_proto_bunldle.sql.txt @@ -2,7 +2,6 @@ DROP PROTO BUNDLE --- AST &ast.DropProtoBundle{ - Drop: 0, Bundle: 11, } diff --git a/testdata/result/ddl/drop_role.sql.txt b/testdata/result/ddl/drop_role.sql.txt index 62eadcab..45972f1a 100644 --- a/testdata/result/ddl/drop_role.sql.txt +++ b/testdata/result/ddl/drop_role.sql.txt @@ -3,7 +3,6 @@ DROP ROLE hr_manager --- AST &ast.DropRole{ - Drop: 0, Name: &ast.Ident{ NamePos: 10, NameEnd: 20, diff --git a/testdata/result/ddl/drop_schema.sql.txt b/testdata/result/ddl/drop_schema.sql.txt index b9356805..9916952a 100644 --- a/testdata/result/ddl/drop_schema.sql.txt +++ b/testdata/result/ddl/drop_schema.sql.txt @@ -2,7 +2,6 @@ DROP SCHEMA sch1 --- AST &ast.DropSchema{ - Drop: 0, Name: &ast.Ident{ NamePos: 12, NameEnd: 16, diff --git a/testdata/result/ddl/drop_search_index.sql.txt b/testdata/result/ddl/drop_search_index.sql.txt index fe6d374c..ca99f2d1 100644 --- a/testdata/result/ddl/drop_search_index.sql.txt +++ b/testdata/result/ddl/drop_search_index.sql.txt @@ -2,7 +2,6 @@ DROP SEARCH INDEX IF EXISTS AlbumsIndex --- AST &ast.DropSearchIndex{ - Drop: 0, IfExists: true, Name: &ast.Ident{ NamePos: 28, diff --git a/testdata/result/ddl/drop_sequence.sql.txt b/testdata/result/ddl/drop_sequence.sql.txt index 74d0585c..b8a4b84e 100644 --- a/testdata/result/ddl/drop_sequence.sql.txt +++ b/testdata/result/ddl/drop_sequence.sql.txt @@ -3,9 +3,7 @@ DROP SEQUENCE my_sequence --- AST &ast.DropSequence{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 14, diff --git a/testdata/result/ddl/drop_sequence_if_exits.sql.txt b/testdata/result/ddl/drop_sequence_if_exits.sql.txt index f8dd5731..34c58016 100644 --- a/testdata/result/ddl/drop_sequence_if_exits.sql.txt +++ b/testdata/result/ddl/drop_sequence_if_exits.sql.txt @@ -3,7 +3,6 @@ DROP SEQUENCE IF EXISTS my_sequence --- AST &ast.DropSequence{ - Drop: 0, IfExists: true, Name: &ast.Path{ Idents: []*ast.Ident{ diff --git a/testdata/result/ddl/drop_table.sql.txt b/testdata/result/ddl/drop_table.sql.txt index 099b9936..727dfa76 100644 --- a/testdata/result/ddl/drop_table.sql.txt +++ b/testdata/result/ddl/drop_table.sql.txt @@ -3,9 +3,7 @@ drop table foo --- AST &ast.DropTable{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 11, diff --git a/testdata/result/ddl/drop_table_if_exists.sql.txt b/testdata/result/ddl/drop_table_if_exists.sql.txt index de5578ca..053346fe 100644 --- a/testdata/result/ddl/drop_table_if_exists.sql.txt +++ b/testdata/result/ddl/drop_table_if_exists.sql.txt @@ -3,7 +3,6 @@ drop table if exists foo --- AST &ast.DropTable{ - Drop: 0, IfExists: true, Name: &ast.Path{ Idents: []*ast.Ident{ diff --git a/testdata/result/ddl/drop_vector_index.sql.txt b/testdata/result/ddl/drop_vector_index.sql.txt index 6c7fa9e2..f9a30112 100644 --- a/testdata/result/ddl/drop_vector_index.sql.txt +++ b/testdata/result/ddl/drop_vector_index.sql.txt @@ -2,9 +2,7 @@ DROP VECTOR INDEX hello_vector_index --- AST &ast.DropVectorIndex{ - Drop: 0, - IfExists: false, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 18, NameEnd: 36, Name: "hello_vector_index", diff --git a/testdata/result/ddl/drop_view.sql.txt b/testdata/result/ddl/drop_view.sql.txt index 959ce82d..c3c58848 100644 --- a/testdata/result/ddl/drop_view.sql.txt +++ b/testdata/result/ddl/drop_view.sql.txt @@ -2,7 +2,6 @@ DROP VIEW SingersView --- AST &ast.DropView{ - Drop: 0, Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ diff --git a/testdata/result/ddl/grant_change_stream_privilege.sql.txt b/testdata/result/ddl/grant_change_stream_privilege.sql.txt index 92016944..7bae5ed3 100644 --- a/testdata/result/ddl/grant_change_stream_privilege.sql.txt +++ b/testdata/result/ddl/grant_change_stream_privilege.sql.txt @@ -2,7 +2,6 @@ GRANT SELECT ON CHANGE STREAM cs_name_one, cs_name_two TO ROLE hr_manager --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.SelectPrivilegeOnChangeStream{ Select: 6, Names: []*ast.Ident{ diff --git a/testdata/result/ddl/grant_execute_on_table_function.sql.txt b/testdata/result/ddl/grant_execute_on_table_function.sql.txt index a7b0f16d..c3070368 100644 --- a/testdata/result/ddl/grant_execute_on_table_function.sql.txt +++ b/testdata/result/ddl/grant_execute_on_table_function.sql.txt @@ -2,7 +2,6 @@ GRANT EXECUTE ON TABLE FUNCTION READ_SingersNameStream TO ROLE hr_manager --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.ExecutePrivilegeOnTableFunction{ Execute: 6, Names: []*ast.Ident{ diff --git a/testdata/result/ddl/grant_privileges.sql.txt b/testdata/result/ddl/grant_privileges.sql.txt index 12634b04..b9cc5586 100644 --- a/testdata/result/ddl/grant_privileges.sql.txt +++ b/testdata/result/ddl/grant_privileges.sql.txt @@ -3,7 +3,6 @@ GRANT SELECT(name, level, location), UPDATE(location) ON TABLE employees, contra --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.PrivilegeOnTable{ Privileges: []ast.TablePrivilege{ &ast.SelectPrivilege{ diff --git a/testdata/result/ddl/grant_role.sql.txt b/testdata/result/ddl/grant_role.sql.txt index b748b957..c5df7aff 100644 --- a/testdata/result/ddl/grant_role.sql.txt +++ b/testdata/result/ddl/grant_role.sql.txt @@ -3,7 +3,6 @@ GRANT ROLE pii_access, pii_writter TO ROLE hr_manager, hr_director --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.RolePrivilege{ Role: 6, Names: []*ast.Ident{ diff --git a/testdata/result/ddl/grant_select_on_view.sql.txt b/testdata/result/ddl/grant_select_on_view.sql.txt index 0c96a499..dbab8e74 100644 --- a/testdata/result/ddl/grant_select_on_view.sql.txt +++ b/testdata/result/ddl/grant_select_on_view.sql.txt @@ -2,7 +2,6 @@ GRANT SELECT ON VIEW singernames TO ROLE hr_manager --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.SelectPrivilegeOnView{ Select: 6, Names: []*ast.Ident{ diff --git a/testdata/result/ddl/named_schema_create_table_backquoted.sql.txt b/testdata/result/ddl/named_schema_create_table_backquoted.sql.txt index 2773b76e..f2c9bff6 100644 --- a/testdata/result/ddl/named_schema_create_table_backquoted.sql.txt +++ b/testdata/result/ddl/named_schema_create_table_backquoted.sql.txt @@ -2,10 +2,8 @@ CREATE TABLE `ORDER`.`ORDER`(PK INT64) PRIMARY KEY(PK) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 53, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 53, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -31,16 +29,10 @@ CREATE TABLE `ORDER`.`ORDER`(PK INT64) PRIMARY KEY(PK) NamePos: 32, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -48,12 +40,8 @@ CREATE TABLE `ORDER`.`ORDER`(PK INT64) PRIMARY KEY(PK) NameEnd: 53, Name: "PK", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/named_schemas_alter_index.sql.txt b/testdata/result/ddl/named_schemas_alter_index.sql.txt index 9d5151de..5fd00cd8 100644 --- a/testdata/result/ddl/named_schemas_alter_index.sql.txt +++ b/testdata/result/ddl/named_schemas_alter_index.sql.txt @@ -2,8 +2,7 @@ ALTER INDEX sch1.indexOnSingers ADD STORED COLUMN SingerInfo --- AST &ast.AlterIndex{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/named_schemas_alter_sequence.sql.txt b/testdata/result/ddl/named_schemas_alter_sequence.sql.txt index 31ef7b41..35240b72 100644 --- a/testdata/result/ddl/named_schemas_alter_sequence.sql.txt +++ b/testdata/result/ddl/named_schemas_alter_sequence.sql.txt @@ -3,8 +3,7 @@ ALTER SEQUENCE sch1.sequence SET OPTIONS (skip_range_min=1, skip_range_max=1234567) --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -50,9 +49,6 @@ ALTER SEQUENCE sch1.sequence }, }, }, - RestartCounterWith: (*ast.RestartCounterWith)(nil), - SkipRange: (*ast.SkipRange)(nil), - NoSkipRange: (*ast.NoSkipRange)(nil), } --- SQL diff --git a/testdata/result/ddl/named_schemas_alter_table_add_constraint.sql.txt b/testdata/result/ddl/named_schemas_alter_table_add_constraint.sql.txt index 92b6c59f..c91c4229 100644 --- a/testdata/result/ddl/named_schemas_alter_table_add_constraint.sql.txt +++ b/testdata/result/ddl/named_schemas_alter_table_add_constraint.sql.txt @@ -3,8 +3,7 @@ ALTER TABLE sch1.ShoppingCarts ADD CONSTRAINT FKShoppingCartsCustomers FOREIGN K REFERENCES sch1.Customers(CustomerId, CustomerName) ON DELETE CASCADE --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/named_schemas_alter_table_drop_constraints.sql.txt b/testdata/result/ddl/named_schemas_alter_table_drop_constraints.sql.txt index e76de6a7..83f44484 100644 --- a/testdata/result/ddl/named_schemas_alter_table_drop_constraints.sql.txt +++ b/testdata/result/ddl/named_schemas_alter_table_drop_constraints.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE sch1.ShoppingCarts DROP CONSTRAINT FKShoppingCartsCustomers --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/ddl/named_schemas_create_index.sql.txt b/testdata/result/ddl/named_schemas_create_index.sql.txt index 7f58a8e0..46e400bb 100644 --- a/testdata/result/ddl/named_schemas_create_index.sql.txt +++ b/testdata/result/ddl/named_schemas_create_index.sql.txt @@ -2,12 +2,8 @@ CREATE INDEX sch1.indexOnSingers ON sch1.Singers(FirstName) --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 58, - Unique: false, - NullFiltered: false, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 58, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -43,12 +39,9 @@ CREATE INDEX sch1.indexOnSingers ON sch1.Singers(FirstName) NameEnd: 58, Name: "FirstName", }, - Dir: "", }, }, - Storing: (*ast.Storing)(nil), - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE INDEX sch1.indexOnSingers ON sch1.Singers (FirstName) +CREATE INDEX sch1.indexOnSingers ON sch1.Singers(FirstName) diff --git a/testdata/result/ddl/named_schemas_create_sequence.sql.txt b/testdata/result/ddl/named_schemas_create_sequence.sql.txt index bbaa6e61..7749d978 100644 --- a/testdata/result/ddl/named_schemas_create_sequence.sql.txt +++ b/testdata/result/ddl/named_schemas_create_sequence.sql.txt @@ -4,8 +4,7 @@ CREATE SEQUENCE sch1.sequence OPTIONS ( ) --- AST &ast.CreateSequence{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 16, @@ -19,9 +18,7 @@ CREATE SEQUENCE sch1.sequence OPTIONS ( }, }, }, - IfNotExists: false, - Params: []ast.SequenceParam(nil), - Options: &ast.Options{ + Options: &ast.Options{ Options: 30, Rparen: 82, Records: []*ast.OptionsDef{ diff --git a/testdata/result/ddl/named_schemas_create_table.sql.txt b/testdata/result/ddl/named_schemas_create_table.sql.txt index 583cfa80..beb9447b 100644 --- a/testdata/result/ddl/named_schemas_create_table.sql.txt +++ b/testdata/result/ddl/named_schemas_create_table.sql.txt @@ -7,10 +7,8 @@ CREATE TABLE sch1.Singers ( ) PRIMARY KEY(SingerId) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 161, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 161, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -36,12 +34,8 @@ CREATE TABLE sch1.Singers ( NamePos: 41, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -54,7 +48,6 @@ CREATE TABLE sch1.Singers ( NamePos: 71, Rparen: 82, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 78, ValueEnd: 82, @@ -62,12 +55,7 @@ CREATE TABLE sch1.Singers ( Value: "1024", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -80,7 +68,6 @@ CREATE TABLE sch1.Singers ( NamePos: 98, Rparen: 109, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 105, ValueEnd: 109, @@ -88,12 +75,7 @@ CREATE TABLE sch1.Singers ( Value: "1024", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -107,18 +89,11 @@ CREATE TABLE sch1.Singers ( Rparen: 136, Name: "BYTES", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -126,12 +101,8 @@ CREATE TABLE sch1.Singers ( NameEnd: 161, Name: "SingerId", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/named_schemas_create_table_foreign_key.sql.txt b/testdata/result/ddl/named_schemas_create_table_foreign_key.sql.txt index 82b1bb68..deb384e1 100644 --- a/testdata/result/ddl/named_schemas_create_table_foreign_key.sql.txt +++ b/testdata/result/ddl/named_schemas_create_table_foreign_key.sql.txt @@ -8,10 +8,8 @@ CREATE TABLE sch1.ShoppingCarts ( ) PRIMARY KEY(CartId) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 296, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 296, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -37,12 +35,8 @@ CREATE TABLE sch1.ShoppingCarts ( NamePos: 43, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 82, @@ -55,12 +49,8 @@ CREATE TABLE sch1.ShoppingCarts ( NamePos: 72, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 119, @@ -74,14 +64,9 @@ CREATE TABLE sch1.ShoppingCarts ( Rparen: 113, Name: "STRING", Max: true, - Size: nil, }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, }, TableConstraints: []*ast.TableConstraint{ @@ -146,12 +131,8 @@ CREATE TABLE sch1.ShoppingCarts ( NameEnd: 296, Name: "CartId", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/named_schemas_create_table_interleave.sql.txt b/testdata/result/ddl/named_schemas_create_table_interleave.sql.txt index d54a49ff..82983cde 100644 --- a/testdata/result/ddl/named_schemas_create_table_interleave.sql.txt +++ b/testdata/result/ddl/named_schemas_create_table_interleave.sql.txt @@ -7,10 +7,8 @@ CREATE TABLE sch1.Albums ( INTERLEAVE IN PARENT sch1.Singers ON DELETE CASCADE --- AST &ast.CreateTable{ - Create: 0, - Rparen: 137, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 137, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -36,12 +34,8 @@ CREATE TABLE sch1.Albums ( NamePos: 38, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 74, @@ -54,12 +48,8 @@ CREATE TABLE sch1.Albums ( NamePos: 64, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -73,18 +63,11 @@ CREATE TABLE sch1.Albums ( Rparen: 103, Name: "STRING", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -92,7 +75,6 @@ CREATE TABLE sch1.Albums ( NameEnd: 128, Name: "SingerId", }, - Dir: "", }, &ast.IndexKey{ DirPos: -1, @@ -101,11 +83,9 @@ CREATE TABLE sch1.Albums ( NameEnd: 137, Name: "AlbumId", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 138, OnDeleteEnd: 193, TableName: &ast.Path{ @@ -124,7 +104,6 @@ CREATE TABLE sch1.Albums ( }, OnDelete: "ON DELETE CASCADE", }, - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/ddl/named_schemas_create_view.sql.txt b/testdata/result/ddl/named_schemas_create_view.sql.txt index 19615943..bda5fae5 100644 --- a/testdata/result/ddl/named_schemas_create_view.sql.txt +++ b/testdata/result/ddl/named_schemas_create_view.sql.txt @@ -4,8 +4,7 @@ AS Select s.FirstName, s.LastName, s.SingerInfo FROM sch1.Singers AS s WHERE s.SingerId = 123456 --- AST &ast.CreateView{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -19,13 +18,10 @@ AS Select s.FirstName, s.LastName, s.SingerInfo }, }, }, - OrReplace: false, SecurityType: "INVOKER", Query: &ast.Select{ - Select: 52, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 52, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -92,8 +88,7 @@ AS Select s.FirstName, s.LastName, s.SingerInfo }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 118, Alias: &ast.Ident{ NamePos: 121, @@ -101,8 +96,6 @@ AS Select s.FirstName, s.LastName, s.SingerInfo Name: "s", }, }, - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -131,10 +124,6 @@ AS Select s.FirstName, s.LastName, s.SingerInfo }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/ddl/named_schemas_drop_index.sql.txt b/testdata/result/ddl/named_schemas_drop_index.sql.txt index e39e22d3..a5ac72df 100644 --- a/testdata/result/ddl/named_schemas_drop_index.sql.txt +++ b/testdata/result/ddl/named_schemas_drop_index.sql.txt @@ -2,9 +2,7 @@ DROP INDEX sch1.indexOnSingers --- AST &ast.DropIndex{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 11, diff --git a/testdata/result/ddl/named_schemas_drop_sequence.sql.txt b/testdata/result/ddl/named_schemas_drop_sequence.sql.txt index 1714e94e..7252d218 100644 --- a/testdata/result/ddl/named_schemas_drop_sequence.sql.txt +++ b/testdata/result/ddl/named_schemas_drop_sequence.sql.txt @@ -2,9 +2,7 @@ DROP SEQUENCE sch1.sequence --- AST &ast.DropSequence{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 14, diff --git a/testdata/result/ddl/named_schemas_drop_table.sql.txt b/testdata/result/ddl/named_schemas_drop_table.sql.txt index f4a3fc70..f68cc7ba 100644 --- a/testdata/result/ddl/named_schemas_drop_table.sql.txt +++ b/testdata/result/ddl/named_schemas_drop_table.sql.txt @@ -2,9 +2,7 @@ DROP TABLE sch1.ShoppingCarts --- AST &ast.DropTable{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 11, diff --git a/testdata/result/ddl/named_schemas_drop_view.sql.txt b/testdata/result/ddl/named_schemas_drop_view.sql.txt index 0431f46a..6a963dbe 100644 --- a/testdata/result/ddl/named_schemas_drop_view.sql.txt +++ b/testdata/result/ddl/named_schemas_drop_view.sql.txt @@ -2,7 +2,6 @@ DROP VIEW sch1.SingerView --- AST &ast.DropView{ - Drop: 0, Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ diff --git a/testdata/result/ddl/rename_table_multiple.sql.txt b/testdata/result/ddl/rename_table_multiple.sql.txt index e075f639..735954fc 100644 --- a/testdata/result/ddl/rename_table_multiple.sql.txt +++ b/testdata/result/ddl/rename_table_multiple.sql.txt @@ -2,8 +2,7 @@ RENAME TABLE Singers TO Artists, Albums TO Recordings --- AST &ast.RenameTable{ - Rename: 0, - Tos: []*ast.RenameTableTo{ + Tos: []*ast.RenameTableTo{ &ast.RenameTableTo{ Old: &ast.Ident{ NamePos: 13, diff --git a/testdata/result/ddl/rename_table_single.sql.txt b/testdata/result/ddl/rename_table_single.sql.txt index a6358055..7390f014 100644 --- a/testdata/result/ddl/rename_table_single.sql.txt +++ b/testdata/result/ddl/rename_table_single.sql.txt @@ -2,8 +2,7 @@ RENAME TABLE Singers TO Artists --- AST &ast.RenameTable{ - Rename: 0, - Tos: []*ast.RenameTableTo{ + Tos: []*ast.RenameTableTo{ &ast.RenameTableTo{ Old: &ast.Ident{ NamePos: 13, diff --git a/testdata/result/ddl/revoke_change_stream_privilege.sql.txt b/testdata/result/ddl/revoke_change_stream_privilege.sql.txt index b3f9b42c..59695a63 100644 --- a/testdata/result/ddl/revoke_change_stream_privilege.sql.txt +++ b/testdata/result/ddl/revoke_change_stream_privilege.sql.txt @@ -2,7 +2,6 @@ REVOKE SELECT ON CHANGE STREAM cs_name_one, cs_name_two FROM ROLE hr_manager --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.SelectPrivilegeOnChangeStream{ Select: 7, Names: []*ast.Ident{ diff --git a/testdata/result/ddl/revoke_execute_on_table_function.sql.txt b/testdata/result/ddl/revoke_execute_on_table_function.sql.txt index 4dd6b857..b7695b39 100644 --- a/testdata/result/ddl/revoke_execute_on_table_function.sql.txt +++ b/testdata/result/ddl/revoke_execute_on_table_function.sql.txt @@ -2,7 +2,6 @@ REVOKE EXECUTE ON TABLE FUNCTION READ_SingersNameStream FROM ROLE hr_manager --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.ExecutePrivilegeOnTableFunction{ Execute: 7, Names: []*ast.Ident{ diff --git a/testdata/result/ddl/revoke_privileges.sql.txt b/testdata/result/ddl/revoke_privileges.sql.txt index 1d0f03bf..700fab92 100644 --- a/testdata/result/ddl/revoke_privileges.sql.txt +++ b/testdata/result/ddl/revoke_privileges.sql.txt @@ -3,7 +3,6 @@ REVOKE SELECT(name, level, location), UPDATE(location) ON TABLE employees, contr --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.PrivilegeOnTable{ Privileges: []ast.TablePrivilege{ &ast.SelectPrivilege{ diff --git a/testdata/result/ddl/revoke_role.sql.txt b/testdata/result/ddl/revoke_role.sql.txt index e9424539..532ada8b 100644 --- a/testdata/result/ddl/revoke_role.sql.txt +++ b/testdata/result/ddl/revoke_role.sql.txt @@ -3,7 +3,6 @@ REVOKE ROLE pii_access, pii_writter FROM ROLE hr_manager, hr_director --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.RolePrivilege{ Role: 7, Names: []*ast.Ident{ diff --git a/testdata/result/ddl/revoke_select_on_view.sql.txt b/testdata/result/ddl/revoke_select_on_view.sql.txt index ecf3c1dd..4f45d474 100644 --- a/testdata/result/ddl/revoke_select_on_view.sql.txt +++ b/testdata/result/ddl/revoke_select_on_view.sql.txt @@ -2,7 +2,6 @@ REVOKE SELECT ON VIEW singernames FROM ROLE hr_manager --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.SelectPrivilegeOnView{ Select: 7, Names: []*ast.Ident{ diff --git a/testdata/result/dml/delete _from.sql.txt b/testdata/result/dml/delete _from.sql.txt index 29eddeae..ef9d1756 100644 --- a/testdata/result/dml/delete _from.sql.txt +++ b/testdata/result/dml/delete _from.sql.txt @@ -2,13 +2,11 @@ delete from foo where foo = 1 and bar = 2 --- AST &ast.Delete{ - Delete: 0, TableName: &ast.Ident{ NamePos: 12, NameEnd: 15, Name: "foo", }, - As: (*ast.AsAlias)(nil), Where: &ast.Where{ Where: 16, Expr: &ast.BinaryExpr{ @@ -43,7 +41,6 @@ delete from foo where foo = 1 and bar = 2 }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/delete.sql.txt b/testdata/result/dml/delete.sql.txt index 1bf07ded..6c7b6ce8 100644 --- a/testdata/result/dml/delete.sql.txt +++ b/testdata/result/dml/delete.sql.txt @@ -2,13 +2,11 @@ delete foo where foo = 1 and bar = 2 --- AST &ast.Delete{ - Delete: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", }, - As: (*ast.AsAlias)(nil), Where: &ast.Where{ Where: 11, Expr: &ast.BinaryExpr{ @@ -43,7 +41,6 @@ delete foo where foo = 1 and bar = 2 }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/delete_as.sql.txt b/testdata/result/dml/delete_as.sql.txt index 36c330e3..f0758fd5 100644 --- a/testdata/result/dml/delete_as.sql.txt +++ b/testdata/result/dml/delete_as.sql.txt @@ -2,7 +2,6 @@ delete foo as F where F.foo = 1 --- AST &ast.Delete{ - Delete: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, @@ -42,7 +41,6 @@ delete foo as F where F.foo = 1 }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/delete_then_return.sql.txt b/testdata/result/dml/delete_then_return.sql.txt index 94b742a1..6c160a1f 100644 --- a/testdata/result/dml/delete_then_return.sql.txt +++ b/testdata/result/dml/delete_then_return.sql.txt @@ -2,13 +2,11 @@ delete foo where foo = 1 and bar = 2 then return * --- AST &ast.Delete{ - Delete: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", }, - As: (*ast.AsAlias)(nil), Where: &ast.Where{ Where: 11, Expr: &ast.BinaryExpr{ @@ -44,9 +42,8 @@ delete foo where foo = 1 and bar = 2 then return * }, }, ThenReturn: &ast.ThenReturn{ - Then: 37, - WithAction: (*ast.WithAction)(nil), - Items: []ast.SelectItem{ + Then: 37, + Items: []ast.SelectItem{ &ast.Star{ Star: 49, }, diff --git a/testdata/result/dml/insert_cte_select.sql.txt b/testdata/result/dml/insert_cte_select.sql.txt new file mode 100644 index 00000000..13e64ec7 --- /dev/null +++ b/testdata/result/dml/insert_cte_select.sql.txt @@ -0,0 +1,89 @@ +--- insert_cte_select.sql +insert foo (foo, bar) +with cte AS (select 1 as foo, 2 as bar) +select * +--- AST +&ast.Insert{ + TableName: &ast.Ident{ + NamePos: 7, + NameEnd: 10, + Name: "foo", + }, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 12, + NameEnd: 15, + Name: "foo", + }, + &ast.Ident{ + NamePos: 17, + NameEnd: 20, + Name: "bar", + }, + }, + Input: &ast.SubQueryInput{ + Query: &ast.Query{ + With: &ast.With{ + With: 22, + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 60, + Name: &ast.Ident{ + NamePos: 27, + NameEnd: 30, + Name: "cte", + }, + QueryExpr: &ast.Select{ + Select: 35, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 42, + ValueEnd: 43, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: 44, + Alias: &ast.Ident{ + NamePos: 47, + NameEnd: 50, + Name: "foo", + }, + }, + }, + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 52, + ValueEnd: 53, + Base: 10, + Value: "2", + }, + As: &ast.AsAlias{ + As: 54, + Alias: &ast.Ident{ + NamePos: 57, + NameEnd: 60, + Name: "bar", + }, + }, + }, + }, + }, + }, + }, + }, + Query: &ast.Select{ + Select: 62, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 69, + }, + }, + }, + }, + }, +} + +--- SQL +INSERT INTO foo (foo, bar) WITH cte AS (SELECT 1 AS foo, 2 AS bar) SELECT * diff --git a/testdata/result/dml/insert_into_values.sql.txt b/testdata/result/dml/insert_into_values.sql.txt index dc897ce3..670a2c4b 100644 --- a/testdata/result/dml/insert_into_values.sql.txt +++ b/testdata/result/dml/insert_into_values.sql.txt @@ -4,9 +4,7 @@ values (1, 2, 3), (4, 5, 6) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 12, NameEnd: 15, Name: "foo", @@ -37,7 +35,6 @@ values (1, 2, 3), Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 40, ValueEnd: 41, @@ -47,7 +44,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 43, ValueEnd: 44, @@ -57,7 +53,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 46, ValueEnd: 47, @@ -73,7 +68,6 @@ values (1, 2, 3), Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 58, ValueEnd: 59, @@ -83,7 +77,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 61, ValueEnd: 62, @@ -93,7 +86,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 64, ValueEnd: 65, @@ -105,7 +97,6 @@ values (1, 2, 3), }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/insert_or_ignore.sql.txt b/testdata/result/dml/insert_or_ignore.sql.txt index 9994ff8e..43d4b19e 100644 --- a/testdata/result/dml/insert_or_ignore.sql.txt +++ b/testdata/result/dml/insert_or_ignore.sql.txt @@ -3,7 +3,6 @@ INSERT OR IGNORE INTO foo (foo, bar) VALUES (1, 2) --- AST &ast.Insert{ - Insert: 0, InsertOrType: "IGNORE", TableName: &ast.Ident{ NamePos: 22, @@ -31,7 +30,6 @@ INSERT OR IGNORE INTO foo Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 45, ValueEnd: 46, @@ -41,7 +39,6 @@ INSERT OR IGNORE INTO foo }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 48, ValueEnd: 49, @@ -53,7 +50,6 @@ INSERT OR IGNORE INTO foo }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/insert_or_update.sql.txt b/testdata/result/dml/insert_or_update.sql.txt index a87b61f8..4ecc3acc 100644 --- a/testdata/result/dml/insert_or_update.sql.txt +++ b/testdata/result/dml/insert_or_update.sql.txt @@ -3,7 +3,6 @@ INSERT OR UPDATE INTO foo (foo, bar) VALUES (1, 2) --- AST &ast.Insert{ - Insert: 0, InsertOrType: "UPDATE", TableName: &ast.Ident{ NamePos: 22, @@ -31,7 +30,6 @@ INSERT OR UPDATE INTO foo Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 45, ValueEnd: 46, @@ -41,7 +39,6 @@ INSERT OR UPDATE INTO foo }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 48, ValueEnd: 49, @@ -53,7 +50,6 @@ INSERT OR UPDATE INTO foo }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/insert_or_update_then_return_with_action_as.sql.txt b/testdata/result/dml/insert_or_update_then_return_with_action_as.sql.txt index ab5e4a6d..665e0e2a 100644 --- a/testdata/result/dml/insert_or_update_then_return_with_action_as.sql.txt +++ b/testdata/result/dml/insert_or_update_then_return_with_action_as.sql.txt @@ -4,7 +4,6 @@ INSERT OR UPDATE INTO foo THEN RETURN WITH ACTION AS act * --- AST &ast.Insert{ - Insert: 0, InsertOrType: "UPDATE", TableName: &ast.Ident{ NamePos: 22, @@ -32,7 +31,6 @@ THEN RETURN WITH ACTION AS act * Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 45, ValueEnd: 46, @@ -42,7 +40,6 @@ THEN RETURN WITH ACTION AS act * }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 48, ValueEnd: 49, diff --git a/testdata/result/dml/insert_select.sql.txt b/testdata/result/dml/insert_select.sql.txt index 5b3b5590..2b2e713b 100644 --- a/testdata/result/dml/insert_select.sql.txt +++ b/testdata/result/dml/insert_select.sql.txt @@ -3,9 +3,7 @@ insert foo (foo, bar) select * from unnest([(1, 2), (3, 4)]) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", @@ -24,10 +22,8 @@ select * from unnest([(1, 2), (3, 4)]) }, Input: &ast.SubQueryInput{ Query: &ast.Select{ - Select: 22, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 22, + Results: []ast.SelectItem{ &ast.Star{ Star: 29, }, @@ -41,7 +37,6 @@ select * from unnest([(1, 2), (3, 4)]) Array: -1, Lbrack: 43, Rbrack: 58, - Type: nil, Values: []ast.Expr{ &ast.TupleStructLiteral{ Lparen: 44, @@ -81,20 +76,10 @@ select * from unnest([(1, 2), (3, 4)]) }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/insert_values.sql.txt b/testdata/result/dml/insert_values.sql.txt index aae84cad..e791c60d 100644 --- a/testdata/result/dml/insert_values.sql.txt +++ b/testdata/result/dml/insert_values.sql.txt @@ -4,9 +4,7 @@ values (1, 2, 3), (4, 5, 6) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", @@ -37,7 +35,6 @@ values (1, 2, 3), Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 35, ValueEnd: 36, @@ -47,7 +44,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 38, ValueEnd: 39, @@ -57,7 +53,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 41, ValueEnd: 42, @@ -73,7 +68,6 @@ values (1, 2, 3), Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 53, ValueEnd: 54, @@ -83,7 +77,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 56, ValueEnd: 57, @@ -93,7 +86,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 59, ValueEnd: 60, @@ -105,7 +97,6 @@ values (1, 2, 3), }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/insert_values_default.sql.txt b/testdata/result/dml/insert_values_default.sql.txt index 2b3b0083..b379cda6 100644 --- a/testdata/result/dml/insert_values_default.sql.txt +++ b/testdata/result/dml/insert_values_default.sql.txt @@ -3,9 +3,7 @@ insert foo (foo, bar) values (1, default) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", @@ -31,7 +29,6 @@ values (1, default) Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 30, ValueEnd: 31, @@ -42,13 +39,11 @@ values (1, default) &ast.DefaultExpr{ DefaultPos: 33, Default: true, - Expr: nil, }, }, }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/insert_with_sequence_function.sql.txt b/testdata/result/dml/insert_with_sequence_function.sql.txt index c78a7cd4..0183ca51 100644 --- a/testdata/result/dml/insert_with_sequence_function.sql.txt +++ b/testdata/result/dml/insert_with_sequence_function.sql.txt @@ -3,9 +3,7 @@ INSERT INTO foo(bar) VALUES (GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence)) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 12, NameEnd: 15, Name: "foo", @@ -26,7 +24,6 @@ INSERT INTO foo(bar) VALUES (GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence)) Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.CallExpr{ Rparen: 73, Func: &ast.Ident{ @@ -34,8 +31,7 @@ INSERT INTO foo(bar) VALUES (GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence)) NameEnd: 52, Name: "GET_NEXT_SEQUENCE_VALUE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.SequenceArg{ Sequence: 53, Expr: &ast.Ident{ @@ -45,16 +41,12 @@ INSERT INTO foo(bar) VALUES (GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence)) }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, }, }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/update.sql.txt b/testdata/result/dml/update.sql.txt index fcf32946..e9e63cb1 100644 --- a/testdata/result/dml/update.sql.txt +++ b/testdata/result/dml/update.sql.txt @@ -2,13 +2,11 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 --- AST &ast.Update{ - Update: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", }, - As: (*ast.AsAlias)(nil), Updates: []*ast.UpdateItem{ &ast.UpdateItem{ Path: []*ast.Ident{ @@ -20,7 +18,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.Ident{ NamePos: 21, NameEnd: 24, @@ -38,7 +35,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.Ident{ NamePos: 32, NameEnd: 35, @@ -57,7 +53,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 DefaultExpr: &ast.DefaultExpr{ DefaultPos: 43, Default: true, - Expr: nil, }, }, }, @@ -78,7 +73,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/update_as.sql.txt b/testdata/result/dml/update_as.sql.txt index 00622578..002e9210 100644 --- a/testdata/result/dml/update_as.sql.txt +++ b/testdata/result/dml/update_as.sql.txt @@ -2,7 +2,6 @@ update foo as F set F.foo = F.bar + 1 where foo = F.bar --- AST &ast.Update{ - Update: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, @@ -32,7 +31,6 @@ update foo as F set F.foo = F.bar + 1 where foo = F.bar }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.BinaryExpr{ Op: "+", Left: &ast.Path{ @@ -84,7 +82,6 @@ update foo as F set F.foo = F.bar + 1 where foo = F.bar }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/dml/update_then_return_with_action.sql.txt b/testdata/result/dml/update_then_return_with_action.sql.txt index 438a476f..bfaba0eb 100644 --- a/testdata/result/dml/update_then_return_with_action.sql.txt +++ b/testdata/result/dml/update_then_return_with_action.sql.txt @@ -2,13 +2,11 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return with action * --- AST &ast.Update{ - Update: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", }, - As: (*ast.AsAlias)(nil), Updates: []*ast.UpdateItem{ &ast.UpdateItem{ Path: []*ast.Ident{ @@ -20,7 +18,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return wit }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.Ident{ NamePos: 21, NameEnd: 24, @@ -38,7 +35,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return wit }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.Ident{ NamePos: 32, NameEnd: 35, @@ -57,7 +53,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return wit DefaultExpr: &ast.DefaultExpr{ DefaultPos: 43, Default: true, - Expr: nil, }, }, }, @@ -83,7 +78,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return wit WithAction: &ast.WithAction{ With: 77, Action: 82, - Alias: (*ast.AsAlias)(nil), }, Items: []ast.SelectItem{ &ast.Star{ diff --git a/testdata/result/dml/update_with_safe_ml_predict.sql.txt b/testdata/result/dml/update_with_safe_ml_predict.sql.txt new file mode 100644 index 00000000..423cf296 --- /dev/null +++ b/testdata/result/dml/update_with_safe_ml_predict.sql.txt @@ -0,0 +1,205 @@ +--- update_with_safe_ml_predict.sql +-- https://cloud.google.com/spanner/docs/backfill-embeddings?hl=en#backfill +UPDATE products +SET + products.desc_embed = ( + SELECT embeddings.values + FROM SAFE.ML.PREDICT( + MODEL gecko_model, + (SELECT products.description AS content) + ) @{remote_udf_max_rows_per_rpc=200} + ), + products.desc_embed_model_version = 3 +WHERE products.desc_embed IS NULL +--- AST +&ast.Update{ + Update: 76, + TableName: &ast.Ident{ + NamePos: 83, + NameEnd: 91, + Name: "products", + }, + Updates: []*ast.UpdateItem{ + &ast.UpdateItem{ + Path: []*ast.Ident{ + &ast.Ident{ + NamePos: 100, + NameEnd: 108, + Name: "products", + }, + &ast.Ident{ + NamePos: 109, + NameEnd: 119, + Name: "desc_embed", + }, + }, + DefaultExpr: &ast.DefaultExpr{ + DefaultPos: -1, + Expr: &ast.ScalarSubQuery{ + Lparen: 122, + Rparen: 333, + Query: &ast.Select{ + Select: 132, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 139, + NameEnd: 149, + Name: "embeddings", + }, + &ast.Ident{ + NamePos: 150, + NameEnd: 156, + Name: "values", + }, + }, + }, + }, + }, + From: &ast.From{ + From: 165, + Source: &ast.TVFCallExpr{ + Rparen: 292, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 170, + NameEnd: 174, + Name: "SAFE", + }, + &ast.Ident{ + NamePos: 175, + NameEnd: 177, + Name: "ML", + }, + &ast.Ident{ + NamePos: 178, + NameEnd: 185, + Name: "PREDICT", + }, + }, + }, + Args: []ast.TVFArg{ + &ast.ModelArg{ + Model: 203, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 209, + NameEnd: 220, + Name: "gecko_model", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.ScalarSubQuery{ + Lparen: 238, + Rparen: 277, + Query: &ast.Select{ + Select: 239, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 246, + NameEnd: 254, + Name: "products", + }, + &ast.Ident{ + NamePos: 255, + NameEnd: 266, + Name: "description", + }, + }, + }, + As: &ast.AsAlias{ + As: 267, + Alias: &ast.Ident{ + NamePos: 270, + NameEnd: 277, + Name: "content", + }, + }, + }, + }, + }, + }, + }, + }, + Hint: &ast.Hint{ + Atmark: 294, + Rbrace: 327, + Records: []*ast.HintRecord{ + &ast.HintRecord{ + Key: &ast.Ident{ + NamePos: 296, + NameEnd: 323, + Name: "remote_udf_max_rows_per_rpc", + }, + Value: &ast.IntLiteral{ + ValuePos: 324, + ValueEnd: 327, + Base: 10, + Value: "200", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + &ast.UpdateItem{ + Path: []*ast.Ident{ + &ast.Ident{ + NamePos: 340, + NameEnd: 348, + Name: "products", + }, + &ast.Ident{ + NamePos: 349, + NameEnd: 373, + Name: "desc_embed_model_version", + }, + }, + DefaultExpr: &ast.DefaultExpr{ + DefaultPos: -1, + Expr: &ast.IntLiteral{ + ValuePos: 376, + ValueEnd: 377, + Base: 10, + Value: "3", + }, + }, + }, + }, + Where: &ast.Where{ + Where: 378, + Expr: &ast.IsNullExpr{ + Null: 407, + Left: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 384, + NameEnd: 392, + Name: "products", + }, + &ast.Ident{ + NamePos: 393, + NameEnd: 403, + Name: "desc_embed", + }, + }, + }, + }, + }, +} + +--- SQL +UPDATE products SET products.desc_embed = (SELECT embeddings.values FROM SAFE.ML.PREDICT(MODEL gecko_model, (SELECT products.description AS content)) @{remote_udf_max_rows_per_rpc=200}), products.desc_embed_model_version = 3 WHERE products.desc_embed IS NULL diff --git a/testdata/result/expr/array_functions_array_filter_one_arg_with_paren_lambda.sql.txt b/testdata/result/expr/array_functions_array_filter_one_arg_with_paren_lambda.sql.txt index a2037132..54b635c4 100644 --- a/testdata/result/expr/array_functions_array_filter_one_arg_with_paren_lambda.sql.txt +++ b/testdata/result/expr/array_functions_array_filter_one_arg_with_paren_lambda.sql.txt @@ -4,18 +4,15 @@ ARRAY_FILTER([1 ,2, 3], (e) -> e > 1) &ast.CallExpr{ Rparen: 36, Func: &ast.Ident{ - NamePos: 0, NameEnd: 12, Name: "ARRAY_FILTER", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 13, Rbrack: 21, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 14, @@ -63,9 +60,6 @@ ARRAY_FILTER([1 ,2, 3], (e) -> e > 1) }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, } --- SQL diff --git a/testdata/result/expr/array_functions_array_filter_parenless_lambda.sql.txt b/testdata/result/expr/array_functions_array_filter_parenless_lambda.sql.txt index 982a7bab..b03a4a55 100644 --- a/testdata/result/expr/array_functions_array_filter_parenless_lambda.sql.txt +++ b/testdata/result/expr/array_functions_array_filter_parenless_lambda.sql.txt @@ -4,18 +4,15 @@ ARRAY_FILTER([1 ,2, 3], e -> e > 1) &ast.CallExpr{ Rparen: 34, Func: &ast.Ident{ - NamePos: 0, NameEnd: 12, Name: "ARRAY_FILTER", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 13, Rbrack: 21, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 14, @@ -63,9 +60,6 @@ ARRAY_FILTER([1 ,2, 3], e -> e > 1) }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, } --- SQL diff --git a/testdata/result/expr/array_functions_array_filter_two_args_lambda.sql.txt b/testdata/result/expr/array_functions_array_filter_two_args_lambda.sql.txt index 7d83c243..4f8bafb8 100644 --- a/testdata/result/expr/array_functions_array_filter_two_args_lambda.sql.txt +++ b/testdata/result/expr/array_functions_array_filter_two_args_lambda.sql.txt @@ -4,18 +4,15 @@ ARRAY_FILTER([0, 2, 3], (e, i) -> e > i) &ast.CallExpr{ Rparen: 39, Func: &ast.Ident{ - NamePos: 0, NameEnd: 12, Name: "ARRAY_FILTER", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 13, Rbrack: 21, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 14, @@ -67,9 +64,6 @@ ARRAY_FILTER([0, 2, 3], (e, i) -> e > i) }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, } --- SQL diff --git a/testdata/result/expr/array_literal_empty_with_types.sql.txt b/testdata/result/expr/array_literal_empty_with_types.sql.txt index 4936cbb1..8497da9f 100644 --- a/testdata/result/expr/array_literal_empty_with_types.sql.txt +++ b/testdata/result/expr/array_literal_empty_with_types.sql.txt @@ -2,14 +2,12 @@ ARRAY[] --- AST &ast.ArrayLiteral{ - Array: 0, Lbrack: 12, Rbrack: 13, Type: &ast.SimpleType{ NamePos: 6, Name: "INT64", }, - Values: []ast.Expr(nil), } --- SQL diff --git a/testdata/result/expr/array_literal_empty_without_array_keyword.sql.txt b/testdata/result/expr/array_literal_empty_without_array_keyword.sql.txt index 5f368857..f29481f3 100644 --- a/testdata/result/expr/array_literal_empty_without_array_keyword.sql.txt +++ b/testdata/result/expr/array_literal_empty_without_array_keyword.sql.txt @@ -3,10 +3,7 @@ --- AST &ast.ArrayLiteral{ Array: -1, - Lbrack: 0, Rbrack: 1, - Type: nil, - Values: []ast.Expr(nil), } --- SQL diff --git a/testdata/result/expr/array_literal_empty_without_types.sql.txt b/testdata/result/expr/array_literal_empty_without_types.sql.txt index 84ecb55d..e1aa12f9 100644 --- a/testdata/result/expr/array_literal_empty_without_types.sql.txt +++ b/testdata/result/expr/array_literal_empty_without_types.sql.txt @@ -2,11 +2,8 @@ ARRAY[] --- AST &ast.ArrayLiteral{ - Array: 0, Lbrack: 5, Rbrack: 6, - Type: nil, - Values: []ast.Expr(nil), } --- SQL diff --git a/testdata/result/expr/braced_new_constructor.sql.txt b/testdata/result/expr/braced_new_constructor.sql.txt index 18d206e3..99b23294 100644 --- a/testdata/result/expr/braced_new_constructor.sql.txt +++ b/testdata/result/expr/braced_new_constructor.sql.txt @@ -59,7 +59,6 @@ NEW Universe { Array: -1, Lbrack: 148, Rbrack: 177, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 149, @@ -137,7 +136,6 @@ NEW Universe { Array: -1, Lbrack: 255, Rbrack: 332, - Type: nil, Values: []ast.Expr{ &ast.BracedConstructor{ Lbrace: 256, @@ -229,10 +227,8 @@ NEW Universe { Lparen: 349, Rparen: 378, Query: &ast.Select{ - Select: 350, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 350, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 357, @@ -249,16 +245,8 @@ NEW Universe { NameEnd: 378, Name: "SolTable", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, diff --git a/testdata/result/expr/braced_new_constructor_empty.sql.txt b/testdata/result/expr/braced_new_constructor_empty.sql.txt index 60878f90..9e845e6b 100644 --- a/testdata/result/expr/braced_new_constructor_empty.sql.txt +++ b/testdata/result/expr/braced_new_constructor_empty.sql.txt @@ -2,7 +2,6 @@ NEW Universe {} --- AST &ast.BracedNewConstructor{ - New: 0, Type: &ast.NamedType{ Path: []*ast.Ident{ &ast.Ident{ @@ -15,7 +14,6 @@ NEW Universe {} Body: &ast.BracedConstructor{ Lbrace: 13, Rbrace: 14, - Fields: []*ast.BracedConstructorField(nil), }, } diff --git a/testdata/result/expr/braced_new_constructor_oneliner.sql.txt b/testdata/result/expr/braced_new_constructor_oneliner.sql.txt index cc34fbeb..f0051def 100644 --- a/testdata/result/expr/braced_new_constructor_oneliner.sql.txt +++ b/testdata/result/expr/braced_new_constructor_oneliner.sql.txt @@ -2,7 +2,6 @@ NEW Universe {name: "Sol", closest_planets: ["Mercury", "Venus", "Earth" ]} --- AST &ast.BracedNewConstructor{ - New: 0, Type: &ast.NamedType{ Path: []*ast.Ident{ &ast.Ident{ @@ -43,7 +42,6 @@ NEW Universe {name: "Sol", closest_planets: ["Mercury", "Venus", "Earth" ]} Array: -1, Lbrack: 44, Rbrack: 73, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 45, diff --git a/testdata/result/expr/cast_as_typename.sql.txt b/testdata/result/expr/cast_as_typename.sql.txt index 3edb8beb..6f45397d 100644 --- a/testdata/result/expr/cast_as_typename.sql.txt +++ b/testdata/result/expr/cast_as_typename.sql.txt @@ -2,9 +2,7 @@ CAST('order_number: "123"' AS examples.shipping.`Order`) --- AST &ast.CastExpr{ - Cast: 0, Rparen: 55, - Safe: false, Expr: &ast.StringLiteral{ ValuePos: 5, ValueEnd: 26, diff --git a/testdata/result/expr/conversion_functions_safe_cast.sql.txt b/testdata/result/expr/conversion_functions_safe_cast.sql.txt index 8f9d1cb4..196c5201 100644 --- a/testdata/result/expr/conversion_functions_safe_cast.sql.txt +++ b/testdata/result/expr/conversion_functions_safe_cast.sql.txt @@ -2,7 +2,6 @@ SAFE_CAST("apple" AS INT64) --- AST &ast.CastExpr{ - Cast: 0, Rparen: 26, Safe: true, Expr: &ast.StringLiteral{ diff --git a/testdata/result/expr/edge_case_backquote_keyword.sql.txt b/testdata/result/expr/edge_case_backquote_keyword.sql.txt index 36e1fe1a..aaaa1ade 100644 --- a/testdata/result/expr/edge_case_backquote_keyword.sql.txt +++ b/testdata/result/expr/edge_case_backquote_keyword.sql.txt @@ -4,7 +4,6 @@ &ast.BinaryExpr{ Op: "+", Left: &ast.Ident{ - NamePos: 0, NameEnd: 4, Name: "IF", }, diff --git a/testdata/result/expr/edge_case_backquote_non_keyword.sql.txt b/testdata/result/expr/edge_case_backquote_non_keyword.sql.txt index beda1a6f..d512ba23 100644 --- a/testdata/result/expr/edge_case_backquote_non_keyword.sql.txt +++ b/testdata/result/expr/edge_case_backquote_non_keyword.sql.txt @@ -4,7 +4,6 @@ &ast.BinaryExpr{ Op: "+", Left: &ast.Ident{ - NamePos: 0, NameEnd: 10, Name: "DATABASE", }, diff --git a/testdata/result/expr/json_literal.sql.txt b/testdata/result/expr/json_literal.sql.txt index 6d4efa7d..6e358b4a 100644 --- a/testdata/result/expr/json_literal.sql.txt +++ b/testdata/result/expr/json_literal.sql.txt @@ -2,7 +2,6 @@ JSON '{"s": "foo", "n": 42}' --- AST &ast.JSONLiteral{ - JSON: 0, Value: &ast.StringLiteral{ ValuePos: 5, ValueEnd: 28, diff --git a/testdata/result/expr/new_constructor.sql.txt b/testdata/result/expr/new_constructor.sql.txt index 63cb5d39..734af855 100644 --- a/testdata/result/expr/new_constructor.sql.txt +++ b/testdata/result/expr/new_constructor.sql.txt @@ -2,7 +2,6 @@ NEW googlesql.examples.music.Chart(key AS rank, name AS chart_name) --- AST &ast.NewConstructor{ - New: 0, Type: &ast.NamedType{ Path: []*ast.Ident{ &ast.Ident{ diff --git a/testdata/result/expr/new_constructor_empty.sql.txt b/testdata/result/expr/new_constructor_empty.sql.txt index 805f975b..92267457 100644 --- a/testdata/result/expr/new_constructor_empty.sql.txt +++ b/testdata/result/expr/new_constructor_empty.sql.txt @@ -3,7 +3,6 @@ NEW googlesql.examples.music.Chart() --- AST &ast.NewConstructor{ - New: 0, Type: &ast.NamedType{ Path: []*ast.Ident{ &ast.Ident{ @@ -28,7 +27,6 @@ NEW googlesql.examples.music.Chart() }, }, }, - Args: []ast.NewConstructorArg(nil), Rparen: 35, } diff --git a/testdata/result/expr/protocol_buffer_functions_replace_fields.sql.txt b/testdata/result/expr/protocol_buffer_functions_replace_fields.sql.txt index 5587e16a..1a9e277a 100644 --- a/testdata/result/expr/protocol_buffer_functions_replace_fields.sql.txt +++ b/testdata/result/expr/protocol_buffer_functions_replace_fields.sql.txt @@ -7,9 +7,8 @@ REPLACE_FIELDS( 11 AS details.chapters) --- AST &ast.ReplaceFieldsExpr{ - ReplaceFields: 0, - Rparen: 166, - Expr: &ast.NewConstructor{ + Rparen: 166, + Expr: &ast.NewConstructor{ New: 18, Type: &ast.NamedType{ Path: []*ast.Ident{ diff --git a/testdata/result/expr/value_subquery_select_as_fqn_typename.sql.txt b/testdata/result/expr/value_subquery_select_as_fqn_typename.sql.txt index 73aed2a3..26c81619 100644 --- a/testdata/result/expr/value_subquery_select_as_fqn_typename.sql.txt +++ b/testdata/result/expr/value_subquery_select_as_fqn_typename.sql.txt @@ -2,12 +2,10 @@ (SELECT AS example.TypeName 1 AS i) --- AST &ast.ScalarSubQuery{ - Lparen: 0, Rparen: 34, Query: &ast.Select{ - Select: 1, - Distinct: false, - As: &ast.AsTypeName{ + Select: 1, + As: &ast.AsTypeName{ As: 8, TypeName: &ast.NamedType{ Path: []*ast.Ident{ @@ -42,12 +40,6 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/expr/value_subquery_select_as_leaf_typename.sql.txt b/testdata/result/expr/value_subquery_select_as_leaf_typename.sql.txt index e3aeb50b..b2ad15b2 100644 --- a/testdata/result/expr/value_subquery_select_as_leaf_typename.sql.txt +++ b/testdata/result/expr/value_subquery_select_as_leaf_typename.sql.txt @@ -2,12 +2,10 @@ (SELECT AS TypeName 1 AS i) --- AST &ast.ScalarSubQuery{ - Lparen: 0, Rparen: 26, Query: &ast.Select{ - Select: 1, - Distinct: false, - As: &ast.AsTypeName{ + Select: 1, + As: &ast.AsTypeName{ As: 8, TypeName: &ast.NamedType{ Path: []*ast.Ident{ @@ -37,12 +35,6 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/expr/value_subquery_select_as_struct.sql.txt b/testdata/result/expr/value_subquery_select_as_struct.sql.txt index f543cd53..cb391b73 100644 --- a/testdata/result/expr/value_subquery_select_as_struct.sql.txt +++ b/testdata/result/expr/value_subquery_select_as_struct.sql.txt @@ -3,12 +3,10 @@ --- AST &ast.ScalarSubQuery{ - Lparen: 0, Rparen: 24, Query: &ast.Select{ - Select: 1, - Distinct: false, - As: &ast.AsStruct{ + Select: 1, + As: &ast.AsStruct{ As: 8, Struct: 11, }, @@ -30,12 +28,6 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/expr/value_subquery_select_as_value.sql.txt b/testdata/result/expr/value_subquery_select_as_value.sql.txt index 30b7f508..8a293635 100644 --- a/testdata/result/expr/value_subquery_select_as_value.sql.txt +++ b/testdata/result/expr/value_subquery_select_as_value.sql.txt @@ -2,12 +2,10 @@ (SELECT AS VALUE 1) --- AST &ast.ScalarSubQuery{ - Lparen: 0, Rparen: 18, Query: &ast.Select{ - Select: 1, - Distinct: false, - As: &ast.AsValue{ + Select: 1, + As: &ast.AsValue{ As: 8, Value: 11, }, @@ -21,12 +19,6 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/aggregate_function_calls.sql.txt b/testdata/result/query/aggregate_function_calls.sql.txt index 9e2ad6c2..dc06d262 100644 --- a/testdata/result/query/aggregate_function_calls.sql.txt +++ b/testdata/result/query/aggregate_function_calls.sql.txt @@ -8,13 +8,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.CallExpr{ Rparen: 43, @@ -23,8 +18,7 @@ SELECT NameEnd: 20, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 21, @@ -33,9 +27,7 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: &ast.HavingMax{ + Having: &ast.HavingMax{ Having: 28, Expr: &ast.Ident{ NamePos: 39, @@ -53,8 +45,7 @@ SELECT NameEnd: 59, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 60, @@ -63,9 +54,7 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: &ast.HavingMin{ + Having: &ast.HavingMin{ Having: 67, Expr: &ast.Ident{ NamePos: 78, @@ -83,8 +72,7 @@ SELECT NameEnd: 98, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 99, @@ -93,12 +81,10 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), NullHandling: &ast.IgnoreNulls{ Ignore: 106, Nulls: 113, }, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -109,8 +95,7 @@ SELECT NameEnd: 134, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 135, @@ -119,12 +104,10 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), NullHandling: &ast.RespectNulls{ Respect: 142, Nulls: 150, }, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -135,8 +118,7 @@ SELECT NameEnd: 171, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 172, @@ -145,7 +127,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), NullHandling: &ast.RespectNulls{ Respect: 179, Nulls: 187, @@ -161,12 +142,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/edge_case_dot_star_except.sql.txt b/testdata/result/query/edge_case_dot_star_except.sql.txt new file mode 100644 index 00000000..c4a182e7 --- /dev/null +++ b/testdata/result/query/edge_case_dot_star_except.sql.txt @@ -0,0 +1,101 @@ +--- edge_case_dot_star_except.sql +SELECT (SELECT T.* EXCEPT (s)) AS n FROM (SELECT 1 AS n, "foo" AS s) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.ScalarSubQuery{ + Lparen: 7, + Rparen: 29, + Query: &ast.Select{ + Select: 8, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 17, + Expr: &ast.Ident{ + NamePos: 15, + NameEnd: 16, + Name: "T", + }, + Except: &ast.StarModifierExcept{ + Except: 19, + Rparen: 28, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 27, + NameEnd: 28, + Name: "s", + }, + }, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 31, + Alias: &ast.Ident{ + NamePos: 34, + NameEnd: 35, + Name: "n", + }, + }, + }, + }, + From: &ast.From{ + From: 36, + Source: &ast.SubQueryTableExpr{ + Lparen: 41, + Rparen: 67, + Query: &ast.Select{ + Select: 42, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 49, + ValueEnd: 50, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: 51, + Alias: &ast.Ident{ + NamePos: 54, + NameEnd: 55, + Name: "n", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 57, + ValueEnd: 62, + Value: "foo", + }, + As: &ast.AsAlias{ + As: 63, + Alias: &ast.Ident{ + NamePos: 66, + NameEnd: 67, + Name: "s", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 69, + Alias: &ast.Ident{ + NamePos: 72, + NameEnd: 73, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT (SELECT T.* EXCEPT (s)) AS n FROM (SELECT 1 AS n, "foo" AS s) AS T diff --git a/testdata/result/query/edge_case_dot_star_except_all.sql.txt b/testdata/result/query/edge_case_dot_star_except_all.sql.txt new file mode 100644 index 00000000..43f7a941 --- /dev/null +++ b/testdata/result/query/edge_case_dot_star_except_all.sql.txt @@ -0,0 +1,94 @@ +--- edge_case_dot_star_except_all.sql +SELECT (SELECT T.* EXCEPT ALL SELECT T.*) AS n FROM (SELECT 1 AS n) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.ScalarSubQuery{ + Lparen: 7, + Rparen: 40, + Query: &ast.CompoundQuery{ + Op: "EXCEPT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ + &ast.Select{ + Select: 8, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 17, + Expr: &ast.Ident{ + NamePos: 15, + NameEnd: 16, + Name: "T", + }, + }, + }, + }, + &ast.Select{ + Select: 30, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 39, + Expr: &ast.Ident{ + NamePos: 37, + NameEnd: 38, + Name: "T", + }, + }, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 42, + Alias: &ast.Ident{ + NamePos: 45, + NameEnd: 46, + Name: "n", + }, + }, + }, + }, + From: &ast.From{ + From: 47, + Source: &ast.SubQueryTableExpr{ + Lparen: 52, + Rparen: 66, + Query: &ast.Select{ + Select: 53, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 60, + ValueEnd: 61, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: 62, + Alias: &ast.Ident{ + NamePos: 65, + NameEnd: 66, + Name: "n", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 68, + Alias: &ast.Ident{ + NamePos: 71, + NameEnd: 72, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT (SELECT T.* EXCEPT ALL SELECT T.*) AS n FROM (SELECT 1 AS n) AS T diff --git a/testdata/result/query/edge_case_dot_star_except_distinct.sql.txt b/testdata/result/query/edge_case_dot_star_except_distinct.sql.txt new file mode 100644 index 00000000..fd8ecccc --- /dev/null +++ b/testdata/result/query/edge_case_dot_star_except_distinct.sql.txt @@ -0,0 +1,94 @@ +--- edge_case_dot_star_except_distinct.sql +SELECT (SELECT T.* EXCEPT DISTINCT SELECT T.*) AS n FROM (SELECT 1 AS n) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.ScalarSubQuery{ + Lparen: 7, + Rparen: 45, + Query: &ast.CompoundQuery{ + Op: "EXCEPT", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ + &ast.Select{ + Select: 8, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 17, + Expr: &ast.Ident{ + NamePos: 15, + NameEnd: 16, + Name: "T", + }, + }, + }, + }, + &ast.Select{ + Select: 35, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 44, + Expr: &ast.Ident{ + NamePos: 42, + NameEnd: 43, + Name: "T", + }, + }, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 47, + Alias: &ast.Ident{ + NamePos: 50, + NameEnd: 51, + Name: "n", + }, + }, + }, + }, + From: &ast.From{ + From: 52, + Source: &ast.SubQueryTableExpr{ + Lparen: 57, + Rparen: 71, + Query: &ast.Select{ + Select: 58, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 65, + ValueEnd: 66, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: 67, + Alias: &ast.Ident{ + NamePos: 70, + NameEnd: 71, + Name: "n", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 73, + Alias: &ast.Ident{ + NamePos: 76, + NameEnd: 77, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT (SELECT T.* EXCEPT DISTINCT SELECT T.*) AS n FROM (SELECT 1 AS n) AS T diff --git a/testdata/result/query/from_query.sql.txt b/testdata/result/query/from_query.sql.txt new file mode 100644 index 00000000..4276cf6c --- /dev/null +++ b/testdata/result/query/from_query.sql.txt @@ -0,0 +1,19 @@ +--- from_query.sql +FROM Singers +--- AST +&ast.QueryStatement{ + Query: &ast.FromQuery{ + From: &ast.From{ + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 5, + NameEnd: 12, + Name: "Singers", + }, + }, + }, + }, +} + +--- SQL +FROM Singers diff --git a/testdata/result/query/pipe_cte_from.sql.txt b/testdata/result/query/pipe_cte_from.sql.txt new file mode 100644 index 00000000..337944bc --- /dev/null +++ b/testdata/result/query/pipe_cte_from.sql.txt @@ -0,0 +1,48 @@ +--- pipe_cte_from.sql +WITH cte AS (SELECT 1) +FROM cte +--- AST +&ast.QueryStatement{ + Query: &ast.Query{ + With: &ast.With{ + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 21, + Name: &ast.Ident{ + NamePos: 5, + NameEnd: 8, + Name: "cte", + }, + QueryExpr: &ast.Select{ + Select: 13, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 20, + ValueEnd: 21, + Base: 10, + Value: "1", + }, + }, + }, + }, + }, + }, + }, + Query: &ast.FromQuery{ + From: &ast.From{ + From: 23, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 28, + NameEnd: 31, + Name: "cte", + }, + }, + }, + }, + }, +} + +--- SQL +WITH cte AS (SELECT 1) FROM cte diff --git a/testdata/result/query/pipe_from_select_all.sql.txt b/testdata/result/query/pipe_from_select_all.sql.txt new file mode 100644 index 00000000..c4834e43 --- /dev/null +++ b/testdata/result/query/pipe_from_select_all.sql.txt @@ -0,0 +1,33 @@ +--- pipe_from_select_all.sql +FROM Singers +|> SELECT ALL * +--- AST +&ast.QueryStatement{ + Query: &ast.Query{ + Query: &ast.FromQuery{ + From: &ast.From{ + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 5, + NameEnd: 12, + Name: "Singers", + }, + }, + }, + }, + PipeOperators: []ast.PipeOperator{ + &ast.PipeSelect{ + Pipe: 13, + AllOrDistinct: "ALL", + Results: []ast.SelectItem{ + &ast.Star{ + Star: 27, + }, + }, + }, + }, + }, +} + +--- SQL +FROM Singers |> SELECT ALL * diff --git a/testdata/result/query/pipe_from_where_select_distinct.sql.txt b/testdata/result/query/pipe_from_where_select_distinct.sql.txt new file mode 100644 index 00000000..d3572d6b --- /dev/null +++ b/testdata/result/query/pipe_from_where_select_distinct.sql.txt @@ -0,0 +1,50 @@ +--- pipe_from_where_select_distinct.sql +FROM Singers +|> WHERE FirstName = "John" +|> SELECT DISTINCT * +--- AST +&ast.QueryStatement{ + Query: &ast.Query{ + Query: &ast.FromQuery{ + From: &ast.From{ + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 5, + NameEnd: 12, + Name: "Singers", + }, + }, + }, + }, + PipeOperators: []ast.PipeOperator{ + &ast.PipeWhere{ + Pipe: 13, + Expr: &ast.BinaryExpr{ + Op: "=", + Left: &ast.Ident{ + NamePos: 22, + NameEnd: 31, + Name: "FirstName", + }, + Right: &ast.StringLiteral{ + ValuePos: 34, + ValueEnd: 40, + Value: "John", + }, + }, + }, + &ast.PipeSelect{ + Pipe: 41, + AllOrDistinct: "DISTINCT", + Results: []ast.SelectItem{ + &ast.Star{ + Star: 60, + }, + }, + }, + }, + }, +} + +--- SQL +FROM Singers |> WHERE FirstName = "John" |> SELECT DISTINCT * diff --git a/testdata/result/query/select_album_with_index_directive.sql.txt b/testdata/result/query/select_album_with_index_directive.sql.txt index d919f75e..9e4e6986 100644 --- a/testdata/result/query/select_album_with_index_directive.sql.txt +++ b/testdata/result/query/select_album_with_index_directive.sql.txt @@ -5,13 +5,8 @@ WHERE AlbumTitle >= @startTitle AND AlbumTitle < @endTitle --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 7, @@ -60,8 +55,6 @@ WHERE AlbumTitle >= @startTitle AND AlbumTitle < @endTitle }, }, }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -94,10 +87,6 @@ WHERE AlbumTitle >= @startTitle AND AlbumTitle < @endTitle }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_alias_without_as.sql.txt b/testdata/result/query/select_alias_without_as.sql.txt index c4604a96..2c446b42 100644 --- a/testdata/result/query/select_alias_without_as.sql.txt +++ b/testdata/result/query/select_alias_without_as.sql.txt @@ -3,13 +3,8 @@ select 1 A --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.IntLiteral{ ValuePos: 7, @@ -27,12 +22,6 @@ select 1 A }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_array_with_struct.sql.txt b/testdata/result/query/select_array_with_struct.sql.txt index 32f645d4..752145e7 100644 --- a/testdata/result/query/select_array_with_struct.sql.txt +++ b/testdata/result/query/select_array_with_struct.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -91,17 +86,8 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_call_with_named_expr.sql.txt b/testdata/result/query/select_call_with_named_expr.sql.txt index bae8b868..11f82c13 100644 --- a/testdata/result/query/select_call_with_named_expr.sql.txt +++ b/testdata/result/query/select_call_with_named_expr.sql.txt @@ -4,13 +4,8 @@ FROM Albums a WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_query => TRUE) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -52,8 +47,7 @@ WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_q NameEnd: 43, Name: "Albums", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 44, @@ -61,7 +55,6 @@ WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_q Name: "a", }, }, - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -98,8 +91,7 @@ WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_q NameEnd: 77, Name: "SEARCH", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -137,15 +129,9 @@ WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_q }, }, }, - NullHandling: nil, - Having: nil, }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_cast.sql.txt b/testdata/result/query/select_cast.sql.txt index 84154e99..db776822 100644 --- a/testdata/result/query/select_cast.sql.txt +++ b/testdata/result/query/select_cast.sql.txt @@ -7,156 +7,145 @@ limit cast(1 as INT64) offset cast(@foo as INT64) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.CastExpr{ - Cast: 7, - Rparen: 22, - Safe: false, - Expr: &ast.IntLiteral{ - ValuePos: 12, - ValueEnd: 13, - Base: 10, - Value: "1", - }, - Type: &ast.SimpleType{ - NamePos: 17, - Name: "INT64", + Query: &ast.Query{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.CastExpr{ + Cast: 7, + Rparen: 22, + Expr: &ast.IntLiteral{ + ValuePos: 12, + ValueEnd: 13, + Base: 10, + Value: "1", + }, + Type: &ast.SimpleType{ + NamePos: 17, + Name: "INT64", + }, }, }, - }, - &ast.ExprSelectItem{ - Expr: &ast.CastExpr{ - Cast: 25, - Rparen: 44, - Safe: false, - Expr: &ast.FloatLiteral{ - ValuePos: 30, - ValueEnd: 33, - Value: "0.1", - }, - Type: &ast.SimpleType{ - NamePos: 37, - Name: "FLOAT32", + &ast.ExprSelectItem{ + Expr: &ast.CastExpr{ + Cast: 25, + Rparen: 44, + Expr: &ast.FloatLiteral{ + ValuePos: 30, + ValueEnd: 33, + Value: "0.1", + }, + Type: &ast.SimpleType{ + NamePos: 37, + Name: "FLOAT32", + }, }, }, - }, - &ast.ExprSelectItem{ - Expr: &ast.CastExpr{ - Cast: 47, - Rparen: 147, - Safe: false, - Expr: &ast.TupleStructLiteral{ - Lparen: 52, - Rparen: 84, - Values: []ast.Expr{ - &ast.TypelessStructLiteral{ - Struct: 53, - Rparen: 60, - Values: []ast.TypelessStructLiteralArg(nil), - }, - &ast.IntLiteral{ - ValuePos: 63, - ValueEnd: 64, - Base: 10, - Value: "1", - }, - &ast.ArrayLiteral{ - Array: -1, - Lbrack: 66, - Rbrack: 71, - Type: nil, - Values: []ast.Expr{ - &ast.IntLiteral{ - ValuePos: 67, - ValueEnd: 68, - Base: 10, - Value: "2", - }, - &ast.IntLiteral{ - ValuePos: 70, - ValueEnd: 71, - Base: 10, - Value: "3", - }, + &ast.ExprSelectItem{ + Expr: &ast.CastExpr{ + Cast: 47, + Rparen: 147, + Expr: &ast.TupleStructLiteral{ + Lparen: 52, + Rparen: 84, + Values: []ast.Expr{ + &ast.TypelessStructLiteral{ + Struct: 53, + Rparen: 60, }, - }, - &ast.ArrayLiteral{ - Array: -1, - Lbrack: 74, - Rbrack: 83, - Type: nil, - Values: []ast.Expr{ - &ast.StringLiteral{ - ValuePos: 75, - ValueEnd: 78, - Value: "4", + &ast.IntLiteral{ + ValuePos: 63, + ValueEnd: 64, + Base: 10, + Value: "1", + }, + &ast.ArrayLiteral{ + Array: -1, + Lbrack: 66, + Rbrack: 71, + Values: []ast.Expr{ + &ast.IntLiteral{ + ValuePos: 67, + ValueEnd: 68, + Base: 10, + Value: "2", + }, + &ast.IntLiteral{ + ValuePos: 70, + ValueEnd: 71, + Base: 10, + Value: "3", + }, }, - &ast.StringLiteral{ - ValuePos: 80, - ValueEnd: 83, - Value: "5", + }, + &ast.ArrayLiteral{ + Array: -1, + Lbrack: 74, + Rbrack: 83, + Values: []ast.Expr{ + &ast.StringLiteral{ + ValuePos: 75, + ValueEnd: 78, + Value: "4", + }, + &ast.StringLiteral{ + ValuePos: 80, + ValueEnd: 83, + Value: "5", + }, }, }, }, }, - }, - Type: &ast.StructType{ - Struct: 89, - Gt: 146, - Fields: []*ast.StructField{ - &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.StructType{ - Struct: 96, - Gt: 103, - Fields: []*ast.StructField(nil), - }, - }, - &ast.StructField{ - Ident: &ast.Ident{ - NamePos: 106, - NameEnd: 107, - Name: "x", - }, - Type: &ast.SimpleType{ - NamePos: 108, - Name: "INT64", - }, - }, - &ast.StructField{ - Ident: &ast.Ident{ - NamePos: 115, - NameEnd: 116, - Name: "y", + Type: &ast.StructType{ + Struct: 89, + Gt: 146, + Fields: []*ast.StructField{ + &ast.StructField{ + Type: &ast.StructType{ + Struct: 96, + Gt: 103, + }, }, - Type: &ast.ArrayType{ - Array: 117, - Gt: 128, - Item: &ast.SimpleType{ - NamePos: 123, + &ast.StructField{ + Ident: &ast.Ident{ + NamePos: 106, + NameEnd: 107, + Name: "x", + }, + Type: &ast.SimpleType{ + NamePos: 108, Name: "INT64", }, }, - }, - &ast.StructField{ - Ident: &ast.Ident{ - NamePos: 131, - NameEnd: 132, - Name: "z", + &ast.StructField{ + Ident: &ast.Ident{ + NamePos: 115, + NameEnd: 116, + Name: "y", + }, + Type: &ast.ArrayType{ + Array: 117, + Gt: 128, + Item: &ast.SimpleType{ + NamePos: 123, + Name: "INT64", + }, + }, }, - Type: &ast.ArrayType{ - Array: 133, - Gt: 145, - Item: &ast.SimpleType{ - NamePos: 139, - Name: "STRING", + &ast.StructField{ + Ident: &ast.Ident{ + NamePos: 131, + NameEnd: 132, + Name: "z", + }, + Type: &ast.ArrayType{ + Array: 133, + Gt: 145, + Item: &ast.SimpleType{ + NamePos: 139, + Name: "STRING", + }, }, }, }, @@ -164,67 +153,84 @@ limit cast(1 as INT64) offset cast(@foo as INT64) }, }, }, - }, - From: &ast.From{ - From: 149, - Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 154, - NameEnd: 155, - Name: "x", + From: &ast.From{ + From: 149, + Source: &ast.Join{ + Op: ",", + Left: &ast.Join{ + Op: ",", + Left: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 154, + NameEnd: 155, + Name: "x", + }, + Sample: &ast.TableSample{ + TableSample: 156, + Method: "BERNOULLI", + Size: &ast.TableSampleSize{ + Lparen: 178, + Rparen: 207, + Value: &ast.CastNumValue{ + Cast: 179, + Rparen: 198, + Expr: &ast.FloatLiteral{ + ValuePos: 184, + ValueEnd: 187, + Value: "0.1", + }, + Type: "FLOAT64", + }, + Unit: "PERCENT", + }, + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: &ast.TableSample{ - TableSample: 156, - Method: "BERNOULLI", - Size: &ast.TableSampleSize{ - Lparen: 178, - Rparen: 207, - Value: &ast.CastNumValue{ - Cast: 179, - Rparen: 198, - Expr: &ast.FloatLiteral{ - ValuePos: 184, - ValueEnd: 187, - Value: "0.1", + Right: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 215, + NameEnd: 216, + Name: "y", + }, + Sample: &ast.TableSample{ + TableSample: 217, + Method: "BERNOULLI", + Size: &ast.TableSampleSize{ + Lparen: 239, + Rparen: 261, + Value: &ast.CastNumValue{ + Cast: 240, + Rparen: 255, + Expr: &ast.IntLiteral{ + ValuePos: 245, + ValueEnd: 246, + Base: 10, + Value: "1", + }, + Type: "INT64", }, - Type: "FLOAT64", + Unit: "ROWS", }, - Unit: "PERCENT", }, }, }, Right: &ast.TableName{ Table: &ast.Ident{ - NamePos: 215, - NameEnd: 216, - Name: "y", + NamePos: 269, + NameEnd: 270, + Name: "z", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), Sample: &ast.TableSample{ - TableSample: 217, + TableSample: 271, Method: "BERNOULLI", Size: &ast.TableSampleSize{ - Lparen: 239, - Rparen: 261, + Lparen: 293, + Rparen: 320, Value: &ast.CastNumValue{ - Cast: 240, - Rparen: 255, - Expr: &ast.IntLiteral{ - ValuePos: 245, - ValueEnd: 246, - Base: 10, - Value: "1", + Cast: 294, + Rparen: 314, + Expr: &ast.Param{ + Atmark: 299, + Name: "param", }, Type: "INT64", }, @@ -232,43 +238,10 @@ limit cast(1 as INT64) offset cast(@foo as INT64) }, }, }, - Cond: nil, - }, - Right: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 269, - NameEnd: 270, - Name: "z", - }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: &ast.TableSample{ - TableSample: 271, - Method: "BERNOULLI", - Size: &ast.TableSampleSize{ - Lparen: 293, - Rparen: 320, - Value: &ast.CastNumValue{ - Cast: 294, - Rparen: 314, - Expr: &ast.Param{ - Atmark: 299, - Name: "param", - }, - Type: "INT64", - }, - Unit: "ROWS", - }, - }, }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 322, Count: &ast.CastIntValue{ Cast: 328, diff --git a/testdata/result/query/select_complex_with_array_path.sql.txt b/testdata/result/query/select_complex_with_array_path.sql.txt index 2ce3e66a..cbfb49b5 100644 --- a/testdata/result/query/select_complex_with_array_path.sql.txt +++ b/testdata/result/query/select_complex_with_array_path.sql.txt @@ -7,13 +7,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -21,18 +16,13 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: ",", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 30, Name: "ComplexTable", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, Right: &ast.PathTableExpr{ Path: &ast.Path{ @@ -49,19 +39,9 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_complex_with_unnest_array_path.sql.txt b/testdata/result/query/select_complex_with_unnest_array_path.sql.txt index 200e7d61..5008c0b7 100644 --- a/testdata/result/query/select_complex_with_unnest_array_path.sql.txt +++ b/testdata/result/query/select_complex_with_unnest_array_path.sql.txt @@ -7,13 +7,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -21,18 +16,13 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: ",", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 30, Name: "ComplexTable", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, Right: &ast.Unnest{ Unnest: 34, @@ -51,19 +41,9 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_count_asterisk.sql.txt b/testdata/result/query/select_count_asterisk.sql.txt index 5dcbd0b7..92036b3d 100644 --- a/testdata/result/query/select_count_asterisk.sql.txt +++ b/testdata/result/query/select_count_asterisk.sql.txt @@ -3,13 +3,8 @@ select count(*) from singers --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.CountStarExpr{ Count: 7, @@ -25,16 +20,8 @@ select count(*) from singers NameEnd: 28, Name: "singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_count_distinct.sql.txt b/testdata/result/query/select_count_distinct.sql.txt index 76755e4a..f32ac131 100644 --- a/testdata/result/query/select_count_distinct.sql.txt +++ b/testdata/result/query/select_count_distinct.sql.txt @@ -2,13 +2,8 @@ select count(distinct x) from foo --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.CallExpr{ Rparen: 23, @@ -27,9 +22,6 @@ select count(distinct x) from foo }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, }, @@ -41,16 +33,8 @@ select count(distinct x) from foo NameEnd: 33, Name: "foo", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_dot_star.sql.txt b/testdata/result/query/select_dot_star.sql.txt new file mode 100644 index 00000000..584d57e2 --- /dev/null +++ b/testdata/result/query/select_dot_star.sql.txt @@ -0,0 +1,70 @@ +--- select_dot_star.sql +SELECT T.* FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 9, + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 8, + Name: "T", + }, + }, + }, + From: &ast.From{ + From: 11, + Source: &ast.SubQueryTableExpr{ + Lparen: 16, + Rparen: 63, + Query: &ast.Select{ + Select: 17, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 24, + ValueEnd: 31, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 32, + Alias: &ast.Ident{ + NamePos: 35, + NameEnd: 40, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 42, + ValueEnd: 50, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 51, + Alias: &ast.Ident{ + NamePos: 54, + NameEnd: 63, + Name: "vegetable", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: -1, + Alias: &ast.Ident{ + NamePos: 65, + NameEnd: 66, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT T.* FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) T diff --git a/testdata/result/query/select_dot_star_except.sql.txt b/testdata/result/query/select_dot_star_except.sql.txt new file mode 100644 index 00000000..76614ca2 --- /dev/null +++ b/testdata/result/query/select_dot_star_except.sql.txt @@ -0,0 +1,81 @@ +--- select_dot_star_except.sql +SELECT T.* EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 9, + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 8, + Name: "T", + }, + Except: &ast.StarModifierExcept{ + Except: 11, + Rparen: 28, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 19, + NameEnd: 28, + Name: "vegetable", + }, + }, + }, + }, + }, + From: &ast.From{ + From: 30, + Source: &ast.SubQueryTableExpr{ + Lparen: 35, + Rparen: 82, + Query: &ast.Select{ + Select: 36, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 43, + ValueEnd: 50, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 51, + Alias: &ast.Ident{ + NamePos: 54, + NameEnd: 59, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 61, + ValueEnd: 69, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 70, + Alias: &ast.Ident{ + NamePos: 73, + NameEnd: 82, + Name: "vegetable", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 84, + Alias: &ast.Ident{ + NamePos: 87, + NameEnd: 88, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT T.* EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T diff --git a/testdata/result/query/select_dot_star_except_replace.sql.txt b/testdata/result/query/select_dot_star_except_replace.sql.txt new file mode 100644 index 00000000..84bfae1f --- /dev/null +++ b/testdata/result/query/select_dot_star_except_replace.sql.txt @@ -0,0 +1,99 @@ +--- select_dot_star_except_replace.sql +SELECT T.* EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 9, + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 8, + Name: "T", + }, + Except: &ast.StarModifierExcept{ + Except: 11, + Rparen: 28, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 19, + NameEnd: 28, + Name: "vegetable", + }, + }, + }, + Replace: &ast.StarModifierReplace{ + Replace: 30, + Rparen: 56, + Columns: []*ast.StarModifierReplaceItem{ + &ast.StarModifierReplaceItem{ + Expr: &ast.StringLiteral{ + ValuePos: 39, + ValueEnd: 47, + Value: "orange", + }, + Name: &ast.Ident{ + NamePos: 51, + NameEnd: 56, + Name: "fruit", + }, + }, + }, + }, + }, + }, + From: &ast.From{ + From: 58, + Source: &ast.SubQueryTableExpr{ + Lparen: 63, + Rparen: 110, + Query: &ast.Select{ + Select: 64, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 71, + ValueEnd: 78, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 79, + Alias: &ast.Ident{ + NamePos: 82, + NameEnd: 87, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 89, + ValueEnd: 97, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 98, + Alias: &ast.Ident{ + NamePos: 101, + NameEnd: 110, + Name: "vegetable", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 112, + Alias: &ast.Ident{ + NamePos: 115, + NameEnd: 116, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT T.* EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T diff --git a/testdata/result/query/select_dot_star_replace.sql.txt b/testdata/result/query/select_dot_star_replace.sql.txt new file mode 100644 index 00000000..8e21e232 --- /dev/null +++ b/testdata/result/query/select_dot_star_replace.sql.txt @@ -0,0 +1,88 @@ +--- select_dot_star_replace.sql +SELECT T.* REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 9, + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 8, + Name: "T", + }, + Replace: &ast.StarModifierReplace{ + Replace: 11, + Rparen: 37, + Columns: []*ast.StarModifierReplaceItem{ + &ast.StarModifierReplaceItem{ + Expr: &ast.StringLiteral{ + ValuePos: 20, + ValueEnd: 28, + Value: "orange", + }, + Name: &ast.Ident{ + NamePos: 32, + NameEnd: 37, + Name: "fruit", + }, + }, + }, + }, + }, + }, + From: &ast.From{ + From: 39, + Source: &ast.SubQueryTableExpr{ + Lparen: 44, + Rparen: 91, + Query: &ast.Select{ + Select: 45, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 52, + ValueEnd: 59, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 60, + Alias: &ast.Ident{ + NamePos: 63, + NameEnd: 68, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 70, + ValueEnd: 78, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 79, + Alias: &ast.Ident{ + NamePos: 82, + NameEnd: 91, + Name: "vegetable", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 93, + Alias: &ast.Ident{ + NamePos: 96, + NameEnd: 97, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT T.* REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T diff --git a/testdata/result/query/select_expr.sql.txt b/testdata/result/query/select_expr.sql.txt index 21b2ce8d..817c41bf 100644 --- a/testdata/result/query/select_expr.sql.txt +++ b/testdata/result/query/select_expr.sql.txt @@ -31,13 +31,8 @@ select 1 + 2, 1 - 2, --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BinaryExpr{ Op: "+", @@ -328,10 +323,8 @@ select 1 + 2, 1 - 2, Lparen: 194, Rparen: 207, Query: &ast.Select{ - Select: 195, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 195, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.IntLiteral{ ValuePos: 202, @@ -349,12 +342,6 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, Ident: &ast.Ident{ @@ -385,7 +372,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 240, Rbrack: 248, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 241, @@ -427,7 +413,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 269, Rbrack: 277, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 270, @@ -469,7 +454,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 300, Rbrack: 308, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 301, @@ -508,7 +492,6 @@ select 1 + 2, 1 - 2, Expr: &ast.CaseExpr{ Case: 330, EndPos: 403, - Expr: nil, Whens: []*ast.CaseWhen{ &ast.CaseWhen{ When: 342, @@ -602,8 +585,7 @@ select 1 + 2, 1 - 2, NameEnd: 522, Name: "date_add", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.DateLiteral{ Date: 523, @@ -629,9 +611,6 @@ select 1 + 2, 1 - 2, }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -642,8 +621,7 @@ select 1 + 2, 1 - 2, NameEnd: 579, Name: "timestamp_add", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.TimestampLiteral{ Timestamp: 580, @@ -669,14 +647,10 @@ select 1 + 2, 1 - 2, }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ Expr: &ast.InExpr{ - Not: false, Left: &ast.IntLiteral{ ValuePos: 638, ValueEnd: 639, @@ -711,7 +685,6 @@ select 1 + 2, 1 - 2, }, &ast.ExprSelectItem{ Expr: &ast.InExpr{ - Not: false, Left: &ast.IntLiteral{ ValuePos: 661, ValueEnd: 662, @@ -725,7 +698,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 673, Rbrack: 681, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 674, @@ -752,7 +724,6 @@ select 1 + 2, 1 - 2, }, &ast.ExprSelectItem{ Expr: &ast.InExpr{ - Not: false, Left: &ast.IntLiteral{ ValuePos: 692, ValueEnd: 693, @@ -763,14 +734,12 @@ select 1 + 2, 1 - 2, Lparen: 697, Rparen: 744, Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 698, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 698, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 705, @@ -780,18 +749,10 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.Select{ - Select: 717, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 717, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 724, @@ -801,18 +762,10 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.Select{ - Select: 736, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 736, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 743, @@ -822,16 +775,8 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -843,7 +788,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 754, Rbrack: 756, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 755, @@ -857,7 +801,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 761, Rbrack: 763, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 762, @@ -920,12 +863,6 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_expr_extract.sql.txt b/testdata/result/query/select_expr_extract.sql.txt index 3ecdd405..788ea52f 100644 --- a/testdata/result/query/select_expr_extract.sql.txt +++ b/testdata/result/query/select_expr_extract.sql.txt @@ -21,13 +21,8 @@ select --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ExtractExpr{ Extract: 11, @@ -45,7 +40,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -65,7 +59,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -85,7 +78,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -105,7 +97,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -125,7 +116,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -145,7 +135,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -165,7 +154,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -185,7 +173,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -205,7 +192,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -225,7 +211,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -245,7 +230,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -265,7 +249,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -285,7 +268,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -305,7 +287,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -325,7 +306,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -345,7 +325,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -365,7 +344,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -396,12 +374,6 @@ select }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_from_change_stream.sql.txt b/testdata/result/query/select_from_change_stream.sql.txt new file mode 100644 index 00000000..c94185fd --- /dev/null +++ b/testdata/result/query/select_from_change_stream.sql.txt @@ -0,0 +1,86 @@ +--- select_from_change_stream.sql +SELECT ChangeRecord FROM READ_SingersNameStream ( + start_timestamp => "2022-05-01T09:00:00Z", + end_timestamp => NULL, + partition_token => NULL, + heartbeat_milliseconds => 10000 +) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 19, + Name: "ChangeRecord", + }, + }, + }, + From: &ast.From{ + From: 20, + Source: &ast.TVFCallExpr{ + Rparen: 181, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 25, + NameEnd: 47, + Name: "READ_SingersNameStream", + }, + }, + }, + NamedArgs: []*ast.NamedArg{ + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 52, + NameEnd: 67, + Name: "start_timestamp", + }, + Value: &ast.StringLiteral{ + ValuePos: 71, + ValueEnd: 93, + Value: "2022-05-01T09:00:00Z", + }, + }, + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 97, + NameEnd: 110, + Name: "end_timestamp", + }, + Value: &ast.NullLiteral{ + Null: 114, + }, + }, + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 122, + NameEnd: 137, + Name: "partition_token", + }, + Value: &ast.NullLiteral{ + Null: 141, + }, + }, + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 149, + NameEnd: 171, + Name: "heartbeat_milliseconds", + }, + Value: &ast.IntLiteral{ + ValuePos: 175, + ValueEnd: 180, + Base: 10, + Value: "10000", + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT ChangeRecord FROM READ_SingersNameStream(start_timestamp => "2022-05-01T09:00:00Z", end_timestamp => NULL, partition_token => NULL, heartbeat_milliseconds => 10000) diff --git a/testdata/result/query/select_from_implicit_unnest.sql.txt b/testdata/result/query/select_from_implicit_unnest.sql.txt index f1d12b88..06a9e39a 100644 --- a/testdata/result/query/select_from_implicit_unnest.sql.txt +++ b/testdata/result/query/select_from_implicit_unnest.sql.txt @@ -4,13 +4,8 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, t.arr AS a WITH OFFSET AS off --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 7, @@ -29,17 +24,14 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, From: &ast.From{ From: 14, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Unnest{ + Op: ",", + Left: &ast.Unnest{ Unnest: 19, Rparen: 62, Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 26, Rbrack: 61, - Type: nil, Values: []ast.Expr{ &ast.TypedStructLiteral{ Struct: 27, @@ -66,7 +58,6 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, Array: -1, Lbrack: 53, Rbrack: 59, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 54, @@ -79,8 +70,7 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 64, Alias: &ast.Ident{ NamePos: 67, @@ -88,8 +78,6 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, Name: "t", }, }, - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, Right: &ast.PathTableExpr{ Path: &ast.Path{ @@ -106,8 +94,7 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 81, Alias: &ast.Ident{ NamePos: 84, @@ -127,16 +114,9 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, }, }, }, - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_from_ml_predict_hint.sql.txt b/testdata/result/query/select_from_ml_predict_hint.sql.txt new file mode 100644 index 00000000..cc99b9a8 --- /dev/null +++ b/testdata/result/query/select_from_ml_predict_hint.sql.txt @@ -0,0 +1,175 @@ +--- select_from_ml_predict_hint.sql +-- https://cloud.google.com/spanner/docs/ml-tutorial-generative-ai?hl=en#register_a_generative_ai_model_in_a_schema +SELECT content +FROM ML.PREDICT( + MODEL TextBison, + (SELECT "Is 13 prime?" AS prompt), + STRUCT(256 AS maxOutputTokens, 0.2 AS temperature, 40 as topK, 0.95 AS topP) +) @{remote_udf_max_rows_per_rpc=1} +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Select: 116, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 123, + NameEnd: 130, + Name: "content", + }, + }, + }, + From: &ast.From{ + From: 131, + Source: &ast.TVFCallExpr{ + Rparen: 289, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 136, + NameEnd: 138, + Name: "ML", + }, + &ast.Ident{ + NamePos: 139, + NameEnd: 146, + Name: "PREDICT", + }, + }, + }, + Args: []ast.TVFArg{ + &ast.ModelArg{ + Model: 152, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 158, + NameEnd: 167, + Name: "TextBison", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.ScalarSubQuery{ + Lparen: 173, + Rparen: 205, + Query: &ast.Select{ + Select: 174, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 181, + ValueEnd: 195, + Value: "Is 13 prime?", + }, + As: &ast.AsAlias{ + As: 196, + Alias: &ast.Ident{ + NamePos: 199, + NameEnd: 205, + Name: "prompt", + }, + }, + }, + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.TypelessStructLiteral{ + Struct: 212, + Rparen: 287, + Values: []ast.TypelessStructLiteralArg{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 219, + ValueEnd: 222, + Base: 10, + Value: "256", + }, + As: &ast.AsAlias{ + As: 223, + Alias: &ast.Ident{ + NamePos: 226, + NameEnd: 241, + Name: "maxOutputTokens", + }, + }, + }, + &ast.Alias{ + Expr: &ast.FloatLiteral{ + ValuePos: 243, + ValueEnd: 246, + Value: "0.2", + }, + As: &ast.AsAlias{ + As: 247, + Alias: &ast.Ident{ + NamePos: 250, + NameEnd: 261, + Name: "temperature", + }, + }, + }, + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 263, + ValueEnd: 265, + Base: 10, + Value: "40", + }, + As: &ast.AsAlias{ + As: 266, + Alias: &ast.Ident{ + NamePos: 269, + NameEnd: 273, + Name: "topK", + }, + }, + }, + &ast.Alias{ + Expr: &ast.FloatLiteral{ + ValuePos: 275, + ValueEnd: 279, + Value: "0.95", + }, + As: &ast.AsAlias{ + As: 280, + Alias: &ast.Ident{ + NamePos: 283, + NameEnd: 287, + Name: "topP", + }, + }, + }, + }, + }, + }, + }, + Hint: &ast.Hint{ + Atmark: 291, + Rbrace: 322, + Records: []*ast.HintRecord{ + &ast.HintRecord{ + Key: &ast.Ident{ + NamePos: 293, + NameEnd: 320, + Name: "remote_udf_max_rows_per_rpc", + }, + Value: &ast.IntLiteral{ + ValuePos: 321, + ValueEnd: 322, + Base: 10, + Value: "1", + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT content FROM ML.PREDICT(MODEL TextBison, (SELECT "Is 13 prime\?" AS prompt), STRUCT(256 AS maxOutputTokens, 0.2 AS temperature, 40 AS topK, 0.95 AS topP)) @{remote_udf_max_rows_per_rpc=1} diff --git a/testdata/result/query/select_from_ml_predict_simple.sql.txt b/testdata/result/query/select_from_ml_predict_simple.sql.txt new file mode 100644 index 00000000..06c7e7df --- /dev/null +++ b/testdata/result/query/select_from_ml_predict_simple.sql.txt @@ -0,0 +1,80 @@ +--- select_from_ml_predict_simple.sql +SELECT id, color, value +FROM ML.PREDICT(MODEL DiamondAppraise, TABLE Diamonds) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 9, + Name: "id", + }, + }, + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 11, + NameEnd: 16, + Name: "color", + }, + }, + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 18, + NameEnd: 23, + Name: "value", + }, + }, + }, + From: &ast.From{ + From: 24, + Source: &ast.TVFCallExpr{ + Rparen: 77, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 29, + NameEnd: 31, + Name: "ML", + }, + &ast.Ident{ + NamePos: 32, + NameEnd: 39, + Name: "PREDICT", + }, + }, + }, + Args: []ast.TVFArg{ + &ast.ModelArg{ + Model: 40, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 46, + NameEnd: 61, + Name: "DiamondAppraise", + }, + }, + }, + }, + &ast.TableArg{ + Table: 63, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 69, + NameEnd: 77, + Name: "Diamonds", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT id, color, value FROM ML.PREDICT(MODEL DiamondAppraise, TABLE Diamonds) diff --git a/testdata/result/query/select_from_ml_predict_textbison.sql.txt b/testdata/result/query/select_from_ml_predict_textbison.sql.txt new file mode 100644 index 00000000..1d267c79 --- /dev/null +++ b/testdata/result/query/select_from_ml_predict_textbison.sql.txt @@ -0,0 +1,370 @@ +--- select_from_ml_predict_textbison.sql +SELECT product_id, product_name, content +FROM ML.PREDICT( + MODEL TextBison, + (SELECT + product.id as product_id, + product.name as product_name, + CONCAT("Is this product safe for infants?", "\n", + "Product Name: ", product.name, "\n", + "Category Name: ", category.name, "\n", + "Product Description:", product.description) AS prompt + FROM + Products AS product JOIN Categories AS category + ON product.category_id = category.id), + STRUCT(100 AS maxOutputTokens) +) @{remote_udf_max_rows_per_rpc=1} +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 17, + Name: "product_id", + }, + }, + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 19, + NameEnd: 31, + Name: "product_name", + }, + }, + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 33, + NameEnd: 40, + Name: "content", + }, + }, + }, + From: &ast.From{ + From: 41, + Source: &ast.TVFCallExpr{ + Rparen: 580, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 46, + NameEnd: 48, + Name: "ML", + }, + &ast.Ident{ + NamePos: 49, + NameEnd: 56, + Name: "PREDICT", + }, + }, + }, + Args: []ast.TVFArg{ + &ast.ModelArg{ + Model: 62, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 68, + NameEnd: 77, + Name: "TextBison", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.ScalarSubQuery{ + Lparen: 83, + Rparen: 542, + Query: &ast.Select{ + Select: 84, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 100, + NameEnd: 107, + Name: "product", + }, + &ast.Ident{ + NamePos: 108, + NameEnd: 110, + Name: "id", + }, + }, + }, + As: &ast.AsAlias{ + As: 111, + Alias: &ast.Ident{ + NamePos: 114, + NameEnd: 124, + Name: "product_id", + }, + }, + }, + &ast.Alias{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 135, + NameEnd: 142, + Name: "product", + }, + &ast.Ident{ + NamePos: 143, + NameEnd: 147, + Name: "name", + }, + }, + }, + As: &ast.AsAlias{ + As: 148, + Alias: &ast.Ident{ + NamePos: 151, + NameEnd: 163, + Name: "product_name", + }, + }, + }, + &ast.Alias{ + Expr: &ast.CallExpr{ + Rparen: 393, + Func: &ast.Ident{ + NamePos: 174, + NameEnd: 180, + Name: "CONCAT", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 181, + ValueEnd: 216, + Value: "Is this product safe for infants?", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 218, + ValueEnd: 222, + Value: "\n", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 240, + ValueEnd: 256, + Value: "Product Name: ", + }, + }, + &ast.ExprArg{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 258, + NameEnd: 265, + Name: "product", + }, + &ast.Ident{ + NamePos: 266, + NameEnd: 270, + Name: "name", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 272, + ValueEnd: 276, + Value: "\n", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 294, + ValueEnd: 311, + Value: "Category Name: ", + }, + }, + &ast.ExprArg{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 313, + NameEnd: 321, + Name: "category", + }, + &ast.Ident{ + NamePos: 322, + NameEnd: 326, + Name: "name", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 328, + ValueEnd: 332, + Value: "\n", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 350, + ValueEnd: 372, + Value: "Product Description:", + }, + }, + &ast.ExprArg{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 374, + NameEnd: 381, + Name: "product", + }, + &ast.Ident{ + NamePos: 382, + NameEnd: 393, + Name: "description", + }, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 395, + Alias: &ast.Ident{ + NamePos: 398, + NameEnd: 404, + Name: "prompt", + }, + }, + }, + }, + From: &ast.From{ + From: 410, + Source: &ast.Join{ + Op: "INNER JOIN", + Left: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 424, + NameEnd: 432, + Name: "Products", + }, + As: &ast.AsAlias{ + As: 433, + Alias: &ast.Ident{ + NamePos: 436, + NameEnd: 443, + Name: "product", + }, + }, + }, + Right: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 449, + NameEnd: 459, + Name: "Categories", + }, + As: &ast.AsAlias{ + As: 460, + Alias: &ast.Ident{ + NamePos: 463, + NameEnd: 471, + Name: "category", + }, + }, + }, + Cond: &ast.On{ + On: 506, + Expr: &ast.BinaryExpr{ + Op: "=", + Left: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 509, + NameEnd: 516, + Name: "product", + }, + &ast.Ident{ + NamePos: 517, + NameEnd: 528, + Name: "category_id", + }, + }, + }, + Right: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 531, + NameEnd: 539, + Name: "category", + }, + &ast.Ident{ + NamePos: 540, + NameEnd: 542, + Name: "id", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.TypelessStructLiteral{ + Struct: 549, + Rparen: 578, + Values: []ast.TypelessStructLiteralArg{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 556, + ValueEnd: 559, + Base: 10, + Value: "100", + }, + As: &ast.AsAlias{ + As: 560, + Alias: &ast.Ident{ + NamePos: 563, + NameEnd: 578, + Name: "maxOutputTokens", + }, + }, + }, + }, + }, + }, + }, + Hint: &ast.Hint{ + Atmark: 582, + Rbrace: 613, + Records: []*ast.HintRecord{ + &ast.HintRecord{ + Key: &ast.Ident{ + NamePos: 584, + NameEnd: 611, + Name: "remote_udf_max_rows_per_rpc", + }, + Value: &ast.IntLiteral{ + ValuePos: 612, + ValueEnd: 613, + Base: 10, + Value: "1", + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT product_id, product_name, content FROM ML.PREDICT(MODEL TextBison, (SELECT product.id AS product_id, product.name AS product_name, CONCAT("Is this product safe for infants\?", "\n", "Product Name: ", product.name, "\n", "Category Name: ", category.name, "\n", "Product Description:", product.description) AS prompt FROM Products AS product INNER JOIN Categories AS category ON product.category_id = category.id), STRUCT(100 AS maxOutputTokens)) @{remote_udf_max_rows_per_rpc=1} diff --git a/testdata/result/query/select_from_path.sql.txt b/testdata/result/query/select_from_path.sql.txt index d58a1d70..d2ce6e21 100644 --- a/testdata/result/query/select_from_path.sql.txt +++ b/testdata/result/query/select_from_path.sql.txt @@ -5,13 +5,8 @@ FROM INFORMATION_SCHEMA.TABLES AS t TABLESAMPLE RESERVOIR (10 ROWS) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -33,8 +28,7 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 44, Alias: &ast.Ident{ NamePos: 47, @@ -42,8 +36,7 @@ FROM Name: "t", }, }, - WithOffset: (*ast.WithOffset)(nil), - Sample: &ast.TableSample{ + Sample: &ast.TableSample{ TableSample: 49, Method: "RESERVOIR", Size: &ast.TableSampleSize{ @@ -60,11 +53,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_function_hints.sql.txt b/testdata/result/query/select_function_hints.sql.txt new file mode 100644 index 00000000..0aeff394 --- /dev/null +++ b/testdata/result/query/select_function_hints.sql.txt @@ -0,0 +1,185 @@ +--- select_function_hints.sql +-- https://cloud.google.com/spanner/docs/reference/standard-sql/functions-reference#function_hints +SELECT + SUBSTRING(CAST(x AS STRING), 2, 5) AS w, + SUBSTRING(CAST(x AS STRING), 3, 7) AS y +FROM (SELECT SHA512(z) @{DISABLE_INLINE = TRUE} AS x FROM t) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Select: 99, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.CallExpr{ + Rparen: 143, + Func: &ast.Ident{ + NamePos: 110, + NameEnd: 119, + Name: "SUBSTRING", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.CastExpr{ + Cast: 120, + Rparen: 136, + Expr: &ast.Ident{ + NamePos: 125, + NameEnd: 126, + Name: "x", + }, + Type: &ast.SimpleType{ + NamePos: 130, + Name: "STRING", + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.IntLiteral{ + ValuePos: 139, + ValueEnd: 140, + Base: 10, + Value: "2", + }, + }, + &ast.ExprArg{ + Expr: &ast.IntLiteral{ + ValuePos: 142, + ValueEnd: 143, + Base: 10, + Value: "5", + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 145, + Alias: &ast.Ident{ + NamePos: 148, + NameEnd: 149, + Name: "w", + }, + }, + }, + &ast.Alias{ + Expr: &ast.CallExpr{ + Rparen: 188, + Func: &ast.Ident{ + NamePos: 155, + NameEnd: 164, + Name: "SUBSTRING", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.CastExpr{ + Cast: 165, + Rparen: 181, + Expr: &ast.Ident{ + NamePos: 170, + NameEnd: 171, + Name: "x", + }, + Type: &ast.SimpleType{ + NamePos: 175, + Name: "STRING", + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.IntLiteral{ + ValuePos: 184, + ValueEnd: 185, + Base: 10, + Value: "3", + }, + }, + &ast.ExprArg{ + Expr: &ast.IntLiteral{ + ValuePos: 187, + ValueEnd: 188, + Base: 10, + Value: "7", + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 190, + Alias: &ast.Ident{ + NamePos: 193, + NameEnd: 194, + Name: "y", + }, + }, + }, + }, + From: &ast.From{ + From: 195, + Source: &ast.SubQueryTableExpr{ + Lparen: 200, + Rparen: 254, + Query: &ast.Select{ + Select: 201, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.CallExpr{ + Rparen: 216, + Func: &ast.Ident{ + NamePos: 208, + NameEnd: 214, + Name: "SHA512", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.Ident{ + NamePos: 215, + NameEnd: 216, + Name: "z", + }, + }, + }, + Hint: &ast.Hint{ + Atmark: 218, + Rbrace: 241, + Records: []*ast.HintRecord{ + &ast.HintRecord{ + Key: &ast.Ident{ + NamePos: 220, + NameEnd: 234, + Name: "DISABLE_INLINE", + }, + Value: &ast.BoolLiteral{ + ValuePos: 237, + Value: true, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 243, + Alias: &ast.Ident{ + NamePos: 246, + NameEnd: 247, + Name: "x", + }, + }, + }, + }, + From: &ast.From{ + From: 248, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 253, + NameEnd: 254, + Name: "t", + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT SUBSTRING(CAST(x AS STRING), 2, 5) AS w, SUBSTRING(CAST(x AS STRING), 3, 7) AS y FROM (SELECT SHA512(z) @{DISABLE_INLINE=TRUE} AS x FROM t) diff --git a/testdata/result/query/select_hint.sql.txt b/testdata/result/query/select_hint.sql.txt index de37c85f..374f27f1 100644 --- a/testdata/result/query/select_hint.sql.txt +++ b/testdata/result/query/select_hint.sql.txt @@ -3,7 +3,6 @@ --- AST &ast.QueryStatement{ Hint: &ast.Hint{ - Atmark: 0, Rbrace: 22, Records: []*ast.HintRecord{ &ast.HintRecord{ @@ -34,12 +33,9 @@ }, }, }, - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 24, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 24, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 31, @@ -48,12 +44,6 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_all.sql.txt b/testdata/result/query/select_literals_all.sql.txt index 17137993..da902945 100644 --- a/testdata/result/query/select_literals_all.sql.txt +++ b/testdata/result/query/select_literals_all.sql.txt @@ -49,13 +49,8 @@ lines''', true, false --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.StringLiteral{ ValuePos: 9, @@ -152,7 +147,7 @@ lines''', ValuePos: 204, ValueEnd: 210, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -161,7 +156,7 @@ lines''', ValuePos: 214, ValueEnd: 224, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -170,7 +165,7 @@ lines''', ValuePos: 228, ValueEnd: 238, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -179,7 +174,7 @@ lines''', ValuePos: 242, ValueEnd: 250, Value: []uint8{ - 0x61, 0x62, 0x63, 0x2b, + 97, 98, 99, 43, }, }, }, @@ -188,7 +183,7 @@ lines''', ValuePos: 254, ValueEnd: 262, Value: []uint8{ - 0x61, 0x62, 0x63, 0x2b, + 97, 98, 99, 43, }, }, }, @@ -197,7 +192,7 @@ lines''', ValuePos: 266, ValueEnd: 277, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -266,7 +261,6 @@ lines''', Array: -1, Lbrack: 352, Rbrack: 360, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 353, @@ -294,7 +288,6 @@ lines''', Array: -1, Lbrack: 365, Rbrack: 380, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 366, @@ -319,7 +312,6 @@ lines''', Array: 385, Lbrack: 390, Rbrack: 398, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 391, @@ -379,7 +371,6 @@ lines''', NamePos: 442, Name: "INT64", }, - Values: []ast.Expr(nil), }, }, &ast.ExprSelectItem{ @@ -387,10 +378,8 @@ lines''', Array: 454, Rparen: 482, Query: &ast.Select{ - Select: 460, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 460, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 467, @@ -424,12 +413,6 @@ lines''', }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -438,10 +421,8 @@ lines''', Array: 487, Rparen: 509, Query: &ast.Select{ - Select: 493, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 493, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TupleStructLiteral{ Lparen: 500, @@ -469,12 +450,6 @@ lines''', }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -496,8 +471,7 @@ lines''', NameEnd: 539, Name: "DATE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 540, @@ -506,9 +480,6 @@ lines''', }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -549,8 +520,7 @@ lines''', NameEnd: 690, Name: "TIMESTAMP", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 691, @@ -559,9 +529,6 @@ lines''', }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -623,16 +590,9 @@ lines''', &ast.ExprSelectItem{ Expr: &ast.BoolLiteral{ ValuePos: 785, - Value: false, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_array.sql.txt b/testdata/result/query/select_literals_array.sql.txt index 5955dc62..24ad47f4 100644 --- a/testdata/result/query/select_literals_array.sql.txt +++ b/testdata/result/query/select_literals_array.sql.txt @@ -8,19 +8,13 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 9, Rbrack: 17, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 10, @@ -48,7 +42,6 @@ SELECT Array: -1, Lbrack: 22, Rbrack: 37, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 23, @@ -73,7 +66,6 @@ SELECT Array: 42, Lbrack: 47, Rbrack: 55, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 48, @@ -133,16 +125,9 @@ SELECT NamePos: 99, Name: "INT64", }, - Values: []ast.Expr(nil), }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_array_invalid.sql.txt b/testdata/result/query/select_literals_array_invalid.sql.txt index 2ffd9a3e..c4c94b67 100644 --- a/testdata/result/query/select_literals_array_invalid.sql.txt +++ b/testdata/result/query/select_literals_array_invalid.sql.txt @@ -4,25 +4,18 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 9, Rbrack: 41, - Type: nil, Values: []ast.Expr{ &ast.ArrayLiteral{ Array: -1, Lbrack: 10, Rbrack: 18, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 11, @@ -48,7 +41,6 @@ SELECT Array: -1, Lbrack: 21, Rbrack: 29, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 22, @@ -74,7 +66,6 @@ SELECT Array: -1, Lbrack: 32, Rbrack: 40, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 33, @@ -100,12 +91,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_bytes.sql.txt b/testdata/result/query/select_literals_bytes.sql.txt index 09b7dbee..498b1214 100644 --- a/testdata/result/query/select_literals_bytes.sql.txt +++ b/testdata/result/query/select_literals_bytes.sql.txt @@ -13,19 +13,14 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BytesLiteral{ ValuePos: 9, ValueEnd: 15, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -34,7 +29,7 @@ SELECT ValuePos: 19, ValueEnd: 29, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -43,7 +38,7 @@ SELECT ValuePos: 33, ValueEnd: 43, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -52,7 +47,7 @@ SELECT ValuePos: 47, ValueEnd: 59, Value: []uint8{ - 0x61, 0x62, 0x63, 0x0a, + 97, 98, 99, 10, }, }, }, @@ -61,7 +56,7 @@ SELECT ValuePos: 63, ValueEnd: 71, Value: []uint8{ - 0x61, 0x62, 0x63, 0x2b, + 97, 98, 99, 43, }, }, }, @@ -70,7 +65,7 @@ SELECT ValuePos: 75, ValueEnd: 83, Value: []uint8{ - 0x61, 0x62, 0x63, 0x2b, + 97, 98, 99, 43, }, }, }, @@ -79,7 +74,7 @@ SELECT ValuePos: 87, ValueEnd: 98, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -88,7 +83,7 @@ SELECT ValuePos: 102, ValueEnd: 115, Value: []uint8{ - 0x61, 0x62, 0x63, 0x5c, 0x6e, + 97, 98, 99, 92, 110, }, }, }, @@ -97,7 +92,7 @@ SELECT ValuePos: 119, ValueEnd: 126, Value: []uint8{ - 0x00, + 0, }, }, }, @@ -106,17 +101,11 @@ SELECT ValuePos: 130, ValueEnd: 145, Value: []uint8{ - 0x3f, 0x3f, 0x3f, + 63, 63, 63, }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_date.sql.txt b/testdata/result/query/select_literals_date.sql.txt index 7d21137b..fafc2985 100644 --- a/testdata/result/query/select_literals_date.sql.txt +++ b/testdata/result/query/select_literals_date.sql.txt @@ -13,13 +13,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.DateLiteral{ Date: 9, @@ -38,8 +33,7 @@ SELECT NameEnd: 33, Name: "DATE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 34, @@ -48,9 +42,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -101,8 +92,7 @@ SELECT NameEnd: 206, Name: "TIMESTAMP", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 207, @@ -111,9 +101,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -134,8 +121,7 @@ SELECT NameEnd: 255, Name: "DATE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 256, @@ -144,9 +130,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, As: &ast.AsAlias{ As: 270, @@ -165,8 +148,7 @@ SELECT NameEnd: 289, Name: "TIMESTAMP", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 290, @@ -175,9 +157,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, As: &ast.AsAlias{ As: 304, @@ -189,12 +168,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_float.sql.txt b/testdata/result/query/select_literals_float.sql.txt index 1f90c1d9..3ccf54f0 100644 --- a/testdata/result/query/select_literals_float.sql.txt +++ b/testdata/result/query/select_literals_float.sql.txt @@ -7,13 +7,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.FloatLiteral{ ValuePos: 9, @@ -43,12 +38,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_int.sql.txt b/testdata/result/query/select_literals_int.sql.txt index 4634fef4..385b2f03 100644 --- a/testdata/result/query/select_literals_int.sql.txt +++ b/testdata/result/query/select_literals_int.sql.txt @@ -7,13 +7,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 9, @@ -47,12 +42,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_paren.sql.txt b/testdata/result/query/select_literals_paren.sql.txt index 34ae9052..5c845ef2 100644 --- a/testdata/result/query/select_literals_paren.sql.txt +++ b/testdata/result/query/select_literals_paren.sql.txt @@ -3,13 +3,8 @@ SELECT (1) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ParenExpr{ Lparen: 7, @@ -23,12 +18,6 @@ SELECT (1) }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_paren_with_operator.sql.txt b/testdata/result/query/select_literals_paren_with_operator.sql.txt index 3efa5f2e..a0c52ced 100644 --- a/testdata/result/query/select_literals_paren_with_operator.sql.txt +++ b/testdata/result/query/select_literals_paren_with_operator.sql.txt @@ -3,13 +3,8 @@ SELECT (1+1) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ParenExpr{ Lparen: 7, @@ -32,12 +27,6 @@ SELECT (1+1) }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_string.sql.txt b/testdata/result/query/select_literals_string.sql.txt index c18ac805..8686fd58 100644 --- a/testdata/result/query/select_literals_string.sql.txt +++ b/testdata/result/query/select_literals_string.sql.txt @@ -25,13 +25,8 @@ lines''', --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.StringLiteral{ ValuePos: 9, @@ -180,12 +175,6 @@ lines''', }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_literals_struct.sql.txt b/testdata/result/query/select_literals_struct.sql.txt index 3b45c25d..656850ee 100644 --- a/testdata/result/query/select_literals_struct.sql.txt +++ b/testdata/result/query/select_literals_struct.sql.txt @@ -18,22 +18,15 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArraySubQuery{ Array: 9, Rparen: 37, Query: &ast.Select{ - Select: 15, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 15, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 22, @@ -67,12 +60,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -81,10 +68,8 @@ SELECT Array: 42, Rparen: 73, Query: &ast.Select{ - Select: 48, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 48, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 55, @@ -116,12 +101,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -130,10 +109,8 @@ SELECT Array: 78, Rparen: 133, Query: &ast.Select{ - Select: 84, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 84, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 91, @@ -196,12 +173,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -210,10 +181,8 @@ SELECT Array: 138, Rparen: 181, Query: &ast.Select{ - Select: 144, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 144, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 151, @@ -271,12 +240,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -285,32 +248,27 @@ SELECT Array: 186, Rparen: 235, Query: &ast.Select{ - Select: 192, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 192, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 199, Rparen: 234, Fields: []*ast.StructField{ &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 206, Name: "INT64", }, }, &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 213, Name: "INT64", }, }, &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 220, Name: "INT64", }, @@ -339,12 +297,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -353,10 +305,8 @@ SELECT Array: 240, Rparen: 291, Query: &ast.Select{ - Select: 246, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 246, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 253, @@ -374,15 +324,13 @@ SELECT }, }, &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 269, Name: "INT64", }, }, &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 276, Name: "INT64", }, @@ -411,12 +359,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -425,10 +367,8 @@ SELECT Array: 296, Rparen: 329, Query: &ast.Select{ - Select: 302, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 302, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 309, @@ -470,12 +410,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -484,10 +418,8 @@ SELECT Array: 334, Rparen: 356, Query: &ast.Select{ - Select: 340, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 340, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TupleStructLiteral{ Lparen: 347, @@ -515,12 +447,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -529,10 +455,8 @@ SELECT Array: 361, Rparen: 392, Query: &ast.Select{ - Select: 367, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 367, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 374, @@ -561,12 +485,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -575,10 +493,8 @@ SELECT Array: 397, Rparen: 424, Query: &ast.Select{ - Select: 403, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 403, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 410, @@ -604,12 +520,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -618,18 +528,15 @@ SELECT Array: 429, Rparen: 458, Query: &ast.Select{ - Select: 435, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 435, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 442, Rparen: 457, Fields: []*ast.StructField{ &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 449, Name: "INT64", }, @@ -646,12 +553,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -660,10 +561,8 @@ SELECT Array: 463, Rparen: 485, Query: &ast.Select{ - Select: 469, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 469, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 476, @@ -681,12 +580,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -695,25 +588,15 @@ SELECT Array: 490, Rparen: 513, Query: &ast.Select{ - Select: 496, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 496, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 503, Rparen: 512, - Fields: []*ast.StructField(nil), - Values: []ast.Expr(nil), }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -722,24 +605,15 @@ SELECT Array: 518, Rparen: 539, Query: &ast.Select{ - Select: 524, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 524, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 531, Rparen: 538, - Values: []ast.TypelessStructLiteralArg(nil), }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -747,12 +621,9 @@ SELECT Expr: &ast.ExistsSubQuery{ Exists: 544, Rparen: 564, - Hint: (*ast.Hint)(nil), Query: &ast.Select{ - Select: 551, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 551, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TupleStructLiteral{ Lparen: 558, @@ -774,22 +645,10 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_nest_complex.sql.txt b/testdata/result/query/select_nest_complex.sql.txt index 81059415..19613b2e 100644 --- a/testdata/result/query/select_nest_complex.sql.txt +++ b/testdata/result/query/select_nest_complex.sql.txt @@ -8,13 +8,8 @@ from ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 7, }, @@ -25,122 +20,87 @@ from ( Lparen: 14, Rparen: 131, Source: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.SubQueryTableExpr{ + Op: "INNER JOIN", + Left: &ast.SubQueryTableExpr{ Lparen: 20, Rparen: 90, - Query: &ast.SubQuery{ - Lparen: 21, - Rparen: 81, - Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: true, - Queries: []ast.QueryExpr{ - &ast.SubQuery{ - Lparen: 22, - Rparen: 54, - Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ - &ast.Select{ - Select: 23, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Alias{ - Expr: &ast.IntLiteral{ - ValuePos: 30, - ValueEnd: 31, - Base: 10, - Value: "1", - }, - As: &ast.AsAlias{ - As: -1, - Alias: &ast.Ident{ - NamePos: 32, - NameEnd: 33, - Name: "A", + Query: &ast.Query{ + Query: &ast.SubQuery{ + Lparen: 21, + Rparen: 81, + Query: &ast.CompoundQuery{ + Op: "UNION", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ + &ast.SubQuery{ + Lparen: 22, + Rparen: 54, + Query: &ast.CompoundQuery{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ + &ast.Select{ + Select: 23, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 30, + ValueEnd: 31, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: -1, + Alias: &ast.Ident{ + NamePos: 32, + NameEnd: 33, + Name: "A", + }, }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), - }, - &ast.SubQuery{ - Lparen: 44, - Rparen: 53, - Query: &ast.Select{ - Select: 45, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.IntLiteral{ - ValuePos: 52, - ValueEnd: 53, - Base: 10, - Value: "2", + &ast.SubQuery{ + Lparen: 44, + Rparen: 53, + Query: &ast.Select{ + Select: 45, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 52, + ValueEnd: 53, + Base: 10, + Value: "2", + }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), - }, - &ast.SubQuery{ - Lparen: 71, - Rparen: 80, - Query: &ast.Select{ - Select: 72, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.IntLiteral{ - ValuePos: 79, - ValueEnd: 80, - Base: 10, - Value: "1", + &ast.SubQuery{ + Lparen: 71, + Rparen: 80, + Query: &ast.Select{ + Select: 72, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 79, + ValueEnd: 80, + Base: 10, + Value: "1", + }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 83, Count: &ast.IntLiteral{ ValuePos: 89, @@ -148,20 +108,15 @@ from ( Base: 10, Value: "1", }, - Offset: (*ast.Offset)(nil), }, }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, Right: &ast.SubQueryTableExpr{ Lparen: 103, Rparen: 119, Query: &ast.Select{ - Select: 104, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 104, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.IntLiteral{ ValuePos: 111, @@ -195,15 +150,7 @@ from ( }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, Cond: &ast.Using{ Using: 121, @@ -217,14 +164,8 @@ from ( }, }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_select_limit_expr.sql.txt b/testdata/result/query/select_select_limit_expr.sql.txt index 7a4f364a..673e13ae 100644 --- a/testdata/result/query/select_select_limit_expr.sql.txt +++ b/testdata/result/query/select_select_limit_expr.sql.txt @@ -3,45 +3,33 @@ select ((select 1) limit 1 offset 0) + 3 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BinaryExpr{ Op: "+", Left: &ast.ScalarSubQuery{ Lparen: 7, Rparen: 35, - Query: &ast.SubQuery{ - Lparen: 8, - Rparen: 17, - Query: &ast.Select{ - Select: 9, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.IntLiteral{ - ValuePos: 16, - ValueEnd: 17, - Base: 10, - Value: "1", + Query: &ast.Query{ + Query: &ast.SubQuery{ + Lparen: 8, + Rparen: 17, + Query: &ast.Select{ + Select: 9, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 16, + ValueEnd: 17, + Base: 10, + Value: "1", + }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 19, Count: &ast.IntLiteral{ ValuePos: 25, @@ -70,12 +58,6 @@ select ((select 1) limit 1 offset 0) + 3 }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_select_set_operator_expr.sql.txt b/testdata/result/query/select_select_set_operator_expr.sql.txt index fc1d824d..141358d5 100644 --- a/testdata/result/query/select_select_set_operator_expr.sql.txt +++ b/testdata/result/query/select_select_set_operator_expr.sql.txt @@ -5,13 +5,8 @@ select ((select 1) union all (select 2)) + 3, --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BinaryExpr{ Op: "+", @@ -19,17 +14,15 @@ select ((select 1) union all (select 2)) + 3, Lparen: 7, Rparen: 39, Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.SubQuery{ Lparen: 8, Rparen: 17, Query: &ast.Select{ - Select: 9, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 9, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 16, @@ -39,24 +32,14 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 29, Rparen: 38, Query: &ast.Select{ - Select: 30, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 30, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 37, @@ -66,19 +49,9 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, Right: &ast.IntLiteral{ @@ -96,17 +69,15 @@ select ((select 1) union all (select 2)) + 3, Lparen: 53, Rparen: 89, Query: &ast.CompoundQuery{ - Op: "INTERSECT", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "INTERSECT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.SubQuery{ Lparen: 54, Rparen: 63, Query: &ast.Select{ - Select: 55, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 55, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 62, @@ -116,24 +87,14 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 79, Rparen: 88, Query: &ast.Select{ - Select: 80, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 80, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 87, @@ -143,19 +104,9 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, Right: &ast.IntLiteral{ @@ -173,17 +124,15 @@ select ((select 1) union all (select 2)) + 3, Lparen: 103, Rparen: 136, Query: &ast.CompoundQuery{ - Op: "EXCEPT", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "EXCEPT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.SubQuery{ Lparen: 104, Rparen: 113, Query: &ast.Select{ - Select: 105, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 105, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 112, @@ -193,24 +142,14 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 126, Rparen: 135, Query: &ast.Select{ - Select: 127, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 127, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 134, @@ -220,19 +159,9 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, Right: &ast.IntLiteral{ @@ -244,12 +173,6 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_as_struct_subquery.sql.txt b/testdata/result/query/select_singer_with_as_struct_subquery.sql.txt index 5bac5fd7..0aa86fe2 100644 --- a/testdata/result/query/select_singer_with_as_struct_subquery.sql.txt +++ b/testdata/result/query/select_singer_with_as_struct_subquery.sql.txt @@ -10,13 +10,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArraySubQuery{ Array: 9, @@ -24,36 +19,30 @@ SELECT Query: &ast.SubQuery{ Lparen: 20, Rparen: 88, - Query: &ast.Select{ - Select: 28, - Distinct: false, - As: &ast.AsStruct{ - As: 35, - Struct: 38, - }, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 53, + Query: &ast.Query{ + Query: &ast.Select{ + Select: 28, + As: &ast.AsStruct{ + As: 35, + Struct: 38, }, - }, - From: &ast.From{ - From: 61, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 66, - NameEnd: 73, - Name: "Singers", + Results: []ast.SelectItem{ + &ast.Star{ + Star: 53, + }, + }, + From: &ast.From{ + From: 61, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 66, + NameEnd: 73, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 74, Count: &ast.IntLiteral{ ValuePos: 80, @@ -61,21 +50,12 @@ SELECT Base: 10, Value: "100", }, - Offset: (*ast.Offset)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_asterisk.sql.txt b/testdata/result/query/select_singer_with_asterisk.sql.txt index 2ef354d2..3511b775 100644 --- a/testdata/result/query/select_singer_with_asterisk.sql.txt +++ b/testdata/result/query/select_singer_with_asterisk.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,16 +20,8 @@ FROM NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_column_and_asterisk.sql.txt b/testdata/result/query/select_singer_with_column_and_asterisk.sql.txt index 4aace401..40ae9fad 100644 --- a/testdata/result/query/select_singer_with_column_and_asterisk.sql.txt +++ b/testdata/result/query/select_singer_with_column_and_asterisk.sql.txt @@ -7,13 +7,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 9, @@ -33,16 +28,8 @@ FROM NameEnd: 37, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_column_names.sql.txt b/testdata/result/query/select_singer_with_column_names.sql.txt index 7bef784a..31e86dce 100644 --- a/testdata/result/query/select_singer_with_column_names.sql.txt +++ b/testdata/result/query/select_singer_with_column_names.sql.txt @@ -9,13 +9,8 @@ FROM Singers --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.Ident{ NamePos: 9, @@ -68,16 +63,8 @@ FROM Singers NameEnd: 88, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_cross_join.sql.txt b/testdata/result/query/select_singer_with_cross_join.sql.txt index f7be0a42..34362fa4 100644 --- a/testdata/result/query/select_singer_with_cross_join.sql.txt +++ b/testdata/result/query/select_singer_with_cross_join.sql.txt @@ -8,13 +8,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -22,17 +17,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "CROSS JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "CROSS JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -40,7 +32,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -48,8 +39,7 @@ FROM NameEnd: 50, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 51, @@ -57,16 +47,9 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_distinct.sql.txt b/testdata/result/query/select_singer_with_distinct.sql.txt index e3018b3e..7875b0ea 100644 --- a/testdata/result/query/select_singer_with_distinct.sql.txt +++ b/testdata/result/query/select_singer_with_distinct.sql.txt @@ -7,13 +7,9 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: true, - As: nil, - Results: []ast.SelectItem{ + AllOrDistinct: "DISTINCT", + Results: []ast.SelectItem{ &ast.Star{ Star: 20, }, @@ -26,16 +22,8 @@ FROM NameEnd: 36, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_full_join.sql.txt b/testdata/result/query/select_singer_with_full_join.sql.txt index 8e364024..4036f6ce 100644 --- a/testdata/result/query/select_singer_with_full_join.sql.txt +++ b/testdata/result/query/select_singer_with_full_join.sql.txt @@ -7,13 +7,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -21,17 +16,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: ",", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 26, Alias: &ast.Ident{ NamePos: 29, @@ -39,7 +31,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -47,8 +38,7 @@ FROM NameEnd: 41, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 42, Alias: &ast.Ident{ NamePos: 45, @@ -56,16 +46,9 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_groupby.sql.txt b/testdata/result/query/select_singer_with_groupby.sql.txt index 2e8f6f26..0c93d97d 100644 --- a/testdata/result/query/select_singer_with_groupby.sql.txt +++ b/testdata/result/query/select_singer_with_groupby.sql.txt @@ -8,13 +8,8 @@ GROUP BY --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 9, @@ -38,12 +33,8 @@ GROUP BY NameEnd: 44, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), GroupBy: &ast.GroupBy{ Group: 45, Exprs: []ast.Expr{ @@ -59,9 +50,6 @@ GROUP BY }, }, }, - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_hash_join.sql.txt b/testdata/result/query/select_singer_with_hash_join.sql.txt index 51741f24..cd61e22e 100644 --- a/testdata/result/query/select_singer_with_hash_join.sql.txt +++ b/testdata/result/query/select_singer_with_hash_join.sql.txt @@ -8,13 +8,8 @@ FROM ON A.SingerID = B.SingerID --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -24,15 +19,13 @@ FROM Source: &ast.Join{ Op: "INNER JOIN", Method: "HASH", - Hint: (*ast.Hint)(nil), Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -40,7 +33,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -48,8 +40,7 @@ FROM NameEnd: 49, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 50, @@ -57,7 +48,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 54, @@ -95,11 +85,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_having.sql.txt b/testdata/result/query/select_singer_with_having.sql.txt index 9d853bd1..c0af45ac 100644 --- a/testdata/result/query/select_singer_with_having.sql.txt +++ b/testdata/result/query/select_singer_with_having.sql.txt @@ -10,13 +10,8 @@ HAVING --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 9, @@ -33,12 +28,8 @@ HAVING NameEnd: 32, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), GroupBy: &ast.GroupBy{ Group: 33, Exprs: []ast.Expr{ @@ -66,8 +57,6 @@ HAVING }, }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_in_and_unnest.sql.txt b/testdata/result/query/select_singer_with_in_and_unnest.sql.txt index ac358ab5..c410d65a 100644 --- a/testdata/result/query/select_singer_with_in_and_unnest.sql.txt +++ b/testdata/result/query/select_singer_with_in_and_unnest.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,15 +22,11 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ Where: 26, Expr: &ast.InExpr{ - Not: false, Left: &ast.Ident{ NamePos: 34, NameEnd: 42, @@ -48,7 +39,6 @@ WHERE Array: 53, Lbrack: 58, Rbrack: 66, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 59, @@ -73,10 +63,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_in_and_unnest_with_query_parameter.sql.txt b/testdata/result/query/select_singer_with_in_and_unnest_with_query_parameter.sql.txt index 456d2286..293e2401 100644 --- a/testdata/result/query/select_singer_with_in_and_unnest_with_query_parameter.sql.txt +++ b/testdata/result/query/select_singer_with_in_and_unnest_with_query_parameter.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,15 +22,11 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ Where: 26, Expr: &ast.InExpr{ - Not: false, Left: &ast.Ident{ NamePos: 34, NameEnd: 42, @@ -51,10 +42,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_join.sql.txt b/testdata/result/query/select_singer_with_join.sql.txt index ab573b3f..70831a2f 100644 --- a/testdata/result/query/select_singer_with_join.sql.txt +++ b/testdata/result/query/select_singer_with_join.sql.txt @@ -9,13 +9,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -23,17 +18,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "LEFT OUTER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -41,7 +33,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -49,8 +40,7 @@ FROM NameEnd: 55, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 56, @@ -58,7 +48,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 60, @@ -96,11 +85,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_join_hint.sql.txt b/testdata/result/query/select_singer_with_join_hint.sql.txt index 92a14a85..272a54be 100644 --- a/testdata/result/query/select_singer_with_join_hint.sql.txt +++ b/testdata/result/query/select_singer_with_join_hint.sql.txt @@ -18,13 +18,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -32,9 +27,8 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: &ast.Hint{ + Op: "INNER JOIN", + Hint: &ast.Hint{ Atmark: 258, Rbrace: 279, Records: []*ast.HintRecord{ @@ -53,9 +47,8 @@ FROM }, }, Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: &ast.Hint{ + Op: "INNER JOIN", + Hint: &ast.Hint{ Atmark: 187, Rbrace: 209, Records: []*ast.HintRecord{ @@ -74,9 +67,8 @@ FROM }, }, Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: &ast.Hint{ + Op: "INNER JOIN", + Hint: &ast.Hint{ Atmark: 117, Rbrace: 138, Records: []*ast.HintRecord{ @@ -95,9 +87,8 @@ FROM }, }, Left: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: &ast.Hint{ + Op: "LEFT OUTER JOIN", + Hint: &ast.Hint{ Atmark: 45, Rbrace: 68, Records: []*ast.HintRecord{ @@ -120,8 +111,7 @@ FROM NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -129,7 +119,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -137,8 +126,7 @@ FROM NameEnd: 79, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 80, @@ -146,7 +134,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 84, @@ -189,8 +176,7 @@ FROM NameEnd: 149, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 150, @@ -198,7 +184,6 @@ FROM Name: "C", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 154, @@ -241,8 +226,7 @@ FROM NameEnd: 220, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 221, @@ -250,7 +234,6 @@ FROM Name: "D", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 225, @@ -293,8 +276,7 @@ FROM NameEnd: 290, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 291, @@ -302,7 +284,6 @@ FROM Name: "E", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 295, @@ -340,11 +321,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_join_twice.sql.txt b/testdata/result/query/select_singer_with_join_twice.sql.txt index 035780a4..c2f8e6dd 100644 --- a/testdata/result/query/select_singer_with_join_twice.sql.txt +++ b/testdata/result/query/select_singer_with_join_twice.sql.txt @@ -12,13 +12,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -26,21 +21,16 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "INNER JOIN", + Left: &ast.Join{ + Op: "INNER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -48,7 +38,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -56,8 +45,7 @@ FROM NameEnd: 44, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 45, @@ -65,7 +53,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 49, @@ -108,8 +95,7 @@ FROM NameEnd: 98, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 99, @@ -117,7 +103,6 @@ FROM Name: "C", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 103, @@ -155,11 +140,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_join_using.sql.txt b/testdata/result/query/select_singer_with_join_using.sql.txt index e37df1cb..a68579f7 100644 --- a/testdata/result/query/select_singer_with_join_using.sql.txt +++ b/testdata/result/query/select_singer_with_join_using.sql.txt @@ -9,13 +9,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -23,17 +18,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "LEFT OUTER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -41,7 +33,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -49,8 +40,7 @@ FROM NameEnd: 55, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 56, @@ -58,7 +48,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.Using{ Using: 60, @@ -78,11 +67,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_join_various.sql.txt b/testdata/result/query/select_singer_with_join_various.sql.txt index 45d847b9..17f7be5a 100644 --- a/testdata/result/query/select_singer_with_join_various.sql.txt +++ b/testdata/result/query/select_singer_with_join_various.sql.txt @@ -32,13 +32,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -46,49 +41,30 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "RIGHT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "RIGHT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "FULL OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "FULL OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "CROSS JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "RIGHT OUTER JOIN", + Left: &ast.Join{ + Op: "RIGHT OUTER JOIN", + Left: &ast.Join{ + Op: "LEFT OUTER JOIN", + Left: &ast.Join{ + Op: "LEFT OUTER JOIN", + Left: &ast.Join{ + Op: "FULL OUTER JOIN", + Left: &ast.Join{ + Op: "FULL OUTER JOIN", + Left: &ast.Join{ + Op: "CROSS JOIN", + Left: &ast.Join{ + Op: "INNER JOIN", + Left: &ast.Join{ + Op: "INNER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -96,7 +72,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -104,8 +79,7 @@ FROM NameEnd: 44, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 45, @@ -113,7 +87,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 49, @@ -156,8 +129,7 @@ FROM NameEnd: 98, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 99, @@ -165,7 +137,6 @@ FROM Name: "C", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 103, @@ -208,8 +179,7 @@ FROM NameEnd: 152, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 153, @@ -217,9 +187,7 @@ FROM Name: "D", }, }, - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -227,8 +195,7 @@ FROM NameEnd: 176, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 177, @@ -236,7 +203,6 @@ FROM Name: "E", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 181, @@ -279,8 +245,7 @@ FROM NameEnd: 235, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 236, @@ -288,7 +253,6 @@ FROM Name: "F", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 240, @@ -331,8 +295,7 @@ FROM NameEnd: 288, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 289, @@ -340,7 +303,6 @@ FROM Name: "G", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 293, @@ -383,8 +345,7 @@ FROM NameEnd: 347, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 348, @@ -392,7 +353,6 @@ FROM Name: "H", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 352, @@ -435,8 +395,7 @@ FROM NameEnd: 401, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 402, @@ -444,7 +403,6 @@ FROM Name: "I", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 406, @@ -487,8 +445,7 @@ FROM NameEnd: 461, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 462, @@ -496,7 +453,6 @@ FROM Name: "J", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 466, @@ -534,11 +490,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_limit.sql.txt b/testdata/result/query/select_singer_with_limit.sql.txt index 388574d4..685f9467 100644 --- a/testdata/result/query/select_singer_with_limit.sql.txt +++ b/testdata/result/query/select_singer_with_limit.sql.txt @@ -7,35 +7,25 @@ LIMIT 100 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 9, + Query: &ast.Query{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 9, + }, }, - }, - From: &ast.From{ - From: 11, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 18, - NameEnd: 25, - Name: "Singers", + From: &ast.From{ + From: 11, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 18, + NameEnd: 25, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 26, Count: &ast.IntLiteral{ ValuePos: 32, @@ -43,7 +33,6 @@ LIMIT 100 Base: 10, Value: "100", }, - Offset: (*ast.Offset)(nil), }, }, } diff --git a/testdata/result/query/select_singer_with_limit_and_skiprows.sql.txt b/testdata/result/query/select_singer_with_limit_and_skiprows.sql.txt index f1293a6a..a076e0c3 100644 --- a/testdata/result/query/select_singer_with_limit_and_skiprows.sql.txt +++ b/testdata/result/query/select_singer_with_limit_and_skiprows.sql.txt @@ -8,35 +8,25 @@ OFFSET 10 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 9, + Query: &ast.Query{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 9, + }, }, - }, - From: &ast.From{ - From: 11, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 18, - NameEnd: 25, - Name: "Singers", + From: &ast.From{ + From: 11, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 18, + NameEnd: 25, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 26, Count: &ast.IntLiteral{ ValuePos: 32, diff --git a/testdata/result/query/select_singer_with_orderby.sql.txt b/testdata/result/query/select_singer_with_orderby.sql.txt index 564ee7f5..06a05fad 100644 --- a/testdata/result/query/select_singer_with_orderby.sql.txt +++ b/testdata/result/query/select_singer_with_orderby.sql.txt @@ -9,33 +9,24 @@ ORDER BY BirthDate DESC --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 9, + Query: &ast.Query{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 9, + }, }, - }, - From: &ast.From{ - From: 11, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 18, - NameEnd: 25, - Name: "Singers", + From: &ast.From{ + From: 11, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 18, + NameEnd: 25, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), OrderBy: &ast.OrderBy{ Order: 26, Items: []*ast.OrderByItem{ @@ -46,8 +37,6 @@ ORDER BY NameEnd: 46, Name: "FirstName", }, - Collate: (*ast.Collate)(nil), - Dir: "", }, &ast.OrderByItem{ DirPos: -1, @@ -64,7 +53,6 @@ ORDER BY Value: "en_US", }, }, - Dir: "", }, &ast.OrderByItem{ DirPos: 88, @@ -73,12 +61,10 @@ ORDER BY NameEnd: 87, Name: "BirthDate", }, - Collate: (*ast.Collate)(nil), - Dir: "DESC", + Dir: "DESC", }, }, }, - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_query_parameter.sql.txt b/testdata/result/query/select_singer_with_query_parameter.sql.txt index 3ec0effb..6eb90de2 100644 --- a/testdata/result/query/select_singer_with_query_parameter.sql.txt +++ b/testdata/result/query/select_singer_with_query_parameter.sql.txt @@ -9,13 +9,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -28,9 +23,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -63,10 +55,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_root_parent.sql.txt b/testdata/result/query/select_singer_with_root_parent.sql.txt index 0347bbaf..967a4a9e 100644 --- a/testdata/result/query/select_singer_with_root_parent.sql.txt +++ b/testdata/result/query/select_singer_with_root_parent.sql.txt @@ -3,16 +3,11 @@ --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.SubQuery{ - Lparen: 0, Rparen: 24, Query: &ast.Select{ - Select: 2, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 2, + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,19 +20,9 @@ NameEnd: 23, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_select_in_from.sql.txt b/testdata/result/query/select_singer_with_select_in_from.sql.txt index 6502a2a8..8945f214 100644 --- a/testdata/result/query/select_singer_with_select_in_from.sql.txt +++ b/testdata/result/query/select_singer_with_select_in_from.sql.txt @@ -12,13 +12,8 @@ FROM ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -29,10 +24,8 @@ FROM ( Lparen: 16, Rparen: 77, Query: &ast.Select{ - Select: 20, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 20, + Results: []ast.SelectItem{ &ast.Star{ Star: 31, }, @@ -45,9 +38,6 @@ FROM ( NameEnd: 51, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -67,20 +57,9 @@ FROM ( }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_select_in_from_and_as.sql.txt b/testdata/result/query/select_singer_with_select_in_from_and_as.sql.txt index fda2490e..7b5f6b4b 100644 --- a/testdata/result/query/select_singer_with_select_in_from_and_as.sql.txt +++ b/testdata/result/query/select_singer_with_select_in_from_and_as.sql.txt @@ -12,13 +12,8 @@ FROM ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -29,10 +24,8 @@ FROM ( Lparen: 16, Rparen: 77, Query: &ast.Select{ - Select: 20, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 20, + Results: []ast.SelectItem{ &ast.Star{ Star: 31, }, @@ -45,9 +38,6 @@ FROM ( NameEnd: 51, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -67,10 +57,6 @@ FROM ( }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, As: &ast.AsAlias{ As: 79, @@ -80,14 +66,8 @@ FROM ( Name: "S", }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_single_column_subquery.sql.txt b/testdata/result/query/select_singer_with_single_column_subquery.sql.txt index 976b4b8a..7fa96ac9 100644 --- a/testdata/result/query/select_singer_with_single_column_subquery.sql.txt +++ b/testdata/result/query/select_singer_with_single_column_subquery.sql.txt @@ -6,48 +6,36 @@ SELECT ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ScalarSubQuery{ Lparen: 7, Rparen: 53, - Query: &ast.Select{ - Select: 11, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 18, - NameEnd: 27, - Name: "FirstName", + Query: &ast.Query{ + Query: &ast.Select{ + Select: 11, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 18, + NameEnd: 27, + Name: "FirstName", + }, }, }, - }, - From: &ast.From{ - From: 30, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 35, - NameEnd: 42, - Name: "Singers", + From: &ast.From{ + From: 30, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 35, + NameEnd: 42, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 43, Count: &ast.IntLiteral{ ValuePos: 49, @@ -55,18 +43,11 @@ SELECT ( Base: 10, Value: "100", }, - Offset: (*ast.Offset)(nil), }, }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_single_column_subquery_with_at.sql.txt b/testdata/result/query/select_singer_with_single_column_subquery_with_at.sql.txt index c420f982..b536ed0f 100644 --- a/testdata/result/query/select_singer_with_single_column_subquery_with_at.sql.txt +++ b/testdata/result/query/select_singer_with_single_column_subquery_with_at.sql.txt @@ -6,48 +6,36 @@ SELECT ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.ScalarSubQuery{ Lparen: 7, Rparen: 53, - Query: &ast.Select{ - Select: 11, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 18, - NameEnd: 27, - Name: "FirstName", + Query: &ast.Query{ + Query: &ast.Select{ + Select: 11, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 18, + NameEnd: 27, + Name: "FirstName", + }, }, }, - }, - From: &ast.From{ - From: 30, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 35, - NameEnd: 42, - Name: "Singers", + From: &ast.From{ + From: 30, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 35, + NameEnd: 42, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 43, Count: &ast.IntLiteral{ ValuePos: 49, @@ -55,7 +43,6 @@ SELECT ( Base: 10, Value: "100", }, - Offset: (*ast.Offset)(nil), }, }, }, @@ -69,12 +56,6 @@ SELECT ( }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_table_alias.sql.txt b/testdata/result/query/select_singer_with_table_alias.sql.txt index 190521fb..e4423eb7 100644 --- a/testdata/result/query/select_singer_with_table_alias.sql.txt +++ b/testdata/result/query/select_singer_with_table_alias.sql.txt @@ -7,13 +7,8 @@ FROM Singers S --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.DotStar{ Star: 11, Expr: &ast.Ident{ @@ -71,8 +66,7 @@ FROM Singers S NameEnd: 60, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 61, @@ -80,14 +74,8 @@ FROM Singers S Name: "S", }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_table_alias_with_hint.sql.txt b/testdata/result/query/select_singer_with_table_alias_with_hint.sql.txt index 3d72f5bf..0632d7a7 100644 --- a/testdata/result/query/select_singer_with_table_alias_with_hint.sql.txt +++ b/testdata/result/query/select_singer_with_table_alias_with_hint.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -51,14 +46,8 @@ FROM Name: "S", }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_table_hint.sql.txt b/testdata/result/query/select_singer_with_table_hint.sql.txt index 5bac204b..ceac381e 100644 --- a/testdata/result/query/select_singer_with_table_hint.sql.txt +++ b/testdata/result/query/select_singer_with_table_hint.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -43,15 +38,8 @@ FROM }, }, }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_tablesample.sql.txt b/testdata/result/query/select_singer_with_tablesample.sql.txt index f333017d..6f4e56c8 100644 --- a/testdata/result/query/select_singer_with_tablesample.sql.txt +++ b/testdata/result/query/select_singer_with_tablesample.sql.txt @@ -8,13 +8,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -22,21 +17,16 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: ",", + Left: &ast.Join{ + Op: ",", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 26, Alias: &ast.Ident{ NamePos: 29, @@ -66,8 +56,7 @@ FROM NameEnd: 74, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 75, Alias: &ast.Ident{ NamePos: 78, @@ -90,7 +79,6 @@ FROM }, }, }, - Cond: nil, }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -98,8 +86,7 @@ FROM NameEnd: 126, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 127, Alias: &ast.Ident{ NamePos: 130, @@ -122,14 +109,8 @@ FROM }, }, }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_tableset.sql.txt b/testdata/result/query/select_singer_with_tableset.sql.txt index d86f32dc..3b6a2daf 100644 --- a/testdata/result/query/select_singer_with_tableset.sql.txt +++ b/testdata/result/query/select_singer_with_tableset.sql.txt @@ -5,17 +5,12 @@ SELECT * FROM Singers --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 7, }, @@ -28,22 +23,12 @@ SELECT * FROM Singers NameEnd: 21, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.Select{ - Select: 32, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 32, + Results: []ast.SelectItem{ &ast.Star{ Star: 39, }, @@ -56,20 +41,10 @@ SELECT * FROM Singers NameEnd: 53, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_tableset_complex.sql.txt b/testdata/result/query/select_singer_with_tableset_complex.sql.txt index 39c7e022..bcea2468 100644 --- a/testdata/result/query/select_singer_with_tableset_complex.sql.txt +++ b/testdata/result/query/select_singer_with_tableset_complex.sql.txt @@ -25,17 +25,12 @@ UNION ALL --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 7, }, @@ -48,29 +43,19 @@ UNION ALL NameEnd: 21, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 32, Rparen: 367, Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: true, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 36, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 36, + Results: []ast.SelectItem{ &ast.Star{ Star: 43, }, @@ -83,29 +68,19 @@ UNION ALL NameEnd: 57, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 77, Rparen: 365, Query: &ast.CompoundQuery{ - Op: "INTERSECT", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "INTERSECT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 83, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 83, + Results: []ast.SelectItem{ &ast.Star{ Star: 90, }, @@ -118,29 +93,19 @@ UNION ALL NameEnd: 104, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 127, Rparen: 361, Query: &ast.CompoundQuery{ - Op: "INTERSECT", - Distinct: true, - Queries: []ast.QueryExpr{ + Op: "INTERSECT", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 135, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 135, + Results: []ast.SelectItem{ &ast.Star{ Star: 142, }, @@ -153,29 +118,19 @@ UNION ALL NameEnd: 156, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 188, Rparen: 355, Query: &ast.CompoundQuery{ - Op: "EXCEPT", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "EXCEPT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 198, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 198, + Results: []ast.SelectItem{ &ast.Star{ Star: 205, }, @@ -188,29 +143,19 @@ UNION ALL NameEnd: 219, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 247, Rparen: 347, Query: &ast.CompoundQuery{ - Op: "EXCEPT", - Distinct: true, - Queries: []ast.QueryExpr{ + Op: "EXCEPT", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 259, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 259, + Results: []ast.SelectItem{ &ast.Star{ Star: 266, }, @@ -223,22 +168,12 @@ UNION ALL NameEnd: 280, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.Select{ - Select: 317, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 317, + Results: []ast.SelectItem{ &ast.Star{ Star: 324, }, @@ -251,55 +186,25 @@ UNION ALL NameEnd: 338, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_tableset_with_where.sql.txt b/testdata/result/query/select_singer_with_tableset_with_where.sql.txt index 06389511..56b6c6a7 100644 --- a/testdata/result/query/select_singer_with_tableset_with_where.sql.txt +++ b/testdata/result/query/select_singer_with_tableset_with_where.sql.txt @@ -9,83 +9,63 @@ ORDER BY --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ - &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 7, - }, - }, - From: &ast.From{ - From: 9, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 14, - NameEnd: 21, - Name: "Singers", + Query: &ast.Query{ + Query: &ast.CompoundQuery{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ + &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, - }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), - }, - &ast.Select{ - Select: 32, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 39, + From: &ast.From{ + From: 9, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 14, + NameEnd: 21, + Name: "Singers", + }, + }, }, }, - From: &ast.From{ - From: 41, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 46, - NameEnd: 53, - Name: "Singers", + &ast.Select{ + Select: 32, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 39, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, - }, - Where: &ast.Where{ - Where: 54, - Expr: &ast.BinaryExpr{ - Op: "=", - Left: &ast.Ident{ - NamePos: 62, - NameEnd: 70, - Name: "SingerId", + From: &ast.From{ + From: 41, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 46, + NameEnd: 53, + Name: "Singers", + }, }, - Right: &ast.IntLiteral{ - ValuePos: 73, - ValueEnd: 74, - Base: 10, - Value: "1", + }, + Where: &ast.Where{ + Where: 54, + Expr: &ast.BinaryExpr{ + Op: "=", + Left: &ast.Ident{ + NamePos: 62, + NameEnd: 70, + Name: "SingerId", + }, + Right: &ast.IntLiteral{ + ValuePos: 73, + ValueEnd: 74, + Base: 10, + Value: "1", + }, }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, OrderBy: &ast.OrderBy{ @@ -98,12 +78,9 @@ ORDER BY NameEnd: 95, Name: "FirstName", }, - Collate: (*ast.Collate)(nil), - Dir: "", }, }, }, - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_toplevel_join_hint.sql.txt b/testdata/result/query/select_singer_with_toplevel_join_hint.sql.txt index 450aca21..6b0504d6 100644 --- a/testdata/result/query/select_singer_with_toplevel_join_hint.sql.txt +++ b/testdata/result/query/select_singer_with_toplevel_join_hint.sql.txt @@ -11,7 +11,6 @@ FROM --- AST &ast.QueryStatement{ Hint: &ast.Hint{ - Atmark: 0, Rbrace: 23, Records: []*ast.HintRecord{ &ast.HintRecord{ @@ -27,12 +26,9 @@ FROM }, }, }, - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 25, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 25, + Results: []ast.SelectItem{ &ast.Star{ Star: 34, }, @@ -40,17 +36,14 @@ FROM From: &ast.From{ From: 36, Source: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "LEFT OUTER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 43, NameEnd: 50, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 51, @@ -58,7 +51,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -66,8 +58,7 @@ FROM NameEnd: 80, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 81, @@ -75,7 +66,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 85, @@ -113,11 +103,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_value_hex.sql.txt b/testdata/result/query/select_singer_with_value_hex.sql.txt index 1cd2c0fc..b1694221 100644 --- a/testdata/result/query/select_singer_with_value_hex.sql.txt +++ b/testdata/result/query/select_singer_with_value_hex.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,9 +22,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -49,10 +41,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_where.sql.txt b/testdata/result/query/select_singer_with_where.sql.txt index 5c42d434..d51994ee 100644 --- a/testdata/result/query/select_singer_with_where.sql.txt +++ b/testdata/result/query/select_singer_with_where.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,9 +22,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -49,10 +41,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_where_and_comparison.sql.txt b/testdata/result/query/select_singer_with_where_and_comparison.sql.txt index ba18a39e..54044e35 100644 --- a/testdata/result/query/select_singer_with_where_and_comparison.sql.txt +++ b/testdata/result/query/select_singer_with_where_and_comparison.sql.txt @@ -25,13 +25,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -44,9 +39,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -175,7 +167,6 @@ WHERE }, }, Right: &ast.InExpr{ - Not: false, Left: &ast.Ident{ NamePos: 145, NameEnd: 153, @@ -241,7 +232,6 @@ WHERE }, }, Right: &ast.BetweenExpr{ - Not: false, Left: &ast.Ident{ NamePos: 203, NameEnd: 211, @@ -312,7 +302,6 @@ WHERE }, Right: &ast.IsNullExpr{ Null: 329, - Not: false, Left: &ast.NullLiteral{ Null: 321, }, @@ -328,7 +317,6 @@ WHERE }, Right: &ast.IsBoolExpr{ RightPos: 379, - Not: false, Left: &ast.ParenExpr{ Lparen: 361, Rparen: 374, @@ -376,7 +364,6 @@ WHERE }, Right: &ast.IsBoolExpr{ RightPos: 439, - Not: false, Left: &ast.ParenExpr{ Lparen: 421, Rparen: 434, @@ -395,7 +382,6 @@ WHERE }, }, }, - Right: false, }, }, Right: &ast.IsBoolExpr{ @@ -419,14 +405,9 @@ WHERE }, }, }, - Right: false, }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_singer_with_where_and_op.sql.txt b/testdata/result/query/select_singer_with_where_and_op.sql.txt index e1fa8b0c..4cdc338c 100644 --- a/testdata/result/query/select_singer_with_where_and_op.sql.txt +++ b/testdata/result/query/select_singer_with_where_and_op.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,9 +22,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -81,10 +73,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_star.sql.txt b/testdata/result/query/select_star.sql.txt new file mode 100644 index 00000000..82324266 --- /dev/null +++ b/testdata/result/query/select_star.sql.txt @@ -0,0 +1,57 @@ +--- select_star.sql +SELECT * FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, + }, + }, + From: &ast.From{ + From: 9, + Source: &ast.SubQueryTableExpr{ + Lparen: 14, + Rparen: 61, + Query: &ast.Select{ + Select: 15, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 22, + ValueEnd: 29, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 30, + Alias: &ast.Ident{ + NamePos: 33, + NameEnd: 38, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 40, + ValueEnd: 48, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 49, + Alias: &ast.Ident{ + NamePos: 52, + NameEnd: 61, + Name: "vegetable", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT * FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) diff --git a/testdata/result/query/select_star_except.sql.txt b/testdata/result/query/select_star_except.sql.txt new file mode 100644 index 00000000..2dc6e9c0 --- /dev/null +++ b/testdata/result/query/select_star_except.sql.txt @@ -0,0 +1,68 @@ +--- select_star_except.sql +SELECT * EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, + Except: &ast.StarModifierExcept{ + Except: 9, + Rparen: 26, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 17, + NameEnd: 26, + Name: "vegetable", + }, + }, + }, + }, + }, + From: &ast.From{ + From: 28, + Source: &ast.SubQueryTableExpr{ + Lparen: 33, + Rparen: 80, + Query: &ast.Select{ + Select: 34, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 41, + ValueEnd: 48, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 49, + Alias: &ast.Ident{ + NamePos: 52, + NameEnd: 57, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 59, + ValueEnd: 67, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 68, + Alias: &ast.Ident{ + NamePos: 71, + NameEnd: 80, + Name: "vegetable", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT * EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) diff --git a/testdata/result/query/select_star_except_replace.sql.txt b/testdata/result/query/select_star_except_replace.sql.txt new file mode 100644 index 00000000..f128def5 --- /dev/null +++ b/testdata/result/query/select_star_except_replace.sql.txt @@ -0,0 +1,86 @@ +--- select_star_except_replace.sql +SELECT * EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, + Except: &ast.StarModifierExcept{ + Except: 9, + Rparen: 26, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 17, + NameEnd: 26, + Name: "vegetable", + }, + }, + }, + Replace: &ast.StarModifierReplace{ + Replace: 28, + Rparen: 54, + Columns: []*ast.StarModifierReplaceItem{ + &ast.StarModifierReplaceItem{ + Expr: &ast.StringLiteral{ + ValuePos: 37, + ValueEnd: 45, + Value: "orange", + }, + Name: &ast.Ident{ + NamePos: 49, + NameEnd: 54, + Name: "fruit", + }, + }, + }, + }, + }, + }, + From: &ast.From{ + From: 56, + Source: &ast.SubQueryTableExpr{ + Lparen: 61, + Rparen: 108, + Query: &ast.Select{ + Select: 62, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 69, + ValueEnd: 76, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 77, + Alias: &ast.Ident{ + NamePos: 80, + NameEnd: 85, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 87, + ValueEnd: 95, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 96, + Alias: &ast.Ident{ + NamePos: 99, + NameEnd: 108, + Name: "vegetable", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT * EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) diff --git a/testdata/result/query/select_star_replace.sql.txt b/testdata/result/query/select_star_replace.sql.txt new file mode 100644 index 00000000..b5b297af --- /dev/null +++ b/testdata/result/query/select_star_replace.sql.txt @@ -0,0 +1,75 @@ +--- select_star_replace.sql +SELECT * REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, + Replace: &ast.StarModifierReplace{ + Replace: 9, + Rparen: 35, + Columns: []*ast.StarModifierReplaceItem{ + &ast.StarModifierReplaceItem{ + Expr: &ast.StringLiteral{ + ValuePos: 18, + ValueEnd: 26, + Value: "orange", + }, + Name: &ast.Ident{ + NamePos: 30, + NameEnd: 35, + Name: "fruit", + }, + }, + }, + }, + }, + }, + From: &ast.From{ + From: 37, + Source: &ast.SubQueryTableExpr{ + Lparen: 42, + Rparen: 89, + Query: &ast.Select{ + Select: 43, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 50, + ValueEnd: 57, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 58, + Alias: &ast.Ident{ + NamePos: 61, + NameEnd: 66, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 68, + ValueEnd: 76, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 77, + Alias: &ast.Ident{ + NamePos: 80, + NameEnd: 89, + Name: "vegetable", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT * REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) diff --git a/testdata/result/query/select_struct_compare_eq.sql.txt b/testdata/result/query/select_struct_compare_eq.sql.txt index ff3acbd9..2ad47609 100644 --- a/testdata/result/query/select_struct_compare_eq.sql.txt +++ b/testdata/result/query/select_struct_compare_eq.sql.txt @@ -9,22 +9,15 @@ SELECT ARRAY( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArraySubQuery{ Array: 7, Rparen: 133, Query: &ast.Select{ - Select: 16, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 16, + Results: []ast.SelectItem{ &ast.Star{ Star: 27, }, @@ -35,10 +28,8 @@ SELECT ARRAY( Lparen: 40, Rparen: 90, Query: &ast.Select{ - Select: 41, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 41, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 48, @@ -101,12 +92,6 @@ SELECT ARRAY( }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, As: &ast.AsAlias{ As: 92, @@ -116,7 +101,6 @@ SELECT ARRAY( Name: "S", }, }, - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -168,20 +152,10 @@ SELECT ARRAY( }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_subscript_operators.sql.txt b/testdata/result/query/select_subscript_operators.sql.txt index 64776a1d..0ee39c7b 100644 --- a/testdata/result/query/select_subscript_operators.sql.txt +++ b/testdata/result/query/select_subscript_operators.sql.txt @@ -15,13 +15,8 @@ select --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IndexExpr{ Rbrack: 30, @@ -29,7 +24,6 @@ select Array: -1, Lbrack: 11, Rbrack: 19, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 12, @@ -71,7 +65,6 @@ select Array: -1, Lbrack: 37, Rbrack: 45, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 38, @@ -113,7 +106,6 @@ select Array: -1, Lbrack: 64, Rbrack: 72, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 65, @@ -155,7 +147,6 @@ select Array: -1, Lbrack: 95, Rbrack: 103, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 96, @@ -197,7 +188,6 @@ select Array: -1, Lbrack: 122, Rbrack: 130, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 123, @@ -498,12 +488,6 @@ select }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_tablesample_with_cross_join.sql.txt b/testdata/result/query/select_tablesample_with_cross_join.sql.txt index b1e29e4a..f89a73f5 100644 --- a/testdata/result/query/select_tablesample_with_cross_join.sql.txt +++ b/testdata/result/query/select_tablesample_with_cross_join.sql.txt @@ -9,13 +9,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -23,17 +18,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "CROSS JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "CROSS JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -41,7 +33,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -49,8 +40,7 @@ FROM NameEnd: 50, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 51, @@ -74,14 +64,8 @@ FROM }, }, }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_tablesample_with_subquery.sql.txt b/testdata/result/query/select_tablesample_with_subquery.sql.txt index 07aadcab..2eca5398 100644 --- a/testdata/result/query/select_tablesample_with_subquery.sql.txt +++ b/testdata/result/query/select_tablesample_with_subquery.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -23,10 +18,8 @@ FROM Lparen: 18, Rparen: 40, Query: &ast.Select{ - Select: 19, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 19, + Results: []ast.SelectItem{ &ast.Star{ Star: 26, }, @@ -39,18 +32,9 @@ FROM NameEnd: 40, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - As: (*ast.AsAlias)(nil), Sample: &ast.TableSample{ TableSample: 42, Method: "BERNOULLI", @@ -68,11 +52,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_tablesample_with_table.sql.txt b/testdata/result/query/select_tablesample_with_table.sql.txt index b6d80bc3..105c0b18 100644 --- a/testdata/result/query/select_tablesample_with_table.sql.txt +++ b/testdata/result/query/select_tablesample_with_table.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,8 +20,6 @@ FROM NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), Sample: &ast.TableSample{ TableSample: 26, Method: "BERNOULLI", @@ -44,11 +37,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_tablesample_with_table_alias.sql.txt b/testdata/result/query/select_tablesample_with_table_alias.sql.txt index 102ff2ed..06e78886 100644 --- a/testdata/result/query/select_tablesample_with_table_alias.sql.txt +++ b/testdata/result/query/select_tablesample_with_table_alias.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,8 +20,7 @@ FROM NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 26, Alias: &ast.Ident{ NamePos: 29, @@ -51,11 +45,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_tablesample_with_unnest_invalid.sql.txt b/testdata/result/query/select_tablesample_with_unnest_invalid.sql.txt index 44d34a87..13ac59cf 100644 --- a/testdata/result/query/select_tablesample_with_unnest_invalid.sql.txt +++ b/testdata/result/query/select_tablesample_with_unnest_invalid.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -91,10 +86,7 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: &ast.TableSample{ + Sample: &ast.TableSample{ TableSample: 83, Method: "BERNOULLI", Size: &ast.TableSampleSize{ @@ -111,11 +103,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_union_chain.sql.txt b/testdata/result/query/select_union_chain.sql.txt index a26ec131..056c6bed 100644 --- a/testdata/result/query/select_union_chain.sql.txt +++ b/testdata/result/query/select_union_chain.sql.txt @@ -3,20 +3,15 @@ --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.SubQuery{ - Lparen: 0, Rparen: 9, Query: &ast.Select{ - Select: 1, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 1, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 8, @@ -26,24 +21,14 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 21, Rparen: 30, Query: &ast.Select{ - Select: 22, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 22, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 29, @@ -53,24 +38,14 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 42, Rparen: 51, Query: &ast.Select{ - Select: 43, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 43, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 50, @@ -80,19 +55,9 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_unnest_with_offset.sql.txt b/testdata/result/query/select_unnest_with_offset.sql.txt index 776191c4..11f707a2 100644 --- a/testdata/result/query/select_unnest_with_offset.sql.txt +++ b/testdata/result/query/select_unnest_with_offset.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -26,7 +21,6 @@ FROM Array: -1, Lbrack: 25, Rbrack: 31, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 26, @@ -67,20 +61,12 @@ FROM }, }, }, - As: (*ast.AsAlias)(nil), WithOffset: &ast.WithOffset{ With: 46, Offset: 51, - As: (*ast.AsAlias)(nil), }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_unnest_with_offset_and_alias.sql.txt b/testdata/result/query/select_unnest_with_offset_and_alias.sql.txt index 3b88c15d..ab2f4a32 100644 --- a/testdata/result/query/select_unnest_with_offset_and_alias.sql.txt +++ b/testdata/result/query/select_unnest_with_offset_and_alias.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -26,7 +21,6 @@ FROM Array: -1, Lbrack: 25, Rbrack: 31, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 26, @@ -48,8 +42,7 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 34, Alias: &ast.Ident{ NamePos: 37, @@ -69,14 +62,8 @@ FROM }, }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_unnest_with_offset_and_alias_min.sql.txt b/testdata/result/query/select_unnest_with_offset_and_alias_min.sql.txt index 684b1116..010a9a8a 100644 --- a/testdata/result/query/select_unnest_with_offset_and_alias_min.sql.txt +++ b/testdata/result/query/select_unnest_with_offset_and_alias_min.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -26,7 +21,6 @@ FROM Array: -1, Lbrack: 25, Rbrack: 31, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 26, @@ -48,8 +42,7 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 34, @@ -69,14 +62,8 @@ FROM }, }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_with.sql.txt b/testdata/result/query/select_with.sql.txt new file mode 100644 index 00000000..58348b5b --- /dev/null +++ b/testdata/result/query/select_with.sql.txt @@ -0,0 +1,112 @@ +--- select_with.sql +-- https://cloud.google.com/spanner/docs/reference/standard-sql/operators#with_expression +SELECT WITH(a AS '123', -- a is '123' + b AS CONCAT(a, '456'), -- b is '123456' + c AS '789', -- c is '789' + CONCAT(b, c)) AS result -- b + c is '123456789' +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Select: 90, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.WithExpr{ + With: 97, + Rparen: 241, + Vars: []*ast.WithExprVar{ + &ast.WithExprVar{ + Name: &ast.Ident{ + NamePos: 102, + NameEnd: 103, + Name: "a", + }, + Expr: &ast.StringLiteral{ + ValuePos: 107, + ValueEnd: 112, + Value: "123", + }, + }, + &ast.WithExprVar{ + Name: &ast.Ident{ + NamePos: 138, + NameEnd: 139, + Name: "b", + }, + Expr: &ast.CallExpr{ + Rparen: 158, + Func: &ast.Ident{ + NamePos: 143, + NameEnd: 149, + Name: "CONCAT", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.Ident{ + NamePos: 150, + NameEnd: 151, + Name: "a", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 153, + ValueEnd: 158, + Value: "456", + }, + }, + }, + }, + }, + &ast.WithExprVar{ + Name: &ast.Ident{ + NamePos: 185, + NameEnd: 186, + Name: "c", + }, + Expr: &ast.StringLiteral{ + ValuePos: 190, + ValueEnd: 195, + Value: "789", + }, + }, + }, + Expr: &ast.CallExpr{ + Rparen: 240, + Func: &ast.Ident{ + NamePos: 229, + NameEnd: 235, + Name: "CONCAT", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.Ident{ + NamePos: 236, + NameEnd: 237, + Name: "b", + }, + }, + &ast.ExprArg{ + Expr: &ast.Ident{ + NamePos: 239, + NameEnd: 240, + Name: "c", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 243, + Alias: &ast.Ident{ + NamePos: 246, + NameEnd: 252, + Name: "result", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT WITH(a AS "123", b AS CONCAT(a, "456"), c AS "789", CONCAT(b, c)) AS result diff --git a/testdata/result/query/select_with_after_hint.sql.txt b/testdata/result/query/select_with_after_hint.sql.txt index fbc3c178..5a759851 100644 --- a/testdata/result/query/select_with_after_hint.sql.txt +++ b/testdata/result/query/select_with_after_hint.sql.txt @@ -4,7 +4,6 @@ --- AST &ast.QueryStatement{ Hint: &ast.Hint{ - Atmark: 0, Rbrace: 11, Records: []*ast.HintRecord{ &ast.HintRecord{ @@ -22,78 +21,60 @@ }, }, }, - With: &ast.With{ - With: 13, - CTEs: []*ast.CTE{ - &ast.CTE{ - Rparen: 46, - Name: &ast.Ident{ - NamePos: 18, - NameEnd: 23, - Name: "subq1", - }, - QueryExpr: &ast.Select{ - Select: 28, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 35, - NameEnd: 37, - Name: "c1", + Query: &ast.Query{ + With: &ast.With{ + With: 13, + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 46, + Name: &ast.Ident{ + NamePos: 18, + NameEnd: 23, + Name: "subq1", + }, + QueryExpr: &ast.Select{ + Select: 28, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 35, + NameEnd: 37, + Name: "c1", + }, }, }, - }, - From: &ast.From{ - From: 38, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 43, - NameEnd: 46, - Name: "foo", + From: &ast.From{ + From: 38, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 43, + NameEnd: 46, + Name: "foo", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, - }, - Query: &ast.Select{ - Select: 48, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 55, + Query: &ast.Select{ + Select: 48, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 55, + }, }, - }, - From: &ast.From{ - From: 57, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 62, - NameEnd: 67, - Name: "subq1", + From: &ast.From{ + From: 57, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 62, + NameEnd: 67, + Name: "subq1", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_with_comment.sql.txt b/testdata/result/query/select_with_comment.sql.txt index a19849c0..369a1a18 100644 --- a/testdata/result/query/select_with_comment.sql.txt +++ b/testdata/result/query/select_with_comment.sql.txt @@ -4,13 +4,9 @@ select 1 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 10, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 10, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 17, @@ -20,12 +16,6 @@ select 1 }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_with_field_path.sql.txt b/testdata/result/query/select_with_field_path.sql.txt index fb07732a..67bd84c5 100644 --- a/testdata/result/query/select_with_field_path.sql.txt +++ b/testdata/result/query/select_with_field_path.sql.txt @@ -19,13 +19,8 @@ WHERE A.z.a = 2 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -110,9 +105,8 @@ WHERE A.z.a = 2 Array: 57, Rparen: 251, Query: &ast.Select{ - Select: 70, - Distinct: false, - As: &ast.AsStruct{ + Select: 70, + As: &ast.AsStruct{ As: 77, Struct: 80, }, @@ -284,21 +278,11 @@ WHERE A.z.a = 2 }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 257, Alias: &ast.Ident{ NamePos: 260, @@ -306,8 +290,6 @@ WHERE A.z.a = 2 Name: "A", }, }, - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -341,10 +323,6 @@ WHERE A.z.a = 2 }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_with_multiple_ctes.sql.txt b/testdata/result/query/select_with_multiple_ctes.sql.txt index f5221e7f..08eb3a79 100644 --- a/testdata/result/query/select_with_multiple_ctes.sql.txt +++ b/testdata/result/query/select_with_multiple_ctes.sql.txt @@ -3,119 +3,89 @@ with subq1 as (select c1 from foo), subq2 as (select c2 from foo) select * from --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: &ast.With{ - With: 0, - CTEs: []*ast.CTE{ - &ast.CTE{ - Rparen: 33, - Name: &ast.Ident{ - NamePos: 5, - NameEnd: 10, - Name: "subq1", - }, - QueryExpr: &ast.Select{ - Select: 15, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 22, - NameEnd: 24, - Name: "c1", + Query: &ast.Query{ + With: &ast.With{ + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 33, + Name: &ast.Ident{ + NamePos: 5, + NameEnd: 10, + Name: "subq1", + }, + QueryExpr: &ast.Select{ + Select: 15, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 22, + NameEnd: 24, + Name: "c1", + }, }, }, - }, - From: &ast.From{ - From: 25, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 30, - NameEnd: 33, - Name: "foo", + From: &ast.From{ + From: 25, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 30, + NameEnd: 33, + Name: "foo", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - }, - &ast.CTE{ - Rparen: 64, - Name: &ast.Ident{ - NamePos: 36, - NameEnd: 41, - Name: "subq2", - }, - QueryExpr: &ast.Select{ - Select: 46, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 53, - NameEnd: 55, - Name: "c2", + &ast.CTE{ + Rparen: 64, + Name: &ast.Ident{ + NamePos: 36, + NameEnd: 41, + Name: "subq2", + }, + QueryExpr: &ast.Select{ + Select: 46, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 53, + NameEnd: 55, + Name: "c2", + }, }, }, - }, - From: &ast.From{ - From: 56, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 61, - NameEnd: 64, - Name: "foo", + From: &ast.From{ + From: 56, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 61, + NameEnd: 64, + Name: "foo", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, - }, - Query: &ast.Select{ - Select: 66, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 73, + Query: &ast.Select{ + Select: 66, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 73, + }, }, - }, - From: &ast.From{ - From: 75, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 80, - NameEnd: 85, - Name: "subq1", + From: &ast.From{ + From: 75, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 80, + NameEnd: 85, + Name: "subq1", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_with_reservedword.sql.txt b/testdata/result/query/select_with_reservedword.sql.txt index f310b6f0..f6a0e091 100644 --- a/testdata/result/query/select_with_reservedword.sql.txt +++ b/testdata/result/query/select_with_reservedword.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,16 +20,8 @@ FROM NameEnd: 26, Name: "UNNEST", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_with_sequence_function.sql.txt b/testdata/result/query/select_with_sequence_function.sql.txt index 333ec82a..c5a07b7a 100644 --- a/testdata/result/query/select_with_sequence_function.sql.txt +++ b/testdata/result/query/select_with_sequence_function.sql.txt @@ -3,13 +3,8 @@ SELECT GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence) as next_id --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.CallExpr{ Rparen: 51, @@ -18,8 +13,7 @@ SELECT GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence) as next_id NameEnd: 30, Name: "GET_NEXT_SEQUENCE_VALUE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.SequenceArg{ Sequence: 31, Expr: &ast.Ident{ @@ -29,9 +23,6 @@ SELECT GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence) as next_id }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, As: &ast.AsAlias{ As: 53, @@ -43,12 +34,6 @@ SELECT GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence) as next_id }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/select_with_trailing_comma.sql.txt b/testdata/result/query/select_with_trailing_comma.sql.txt index 8aba7288..835ed9e3 100644 --- a/testdata/result/query/select_with_trailing_comma.sql.txt +++ b/testdata/result/query/select_with_trailing_comma.sql.txt @@ -2,13 +2,8 @@ SELECT 1, 2, --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 7, @@ -26,12 +21,6 @@ SELECT 1, 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/query/with_paren_query_limit.sql.txt b/testdata/result/query/with_paren_query_limit.sql.txt new file mode 100644 index 00000000..3be484bd --- /dev/null +++ b/testdata/result/query/with_paren_query_limit.sql.txt @@ -0,0 +1,66 @@ +--- with_paren_query_limit.sql +WITH cte AS (SELECT 1) (SELECT * FROM cte) LIMIT 1 +--- AST +&ast.QueryStatement{ + Query: &ast.Query{ + With: &ast.With{ + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 21, + Name: &ast.Ident{ + NamePos: 5, + NameEnd: 8, + Name: "cte", + }, + QueryExpr: &ast.Select{ + Select: 13, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 20, + ValueEnd: 21, + Base: 10, + Value: "1", + }, + }, + }, + }, + }, + }, + }, + Query: &ast.SubQuery{ + Lparen: 23, + Rparen: 41, + Query: &ast.Select{ + Select: 24, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 31, + }, + }, + From: &ast.From{ + From: 33, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 38, + NameEnd: 41, + Name: "cte", + }, + }, + }, + }, + }, + Limit: &ast.Limit{ + Limit: 43, + Count: &ast.IntLiteral{ + ValuePos: 49, + ValueEnd: 50, + Base: 10, + Value: "1", + }, + }, + }, +} + +--- SQL +WITH cte AS (SELECT 1) (SELECT * FROM cte) LIMIT 1 diff --git a/testdata/result/statement/aggregate_function_calls.sql.txt b/testdata/result/statement/aggregate_function_calls.sql.txt index 9e2ad6c2..dc06d262 100644 --- a/testdata/result/statement/aggregate_function_calls.sql.txt +++ b/testdata/result/statement/aggregate_function_calls.sql.txt @@ -8,13 +8,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.CallExpr{ Rparen: 43, @@ -23,8 +18,7 @@ SELECT NameEnd: 20, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 21, @@ -33,9 +27,7 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: &ast.HavingMax{ + Having: &ast.HavingMax{ Having: 28, Expr: &ast.Ident{ NamePos: 39, @@ -53,8 +45,7 @@ SELECT NameEnd: 59, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 60, @@ -63,9 +54,7 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: &ast.HavingMin{ + Having: &ast.HavingMin{ Having: 67, Expr: &ast.Ident{ NamePos: 78, @@ -83,8 +72,7 @@ SELECT NameEnd: 98, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 99, @@ -93,12 +81,10 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), NullHandling: &ast.IgnoreNulls{ Ignore: 106, Nulls: 113, }, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -109,8 +95,7 @@ SELECT NameEnd: 134, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 135, @@ -119,12 +104,10 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), NullHandling: &ast.RespectNulls{ Respect: 142, Nulls: 150, }, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -135,8 +118,7 @@ SELECT NameEnd: 171, Name: "ARRAY_AGG", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 172, @@ -145,7 +127,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), NullHandling: &ast.RespectNulls{ Respect: 179, Nulls: 187, @@ -161,12 +142,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/alter_change_stream_options.sql.txt b/testdata/result/statement/alter_change_stream_options.sql.txt index 0069de75..b0214ab8 100644 --- a/testdata/result/statement/alter_change_stream_options.sql.txt +++ b/testdata/result/statement/alter_change_stream_options.sql.txt @@ -3,8 +3,7 @@ ALTER CHANGE STREAM change_stream_name SET OPTIONS (retention_period = '1d', val --- AST &ast.AlterChangeStream{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "change_stream_name", diff --git a/testdata/result/statement/alter_change_stream_set_drop_for_all.sql.txt b/testdata/result/statement/alter_change_stream_set_drop_for_all.sql.txt index 78744030..07c9db12 100644 --- a/testdata/result/statement/alter_change_stream_set_drop_for_all.sql.txt +++ b/testdata/result/statement/alter_change_stream_set_drop_for_all.sql.txt @@ -3,8 +3,7 @@ ALTER CHANGE STREAM change_stream_name DROP FOR ALL --- AST &ast.AlterChangeStream{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "change_stream_name", diff --git a/testdata/result/statement/alter_change_stream_set_for_all.sql.txt b/testdata/result/statement/alter_change_stream_set_for_all.sql.txt index 93247c77..a8dfc96e 100644 --- a/testdata/result/statement/alter_change_stream_set_for_all.sql.txt +++ b/testdata/result/statement/alter_change_stream_set_for_all.sql.txt @@ -3,8 +3,7 @@ ALTER CHANGE STREAM change_stream_name SET FOR ALL --- AST &ast.AlterChangeStream{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "change_stream_name", diff --git a/testdata/result/statement/alter_change_stream_set_for_table_columns.sql.txt b/testdata/result/statement/alter_change_stream_set_for_table_columns.sql.txt index ed5c412b..4b2104c9 100644 --- a/testdata/result/statement/alter_change_stream_set_for_table_columns.sql.txt +++ b/testdata/result/statement/alter_change_stream_set_for_table_columns.sql.txt @@ -3,8 +3,7 @@ ALTER CHANGE STREAM change_stream_name SET FOR table_name1(column1, column2), ta --- AST &ast.AlterChangeStream{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "change_stream_name", diff --git a/testdata/result/statement/alter_database.sql.txt b/testdata/result/statement/alter_database.sql.txt index 3fc122ab..7aee12b2 100644 --- a/testdata/result/statement/alter_database.sql.txt +++ b/testdata/result/statement/alter_database.sql.txt @@ -8,8 +8,7 @@ ALTER DATABASE dbname SET OPTIONS ( ) --- AST &ast.AlterDatabase{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 15, NameEnd: 21, Name: "dbname", diff --git a/testdata/result/statement/alter_index_add_stored_column.sql.txt b/testdata/result/statement/alter_index_add_stored_column.sql.txt index ae278e40..831651a3 100644 --- a/testdata/result/statement/alter_index_add_stored_column.sql.txt +++ b/testdata/result/statement/alter_index_add_stored_column.sql.txt @@ -3,8 +3,7 @@ alter index foo add stored column bar --- AST &ast.AlterIndex{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_index_drop_stored_column.sql.txt b/testdata/result/statement/alter_index_drop_stored_column.sql.txt index 1a54ff45..d22dc9c7 100644 --- a/testdata/result/statement/alter_index_drop_stored_column.sql.txt +++ b/testdata/result/statement/alter_index_drop_stored_column.sql.txt @@ -3,8 +3,7 @@ alter index foo drop stored column bar --- AST &ast.AlterIndex{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_model.sql.txt b/testdata/result/statement/alter_model.sql.txt index cb6cf129..9cb212f6 100644 --- a/testdata/result/statement/alter_model.sql.txt +++ b/testdata/result/statement/alter_model.sql.txt @@ -9,9 +9,7 @@ SET OPTIONS ( ) --- AST &ast.AlterModel{ - Alter: 0, - IfExists: false, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 12, NameEnd: 33, Name: "MyClassificationModel", @@ -30,7 +28,6 @@ SET OPTIONS ( Array: -1, Lbrack: 64, Rbrack: 227, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 74, diff --git a/testdata/result/statement/alter_model_if_exists.sql.txt b/testdata/result/statement/alter_model_if_exists.sql.txt index a585c656..f6884fd5 100644 --- a/testdata/result/statement/alter_model_if_exists.sql.txt +++ b/testdata/result/statement/alter_model_if_exists.sql.txt @@ -9,7 +9,6 @@ SET OPTIONS ( ) --- AST &ast.AlterModel{ - Alter: 0, IfExists: true, Name: &ast.Ident{ NamePos: 22, @@ -30,7 +29,6 @@ SET OPTIONS ( Array: -1, Lbrack: 74, Rbrack: 237, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 84, diff --git a/testdata/result/statement/alter_proto_bundle_all.sql.txt b/testdata/result/statement/alter_proto_bundle_all.sql.txt index feb37248..6d94cede 100644 --- a/testdata/result/statement/alter_proto_bundle_all.sql.txt +++ b/testdata/result/statement/alter_proto_bundle_all.sql.txt @@ -2,7 +2,6 @@ ALTER PROTO BUNDLE INSERT (package.Inserted) UPDATE (package.Updated) DELETE (package.Deleted) --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, Insert: &ast.AlterProtoBundleInsert{ Insert: 19, diff --git a/testdata/result/statement/alter_proto_bundle_delete.sql.txt b/testdata/result/statement/alter_proto_bundle_delete.sql.txt index ca333576..663b0159 100644 --- a/testdata/result/statement/alter_proto_bundle_delete.sql.txt +++ b/testdata/result/statement/alter_proto_bundle_delete.sql.txt @@ -2,10 +2,7 @@ ALTER PROTO BUNDLE DELETE(`examples.shipping.OrderHistory`) --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, - Insert: (*ast.AlterProtoBundleInsert)(nil), - Update: (*ast.AlterProtoBundleUpdate)(nil), Delete: &ast.AlterProtoBundleDelete{ Delete: 19, Types: &ast.ProtoBundleTypes{ diff --git a/testdata/result/statement/alter_proto_bundle_insert.sql.txt b/testdata/result/statement/alter_proto_bundle_insert.sql.txt index 3b82c6c1..470928dc 100644 --- a/testdata/result/statement/alter_proto_bundle_insert.sql.txt +++ b/testdata/result/statement/alter_proto_bundle_insert.sql.txt @@ -4,7 +4,6 @@ ALTER PROTO BUNDLE INSERT ( ) --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, Insert: &ast.AlterProtoBundleInsert{ Insert: 19, @@ -34,8 +33,6 @@ ALTER PROTO BUNDLE INSERT ( }, }, }, - Update: (*ast.AlterProtoBundleUpdate)(nil), - Delete: (*ast.AlterProtoBundleDelete)(nil), } --- SQL diff --git a/testdata/result/statement/alter_proto_bundle_noop.sql.txt b/testdata/result/statement/alter_proto_bundle_noop.sql.txt index aa40ccc7..e33290f1 100644 --- a/testdata/result/statement/alter_proto_bundle_noop.sql.txt +++ b/testdata/result/statement/alter_proto_bundle_noop.sql.txt @@ -2,11 +2,7 @@ ALTER PROTO BUNDLE --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, - Insert: (*ast.AlterProtoBundleInsert)(nil), - Update: (*ast.AlterProtoBundleUpdate)(nil), - Delete: (*ast.AlterProtoBundleDelete)(nil), } --- SQL diff --git a/testdata/result/statement/alter_proto_bundle_update.sql.txt b/testdata/result/statement/alter_proto_bundle_update.sql.txt index 19f249b1..45376eb4 100644 --- a/testdata/result/statement/alter_proto_bundle_update.sql.txt +++ b/testdata/result/statement/alter_proto_bundle_update.sql.txt @@ -2,9 +2,7 @@ ALTER PROTO BUNDLE UPDATE(`examples.shipping.Order`) --- AST &ast.AlterProtoBundle{ - Alter: 0, Bundle: 12, - Insert: (*ast.AlterProtoBundleInsert)(nil), Update: &ast.AlterProtoBundleUpdate{ Update: 19, Types: &ast.ProtoBundleTypes{ @@ -23,7 +21,6 @@ ALTER PROTO BUNDLE UPDATE(`examples.shipping.Order`) }, }, }, - Delete: (*ast.AlterProtoBundleDelete)(nil), } --- SQL diff --git a/testdata/result/statement/alter_search_index_add_stored_column.sql.txt b/testdata/result/statement/alter_search_index_add_stored_column.sql.txt index e27c4f83..f0b3a65b 100644 --- a/testdata/result/statement/alter_search_index_add_stored_column.sql.txt +++ b/testdata/result/statement/alter_search_index_add_stored_column.sql.txt @@ -2,8 +2,7 @@ ALTER SEARCH INDEX AlbumsIndex ADD STORED COLUMN Genre --- AST &ast.AlterSearchIndex{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 19, NameEnd: 30, Name: "AlbumsIndex", diff --git a/testdata/result/statement/alter_search_index_drop_stored_column.sql.txt b/testdata/result/statement/alter_search_index_drop_stored_column.sql.txt index 1a3f12bf..b7ac0f3d 100644 --- a/testdata/result/statement/alter_search_index_drop_stored_column.sql.txt +++ b/testdata/result/statement/alter_search_index_drop_stored_column.sql.txt @@ -2,8 +2,7 @@ ALTER SEARCH INDEX AlbumsIndex DROP STORED COLUMN Genre --- AST &ast.AlterSearchIndex{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 19, NameEnd: 30, Name: "AlbumsIndex", diff --git a/testdata/result/statement/alter_sequence_no_skip_range.sql.txt b/testdata/result/statement/alter_sequence_no_skip_range.sql.txt index affc7ce0..a37cc758 100644 --- a/testdata/result/statement/alter_sequence_no_skip_range.sql.txt +++ b/testdata/result/statement/alter_sequence_no_skip_range.sql.txt @@ -3,8 +3,7 @@ ALTER SEQUENCE my_sequence NO SKIP RANGE --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -13,10 +12,7 @@ ALTER SEQUENCE my_sequence NO SKIP RANGE }, }, }, - Options: (*ast.Options)(nil), - RestartCounterWith: (*ast.RestartCounterWith)(nil), - SkipRange: (*ast.SkipRange)(nil), - NoSkipRange: &ast.NoSkipRange{ + NoSkipRange: &ast.NoSkipRange{ No: 27, Range: 35, }, diff --git a/testdata/result/statement/alter_sequence_restart_counter_with.sql.txt b/testdata/result/statement/alter_sequence_restart_counter_with.sql.txt index f16f75e3..013ce56a 100644 --- a/testdata/result/statement/alter_sequence_restart_counter_with.sql.txt +++ b/testdata/result/statement/alter_sequence_restart_counter_with.sql.txt @@ -2,8 +2,7 @@ ALTER SEQUENCE my_sequence RESTART COUNTER WITH 1000 --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -12,7 +11,6 @@ ALTER SEQUENCE my_sequence RESTART COUNTER WITH 1000 }, }, }, - Options: (*ast.Options)(nil), RestartCounterWith: &ast.RestartCounterWith{ Restart: 27, Counter: &ast.IntLiteral{ @@ -22,8 +20,6 @@ ALTER SEQUENCE my_sequence RESTART COUNTER WITH 1000 Value: "1000", }, }, - SkipRange: (*ast.SkipRange)(nil), - NoSkipRange: (*ast.NoSkipRange)(nil), } --- SQL diff --git a/testdata/result/statement/alter_sequence_set_options.sql.txt b/testdata/result/statement/alter_sequence_set_options.sql.txt index b8c2dcd4..cf788a6d 100644 --- a/testdata/result/statement/alter_sequence_set_options.sql.txt +++ b/testdata/result/statement/alter_sequence_set_options.sql.txt @@ -3,8 +3,7 @@ ALTER SEQUENCE my_sequence SET OPTIONS (skip_range_min=1, skip_range_max=1234567 --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -45,9 +44,6 @@ ALTER SEQUENCE my_sequence SET OPTIONS (skip_range_min=1, skip_range_max=1234567 }, }, }, - RestartCounterWith: (*ast.RestartCounterWith)(nil), - SkipRange: (*ast.SkipRange)(nil), - NoSkipRange: (*ast.NoSkipRange)(nil), } --- SQL diff --git a/testdata/result/statement/alter_sequence_skip_range.sql.txt b/testdata/result/statement/alter_sequence_skip_range.sql.txt index fcd1d3a8..8e4b6324 100644 --- a/testdata/result/statement/alter_sequence_skip_range.sql.txt +++ b/testdata/result/statement/alter_sequence_skip_range.sql.txt @@ -3,8 +3,7 @@ ALTER SEQUENCE my_sequence SKIP RANGE 1, 1234567 --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -13,9 +12,7 @@ ALTER SEQUENCE my_sequence SKIP RANGE 1, 1234567 }, }, }, - Options: (*ast.Options)(nil), - RestartCounterWith: (*ast.RestartCounterWith)(nil), - SkipRange: &ast.SkipRange{ + SkipRange: &ast.SkipRange{ Skip: 27, Min: &ast.IntLiteral{ ValuePos: 38, @@ -30,7 +27,6 @@ ALTER SEQUENCE my_sequence SKIP RANGE 1, 1234567 Value: "1234567", }, }, - NoSkipRange: (*ast.NoSkipRange)(nil), } --- SQL diff --git a/testdata/result/statement/alter_statistics.sql.txt b/testdata/result/statement/alter_statistics.sql.txt index 5e513edd..d5b5b3bb 100644 --- a/testdata/result/statement/alter_statistics.sql.txt +++ b/testdata/result/statement/alter_statistics.sql.txt @@ -2,8 +2,7 @@ ALTER STATISTICS auto_20191128_14_47_22UTC SET OPTIONS (allow_gc=false) --- AST &ast.AlterStatistics{ - Alter: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 17, NameEnd: 42, Name: "auto_20191128_14_47_22UTC", @@ -20,7 +19,6 @@ ALTER STATISTICS auto_20191128_14_47_22UTC SET OPTIONS (allow_gc=false) }, Value: &ast.BoolLiteral{ ValuePos: 65, - Value: false, }, }, }, diff --git a/testdata/result/statement/alter_table_add_check.sql.txt b/testdata/result/statement/alter_table_add_check.sql.txt index 12790e88..16e305bb 100644 --- a/testdata/result/statement/alter_table_add_check.sql.txt +++ b/testdata/result/statement/alter_table_add_check.sql.txt @@ -3,8 +3,7 @@ alter table foo add check (c1 > 0) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -16,9 +15,7 @@ alter table foo add check (c1 > 0) TableAlteration: &ast.AddTableConstraint{ Add: 16, TableConstraint: &ast.TableConstraint{ - ConstraintPos: 0, - Name: (*ast.Ident)(nil), - Constraint: &ast.Check{ + Constraint: &ast.Check{ Check: 20, Rparen: 33, Expr: &ast.BinaryExpr{ diff --git a/testdata/result/statement/alter_table_add_column.sql.txt b/testdata/result/statement/alter_table_add_column.sql.txt index 4ed7b407..a2e5b008 100644 --- a/testdata/result/statement/alter_table_add_column.sql.txt +++ b/testdata/result/statement/alter_table_add_column.sql.txt @@ -2,8 +2,7 @@ alter table foo add column baz string(max) not null --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -13,9 +12,8 @@ alter table foo add column baz string(max) not null }, }, TableAlteration: &ast.AddColumn{ - Add: 16, - IfNotExists: false, - Column: &ast.ColumnDef{ + Add: 16, + Column: &ast.ColumnDef{ Null: 47, Name: &ast.Ident{ NamePos: 27, @@ -27,14 +25,9 @@ alter table foo add column baz string(max) not null Rparen: 41, Name: "STRING", Max: true, - Size: nil, }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, }, } diff --git a/testdata/result/statement/alter_table_add_column_if_not_exists.sql.txt b/testdata/result/statement/alter_table_add_column_if_not_exists.sql.txt index 3b707a0c..635672e2 100644 --- a/testdata/result/statement/alter_table_add_column_if_not_exists.sql.txt +++ b/testdata/result/statement/alter_table_add_column_if_not_exists.sql.txt @@ -3,8 +3,7 @@ alter table foo add column if not exists baz string(max) not null --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -28,14 +27,9 @@ alter table foo add column if not exists baz string(max) not null Rparen: 55, Name: "STRING", Max: true, - Size: nil, }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, }, } diff --git a/testdata/result/statement/alter_table_add_column_with_if_expression.sql.txt b/testdata/result/statement/alter_table_add_column_with_if_expression.sql.txt index 7698c23c..181f03d3 100644 --- a/testdata/result/statement/alter_table_add_column_with_if_expression.sql.txt +++ b/testdata/result/statement/alter_table_add_column_with_if_expression.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND status != "SCHEDULING", TIMESTAMP_ADD(updated_at, INTERVAL 120 DAY), NULL)) STORED --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -13,9 +12,8 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND sta }, }, TableAlteration: &ast.AddColumn{ - Add: 16, - IfNotExists: false, - Column: &ast.ColumnDef{ + Add: 16, + Column: &ast.ColumnDef{ Null: -1, Name: &ast.Ident{ NamePos: 27, @@ -26,8 +24,6 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND sta NamePos: 38, Name: "TIMESTAMP", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), GeneratedExpr: &ast.GeneratedColumnExpr{ As: 48, Stored: 153, @@ -71,8 +67,7 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND sta NameEnd: 114, Name: "TIMESTAMP_ADD", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 115, @@ -95,18 +90,13 @@ ALTER TABLE foo ADD COLUMN expired_at TIMESTAMP AS (IF (status != "OPEN" AND sta }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, ElseResult: &ast.NullLiteral{ Null: 146, }, }, }, - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, } diff --git a/testdata/result/statement/alter_table_add_constraint_check.sql.txt b/testdata/result/statement/alter_table_add_constraint_check.sql.txt index c7b6bd73..03292861 100644 --- a/testdata/result/statement/alter_table_add_constraint_check.sql.txt +++ b/testdata/result/statement/alter_table_add_constraint_check.sql.txt @@ -3,8 +3,7 @@ alter table foo add constraint cname check (c1 > 0) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_add_constraint_foreign_key.sql.txt b/testdata/result/statement/alter_table_add_constraint_foreign_key.sql.txt index 14f2f1db..b0c986d8 100644 --- a/testdata/result/statement/alter_table_add_constraint_foreign_key.sql.txt +++ b/testdata/result/statement/alter_table_add_constraint_foreign_key.sql.txt @@ -3,8 +3,7 @@ alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2ke --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -59,7 +58,6 @@ alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2ke Name: "t2key2", }, }, - OnDelete: "", }, }, }, diff --git a/testdata/result/statement/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt b/testdata/result/statement/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt index 5763ea75..7e7ab779 100644 --- a/testdata/result/statement/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt +++ b/testdata/result/statement/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt @@ -3,8 +3,7 @@ alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2ke --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt b/testdata/result/statement/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt index 80052ce0..080c4819 100644 --- a/testdata/result/statement/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt +++ b/testdata/result/statement/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt @@ -3,8 +3,7 @@ alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2ke --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_add_foreign_key.sql.txt b/testdata/result/statement/alter_table_add_foreign_key.sql.txt index 040d5f20..510a9c43 100644 --- a/testdata/result/statement/alter_table_add_foreign_key.sql.txt +++ b/testdata/result/statement/alter_table_add_foreign_key.sql.txt @@ -3,8 +3,7 @@ alter table foo add foreign key (bar) references t2 (t2key1) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -16,9 +15,7 @@ alter table foo add foreign key (bar) references t2 (t2key1) TableAlteration: &ast.AddTableConstraint{ Add: 16, TableConstraint: &ast.TableConstraint{ - ConstraintPos: 0, - Name: (*ast.Ident)(nil), - Constraint: &ast.ForeignKey{ + Constraint: &ast.ForeignKey{ Foreign: 20, Rparen: 59, OnDeleteEnd: -1, @@ -45,7 +42,6 @@ alter table foo add foreign key (bar) references t2 (t2key1) Name: "t2key1", }, }, - OnDelete: "", }, }, }, diff --git a/testdata/result/statement/alter_table_add_row_deletion_policy.sql.txt b/testdata/result/statement/alter_table_add_row_deletion_policy.sql.txt index 4838ae3c..091ec583 100644 --- a/testdata/result/statement/alter_table_add_row_deletion_policy.sql.txt +++ b/testdata/result/statement/alter_table_add_row_deletion_policy.sql.txt @@ -3,8 +3,7 @@ alter table foo add row deletion policy ( older_than ( bar, interval 30 day )) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_add_synonym.sql.txt b/testdata/result/statement/alter_table_add_synonym.sql.txt index 0f384a60..cc54b865 100644 --- a/testdata/result/statement/alter_table_add_synonym.sql.txt +++ b/testdata/result/statement/alter_table_add_synonym.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE Singers ADD SYNONYM SingersTest --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_alter_column.sql.txt b/testdata/result/statement/alter_table_alter_column.sql.txt index 13e95b83..254ad98c 100644 --- a/testdata/result/statement/alter_table_alter_column.sql.txt +++ b/testdata/result/statement/alter_table_alter_column.sql.txt @@ -2,8 +2,7 @@ alter table foo alter column foo string(256) not null --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -24,7 +23,6 @@ alter table foo alter column foo string(256) not null NamePos: 33, Rparen: 43, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 40, ValueEnd: 43, @@ -32,9 +30,8 @@ alter table foo alter column foo string(256) not null Value: "256", }, }, - Null: 49, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), + Null: 49, + NotNull: true, }, }, } diff --git a/testdata/result/statement/alter_table_alter_column_alter_identity_restart_counter_with.sql.txt b/testdata/result/statement/alter_table_alter_column_alter_identity_restart_counter_with.sql.txt index 8240d64e..535a260e 100644 --- a/testdata/result/statement/alter_table_alter_column_alter_identity_restart_counter_with.sql.txt +++ b/testdata/result/statement/alter_table_alter_column_alter_identity_restart_counter_with.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN id ALTER IDENTITY RESTART COUNTER WITH 1000 --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_alter_column_alter_identity_set_no_skip_range.sql.txt b/testdata/result/statement/alter_table_alter_column_alter_identity_set_no_skip_range.sql.txt index 29e2961c..0d133c9e 100644 --- a/testdata/result/statement/alter_table_alter_column_alter_identity_set_no_skip_range.sql.txt +++ b/testdata/result/statement/alter_table_alter_column_alter_identity_set_no_skip_range.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN id ALTER IDENTITY SET NO SKIP RANGE --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_alter_column_alter_identity_set_skip_range.sql.txt b/testdata/result/statement/alter_table_alter_column_alter_identity_set_skip_range.sql.txt index a58303b0..59da1659 100644 --- a/testdata/result/statement/alter_table_alter_column_alter_identity_set_skip_range.sql.txt +++ b/testdata/result/statement/alter_table_alter_column_alter_identity_set_skip_range.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN id ALTER IDENTITY SET SKIP RANGE 1, 1234567 --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_alter_column_drop_default.sql.txt b/testdata/result/statement/alter_table_alter_column_drop_default.sql.txt index 21b4175f..8b5e7026 100644 --- a/testdata/result/statement/alter_table_alter_column_drop_default.sql.txt +++ b/testdata/result/statement/alter_table_alter_column_drop_default.sql.txt @@ -2,8 +2,7 @@ alter table foo alter column foo drop default --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_alter_column_set.sql.txt b/testdata/result/statement/alter_table_alter_column_set.sql.txt index 79eebcf1..5ead03f4 100644 --- a/testdata/result/statement/alter_table_alter_column_set.sql.txt +++ b/testdata/result/statement/alter_table_alter_column_set.sql.txt @@ -2,8 +2,7 @@ alter table foo alter column foo set options(allow_commit_timestamp = true) --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_alter_column_set_default.sql.txt b/testdata/result/statement/alter_table_alter_column_set_default.sql.txt index 61bfd3cc..5b75eba2 100644 --- a/testdata/result/statement/alter_table_alter_column_set_default.sql.txt +++ b/testdata/result/statement/alter_table_alter_column_set_default.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN output SET DEFAULT("") --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -27,7 +26,6 @@ ALTER TABLE actions ALTER COLUMN output SET DEFAULT("") Expr: &ast.StringLiteral{ ValuePos: 52, ValueEnd: 54, - Value: "", }, }, }, diff --git a/testdata/result/statement/alter_table_alter_column_with_default.sql.txt b/testdata/result/statement/alter_table_alter_column_with_default.sql.txt index 1df22088..94a7fc3a 100644 --- a/testdata/result/statement/alter_table_alter_column_with_default.sql.txt +++ b/testdata/result/statement/alter_table_alter_column_with_default.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE actions ALTER COLUMN output STRING(MAX) NOT NULL DEFAULT("") --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -25,7 +24,6 @@ ALTER TABLE actions ALTER COLUMN output STRING(MAX) NOT NULL DEFAULT("") Rparen: 50, Name: "STRING", Max: true, - Size: nil, }, Null: 56, NotNull: true, @@ -35,7 +33,6 @@ ALTER TABLE actions ALTER COLUMN output STRING(MAX) NOT NULL DEFAULT("") Expr: &ast.StringLiteral{ ValuePos: 69, ValueEnd: 71, - Value: "", }, }, }, diff --git a/testdata/result/statement/alter_table_drop_column.sql.txt b/testdata/result/statement/alter_table_drop_column.sql.txt index 0a21940d..f279716f 100644 --- a/testdata/result/statement/alter_table_drop_column.sql.txt +++ b/testdata/result/statement/alter_table_drop_column.sql.txt @@ -3,8 +3,7 @@ alter table foo drop column bar --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_drop_constraint.sql.txt b/testdata/result/statement/alter_table_drop_constraint.sql.txt index cd868b07..72380fbe 100644 --- a/testdata/result/statement/alter_table_drop_constraint.sql.txt +++ b/testdata/result/statement/alter_table_drop_constraint.sql.txt @@ -3,8 +3,7 @@ alter table foo drop constraint bar --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_drop_row_deletion_policy.sql.txt b/testdata/result/statement/alter_table_drop_row_deletion_policy.sql.txt index 79604aa1..ea5aecd9 100644 --- a/testdata/result/statement/alter_table_drop_row_deletion_policy.sql.txt +++ b/testdata/result/statement/alter_table_drop_row_deletion_policy.sql.txt @@ -3,8 +3,7 @@ alter table foo drop row deletion policy --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_drop_synonym.sql.txt b/testdata/result/statement/alter_table_drop_synonym.sql.txt index f5233212..bdd9f37e 100644 --- a/testdata/result/statement/alter_table_drop_synonym.sql.txt +++ b/testdata/result/statement/alter_table_drop_synonym.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE Singers DROP SYNONYM SingersTest --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_rename_to.sql.txt b/testdata/result/statement/alter_table_rename_to.sql.txt index 1e7c36a3..d195bd73 100644 --- a/testdata/result/statement/alter_table_rename_to.sql.txt +++ b/testdata/result/statement/alter_table_rename_to.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE Singers RENAME TO SingersNew --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -19,7 +18,6 @@ ALTER TABLE Singers RENAME TO SingersNew NameEnd: 40, Name: "SingersNew", }, - AddSynonym: (*ast.AddSynonym)(nil), }, } diff --git a/testdata/result/statement/alter_table_rename_to_add_synonym.sql.txt b/testdata/result/statement/alter_table_rename_to_add_synonym.sql.txt index 868eeb4e..bc921657 100644 --- a/testdata/result/statement/alter_table_rename_to_add_synonym.sql.txt +++ b/testdata/result/statement/alter_table_rename_to_add_synonym.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE Singers RENAME TO SingersNew, ADD SYNONYM Singers --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_replace_row_deletion_policy.sql.txt b/testdata/result/statement/alter_table_replace_row_deletion_policy.sql.txt index 3fe645be..36397cad 100644 --- a/testdata/result/statement/alter_table_replace_row_deletion_policy.sql.txt +++ b/testdata/result/statement/alter_table_replace_row_deletion_policy.sql.txt @@ -3,8 +3,7 @@ alter table foo replace row deletion policy ( older_than ( bar, interval 30 day --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_set_on_delete.sql.txt b/testdata/result/statement/alter_table_set_on_delete.sql.txt index 366965fd..c87c0894 100644 --- a/testdata/result/statement/alter_table_set_on_delete.sql.txt +++ b/testdata/result/statement/alter_table_set_on_delete.sql.txt @@ -2,8 +2,7 @@ alter table foo set on delete cascade --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/alter_table_set_on_delete_no_action.sql.txt b/testdata/result/statement/alter_table_set_on_delete_no_action.sql.txt index 33386763..45ba919c 100644 --- a/testdata/result/statement/alter_table_set_on_delete_no_action.sql.txt +++ b/testdata/result/statement/alter_table_set_on_delete_no_action.sql.txt @@ -2,8 +2,7 @@ alter table foo set on delete no action --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/analyze.sql.txt b/testdata/result/statement/analyze.sql.txt index 44a712f1..0dcf9198 100644 --- a/testdata/result/statement/analyze.sql.txt +++ b/testdata/result/statement/analyze.sql.txt @@ -1,9 +1,7 @@ --- analyze.sql ANALYZE --- AST -&ast.Analyze{ - Analyze: 0, -} +&ast.Analyze{} --- SQL ANALYZE diff --git a/testdata/result/statement/create_change_stream.sql.txt b/testdata/result/statement/create_change_stream.sql.txt index 323175f1..195b135d 100644 --- a/testdata/result/statement/create_change_stream.sql.txt +++ b/testdata/result/statement/create_change_stream.sql.txt @@ -3,14 +3,11 @@ CREATE CHANGE STREAM change_stream_name --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", }, - For: nil, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/statement/create_change_stream_for_all.sql.txt b/testdata/result/statement/create_change_stream_for_all.sql.txt index ae3ae9de..454e5db2 100644 --- a/testdata/result/statement/create_change_stream_for_all.sql.txt +++ b/testdata/result/statement/create_change_stream_for_all.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR ALL --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -13,7 +12,6 @@ CREATE CHANGE STREAM change_stream_name FOR ALL For: 40, All: 48, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/statement/create_change_stream_for_multiple_table_columns.sql.txt b/testdata/result/statement/create_change_stream_for_multiple_table_columns.sql.txt index 7f223ba7..6bfce3fb 100644 --- a/testdata/result/statement/create_change_stream_for_multiple_table_columns.sql.txt +++ b/testdata/result/statement/create_change_stream_for_multiple_table_columns.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name1(column1, column2), table --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -54,7 +53,6 @@ CREATE CHANGE STREAM change_stream_name FOR table_name1(column1, column2), table }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/statement/create_change_stream_for_table.sql.txt b/testdata/result/statement/create_change_stream_for_table.sql.txt index e208fda4..ebde8b19 100644 --- a/testdata/result/statement/create_change_stream_for_table.sql.txt +++ b/testdata/result/statement/create_change_stream_for_table.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -13,17 +12,14 @@ CREATE CHANGE STREAM change_stream_name FOR table_name For: 40, Tables: []*ast.ChangeStreamForTable{ &ast.ChangeStreamForTable{ - Rparen: 0, TableName: &ast.Ident{ NamePos: 44, NameEnd: 54, Name: "table_name", }, - Columns: []*ast.Ident(nil), }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/statement/create_change_stream_for_table_column.sql.txt b/testdata/result/statement/create_change_stream_for_table_column.sql.txt index 8829eac0..3be46ca1 100644 --- a/testdata/result/statement/create_change_stream_for_table_column.sql.txt +++ b/testdata/result/statement/create_change_stream_for_table_column.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name(column) --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -29,7 +28,6 @@ CREATE CHANGE STREAM change_stream_name FOR table_name(column) }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/statement/create_change_stream_for_table_columns.sql.txt b/testdata/result/statement/create_change_stream_for_table_columns.sql.txt index 320c4dd3..872ff41f 100644 --- a/testdata/result/statement/create_change_stream_for_table_columns.sql.txt +++ b/testdata/result/statement/create_change_stream_for_table_columns.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name(column1, column2) --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -34,7 +33,6 @@ CREATE CHANGE STREAM change_stream_name FOR table_name(column1, column2) }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/statement/create_change_stream_for_tables.sql.txt b/testdata/result/statement/create_change_stream_for_tables.sql.txt index d152e46e..3cfd2415 100644 --- a/testdata/result/statement/create_change_stream_for_tables.sql.txt +++ b/testdata/result/statement/create_change_stream_for_tables.sql.txt @@ -3,8 +3,7 @@ CREATE CHANGE STREAM change_stream_name FOR table_name1, table_name2 --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", @@ -13,26 +12,21 @@ CREATE CHANGE STREAM change_stream_name FOR table_name1, table_name2 For: 40, Tables: []*ast.ChangeStreamForTable{ &ast.ChangeStreamForTable{ - Rparen: 0, TableName: &ast.Ident{ NamePos: 44, NameEnd: 55, Name: "table_name1", }, - Columns: []*ast.Ident(nil), }, &ast.ChangeStreamForTable{ - Rparen: 0, TableName: &ast.Ident{ NamePos: 57, NameEnd: 68, Name: "table_name2", }, - Columns: []*ast.Ident(nil), }, }, }, - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/statement/create_change_stream_for_tables_with_option.sql.txt b/testdata/result/statement/create_change_stream_for_tables_with_option.sql.txt index 7f1778ce..9077f8c5 100644 --- a/testdata/result/statement/create_change_stream_for_tables_with_option.sql.txt +++ b/testdata/result/statement/create_change_stream_for_tables_with_option.sql.txt @@ -4,8 +4,7 @@ OPTIONS(retention_period = '1d') --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", diff --git a/testdata/result/statement/create_change_stream_for_tables_with_option_null.sql.txt b/testdata/result/statement/create_change_stream_for_tables_with_option_null.sql.txt index 1ff7f957..5f569192 100644 --- a/testdata/result/statement/create_change_stream_for_tables_with_option_null.sql.txt +++ b/testdata/result/statement/create_change_stream_for_tables_with_option_null.sql.txt @@ -4,8 +4,7 @@ OPTIONS(retention_period = null) --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", diff --git a/testdata/result/statement/create_change_stream_for_tables_with_options.sql.txt b/testdata/result/statement/create_change_stream_for_tables_with_options.sql.txt index ecb43509..8dbce278 100644 --- a/testdata/result/statement/create_change_stream_for_tables_with_options.sql.txt +++ b/testdata/result/statement/create_change_stream_for_tables_with_options.sql.txt @@ -4,8 +4,7 @@ OPTIONS(retention_period = '1d', value_capture_type = 'NEW_ROW') --- AST &ast.CreateChangeStream{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 21, NameEnd: 39, Name: "change_stream_name", diff --git a/testdata/result/statement/create_database.sql.txt b/testdata/result/statement/create_database.sql.txt index 85282278..54a7523e 100644 --- a/testdata/result/statement/create_database.sql.txt +++ b/testdata/result/statement/create_database.sql.txt @@ -3,8 +3,7 @@ create database foo_bar_baz --- AST &ast.CreateDatabase{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 16, NameEnd: 27, Name: "foo_bar_baz", diff --git a/testdata/result/statement/create_index.sql.txt b/testdata/result/statement/create_index.sql.txt index 568a898e..f29910dd 100644 --- a/testdata/result/statement/create_index.sql.txt +++ b/testdata/result/statement/create_index.sql.txt @@ -6,12 +6,8 @@ create index foo_bar on foo ( --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 53, - Unique: false, - NullFiltered: false, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 53, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -49,9 +45,7 @@ create index foo_bar on foo ( Dir: "ASC", }, }, - Storing: (*ast.Storing)(nil), - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE INDEX foo_bar ON foo (bar DESC, baz ASC) +CREATE INDEX foo_bar ON foo(bar DESC, baz ASC) diff --git a/testdata/result/statement/create_index_if_not_exists.sql.txt b/testdata/result/statement/create_index_if_not_exists.sql.txt index 760d3db7..824fd9e4 100644 --- a/testdata/result/statement/create_index_if_not_exists.sql.txt +++ b/testdata/result/statement/create_index_if_not_exists.sql.txt @@ -3,12 +3,9 @@ create index if not exists foo_bar on foo (bar) --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 46, - Unique: false, - NullFiltered: false, - IfNotExists: true, - Name: &ast.Path{ + Rparen: 46, + IfNotExists: true, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 27, @@ -34,12 +31,9 @@ create index if not exists foo_bar on foo (bar) NameEnd: 46, Name: "bar", }, - Dir: "", }, }, - Storing: (*ast.Storing)(nil), - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE INDEX IF NOT EXISTS foo_bar ON foo (bar) +CREATE INDEX IF NOT EXISTS foo_bar ON foo(bar) diff --git a/testdata/result/statement/create_index_interleave.sql.txt b/testdata/result/statement/create_index_interleave.sql.txt index c4efd04e..5dffda20 100644 --- a/testdata/result/statement/create_index_interleave.sql.txt +++ b/testdata/result/statement/create_index_interleave.sql.txt @@ -6,12 +6,8 @@ create index foo_bar on foo ( --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 41, - Unique: false, - NullFiltered: false, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 41, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -62,4 +58,4 @@ create index foo_bar on foo ( } --- SQL -CREATE INDEX foo_bar ON foo (foo DESC) STORING (bar), INTERLEAVE IN foobar +CREATE INDEX foo_bar ON foo(foo DESC) STORING (bar), INTERLEAVE IN foobar diff --git a/testdata/result/statement/create_index_storing.sql.txt b/testdata/result/statement/create_index_storing.sql.txt index 3c538ded..5f0a2dbf 100644 --- a/testdata/result/statement/create_index_storing.sql.txt +++ b/testdata/result/statement/create_index_storing.sql.txt @@ -5,12 +5,8 @@ create index foo_bar on foo ( --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 40, - Unique: false, - NullFiltered: false, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 40, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -55,8 +51,7 @@ create index foo_bar on foo ( }, }, }, - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE INDEX foo_bar ON foo (bar ASC) STORING (foo, baz) +CREATE INDEX foo_bar ON foo(bar ASC) STORING (foo, baz) diff --git a/testdata/result/statement/create_model.sql.txt b/testdata/result/statement/create_model.sql.txt index 8ef0fbe3..de647cb2 100644 --- a/testdata/result/statement/create_model.sql.txt +++ b/testdata/result/statement/create_model.sql.txt @@ -15,11 +15,8 @@ OPTIONS ( ) --- AST &ast.CreateModel{ - Create: 0, - Remote: 183, - OrReplace: false, - IfNotExists: false, - Name: &ast.Ident{ + Remote: 183, + Name: &ast.Ident{ NamePos: 13, NameEnd: 34, Name: "MyClassificationModel", @@ -38,7 +35,6 @@ OPTIONS ( NamePos: 52, Name: "FLOAT64", }, - Options: (*ast.Options)(nil), }, &ast.CreateModelColumn{ Name: &ast.Ident{ @@ -51,9 +47,7 @@ OPTIONS ( Rparen: 82, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, &ast.CreateModelColumn{ Name: &ast.Ident{ @@ -62,17 +56,16 @@ OPTIONS ( Name: "tag_array", }, DataType: &ast.ArraySchemaType{ - Array: 97, - Gt: 114, - Item: &ast.SizedSchemaType{ + Array: 97, + Gt: 114, + Rparen: -1, + Item: &ast.SizedSchemaType{ NamePos: 103, Rparen: 113, Name: "STRING", Max: true, - Size: nil, }, }, - Options: (*ast.Options)(nil), }, }, OutputColumns: []*ast.CreateModelColumn{ @@ -83,14 +76,14 @@ OPTIONS ( Name: "scores", }, DataType: &ast.ArraySchemaType{ - Array: 136, - Gt: 149, - Item: &ast.ScalarSchemaType{ + Array: 136, + Gt: 149, + Rparen: -1, + Item: &ast.ScalarSchemaType{ NamePos: 142, Name: "FLOAT64", }, }, - Options: (*ast.Options)(nil), }, &ast.CreateModelColumn{ Name: &ast.Ident{ @@ -99,17 +92,16 @@ OPTIONS ( Name: "classes", }, DataType: &ast.ArraySchemaType{ - Array: 162, - Gt: 179, - Item: &ast.SizedSchemaType{ + Array: 162, + Gt: 179, + Rparen: -1, + Item: &ast.SizedSchemaType{ NamePos: 168, Rparen: 178, Name: "STRING", Max: true, - Size: nil, }, }, - Options: (*ast.Options)(nil), }, }, }, diff --git a/testdata/result/statement/create_model_if_not_exists.sql.txt b/testdata/result/statement/create_model_if_not_exists.sql.txt index dfaea744..05f2efaa 100644 --- a/testdata/result/statement/create_model_if_not_exists.sql.txt +++ b/testdata/result/statement/create_model_if_not_exists.sql.txt @@ -8,9 +8,7 @@ REMOTE OPTIONS ( ) --- AST &ast.CreateModel{ - Create: 0, Remote: 93, - OrReplace: false, IfNotExists: true, Name: &ast.Ident{ NamePos: 13, @@ -32,9 +30,7 @@ REMOTE OPTIONS ( Rparen: 61, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, }, OutputColumns: []*ast.CreateModelColumn{ @@ -49,9 +45,7 @@ REMOTE OPTIONS ( Rparen: 90, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, }, }, diff --git a/testdata/result/statement/create_or_replace_model.sql.txt b/testdata/result/statement/create_or_replace_model.sql.txt index 7f9f4a2c..9955be94 100644 --- a/testdata/result/statement/create_or_replace_model.sql.txt +++ b/testdata/result/statement/create_or_replace_model.sql.txt @@ -8,11 +8,9 @@ REMOTE OPTIONS ( ) --- AST &ast.CreateModel{ - Create: 0, - Remote: 90, - OrReplace: true, - IfNotExists: false, - Name: &ast.Ident{ + Remote: 90, + OrReplace: true, + Name: &ast.Ident{ NamePos: 24, NameEnd: 33, Name: "GeminiPro", @@ -32,9 +30,7 @@ REMOTE OPTIONS ( Rparen: 58, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, }, OutputColumns: []*ast.CreateModelColumn{ @@ -49,9 +45,7 @@ REMOTE OPTIONS ( Rparen: 87, Name: "STRING", Max: true, - Size: nil, }, - Options: (*ast.Options)(nil), }, }, }, diff --git a/testdata/result/statement/create_or_replace_view.sql.txt b/testdata/result/statement/create_or_replace_view.sql.txt index f66ace7f..59a20e48 100644 --- a/testdata/result/statement/create_or_replace_view.sql.txt +++ b/testdata/result/statement/create_or_replace_view.sql.txt @@ -8,8 +8,7 @@ from singers --- AST &ast.CreateView{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 23, @@ -21,10 +20,8 @@ from singers OrReplace: true, SecurityType: "INVOKER", Query: &ast.Select{ - Select: 59, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 59, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -107,16 +104,8 @@ from singers NameEnd: 169, Name: "singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/create_placement.sql.txt b/testdata/result/statement/create_placement.sql.txt index efbb1bc0..4cae85d1 100644 --- a/testdata/result/statement/create_placement.sql.txt +++ b/testdata/result/statement/create_placement.sql.txt @@ -2,8 +2,7 @@ CREATE PLACEMENT `europeplacement` OPTIONS (instance_partition="europe-partition") --- AST &ast.CreatePlacement{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 17, NameEnd: 34, Name: "europeplacement", diff --git a/testdata/result/statement/create_role.sql.txt b/testdata/result/statement/create_role.sql.txt index 1ee359a6..272ed16b 100644 --- a/testdata/result/statement/create_role.sql.txt +++ b/testdata/result/statement/create_role.sql.txt @@ -3,8 +3,7 @@ CREATE ROLE hr_manager --- AST &ast.CreateRole{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 12, NameEnd: 22, Name: "hr_manager", diff --git a/testdata/result/statement/create_schema.sql.txt b/testdata/result/statement/create_schema.sql.txt index 2b04f8f5..0d7bd8cd 100644 --- a/testdata/result/statement/create_schema.sql.txt +++ b/testdata/result/statement/create_schema.sql.txt @@ -2,8 +2,7 @@ CREATE SCHEMA sch1 --- AST &ast.CreateSchema{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 14, NameEnd: 18, Name: "sch1", diff --git a/testdata/result/statement/create_search_index_full.sql.txt b/testdata/result/statement/create_search_index_full.sql.txt index 299f2fe0..3f4d4b09 100644 --- a/testdata/result/statement/create_search_index_full.sql.txt +++ b/testdata/result/statement/create_search_index_full.sql.txt @@ -9,8 +9,7 @@ WHERE Genre IS NOT NULL AND ReleaseTimestamp IS NOT NULL OPTIONS(sort_order_sharding=true) --- AST &ast.CreateSearchIndex{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 35, Name: "AlbumsIndexFull", @@ -61,8 +60,7 @@ OPTIONS(sort_order_sharding=true) NameEnd: 137, Name: "ReleaseTimestamp", }, - Collate: (*ast.Collate)(nil), - Dir: "DESC", + Dir: "DESC", }, }, }, diff --git a/testdata/result/statement/create_search_index_null_filtered.sql.txt b/testdata/result/statement/create_search_index_null_filtered.sql.txt index f1fab7c1..d5729a3a 100644 --- a/testdata/result/statement/create_search_index_null_filtered.sql.txt +++ b/testdata/result/statement/create_search_index_null_filtered.sql.txt @@ -5,8 +5,7 @@ STORING(Genre) WHERE Genre IS NOT NULL --- AST &ast.CreateSearchIndex{ - Create: 0, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 31, Name: "AlbumsIndex", @@ -35,9 +34,7 @@ WHERE Genre IS NOT NULL }, }, }, - PartitionColumns: []*ast.Ident(nil), - OrderBy: (*ast.OrderBy)(nil), - Where: &ast.Where{ + Where: &ast.Where{ Where: 76, Expr: &ast.IsNullExpr{ Null: 95, @@ -49,8 +46,6 @@ WHERE Genre IS NOT NULL }, }, }, - Interleave: (*ast.InterleaveIn)(nil), - Options: (*ast.Options)(nil), } --- SQL diff --git a/testdata/result/statement/create_search_index_simple.sql.txt b/testdata/result/statement/create_search_index_simple.sql.txt index 60072aa5..157fa39d 100644 --- a/testdata/result/statement/create_search_index_simple.sql.txt +++ b/testdata/result/statement/create_search_index_simple.sql.txt @@ -22,13 +22,7 @@ CREATE SEARCH INDEX AlbumsIndex Name: "AlbumTitle_Tokens", }, }, - Rparen: 84, - Storing: (*ast.Storing)(nil), - PartitionColumns: []*ast.Ident(nil), - OrderBy: (*ast.OrderBy)(nil), - Where: (*ast.Where)(nil), - Interleave: (*ast.InterleaveIn)(nil), - Options: (*ast.Options)(nil), + Rparen: 84, } --- SQL diff --git a/testdata/result/statement/create_sequance.sql.txt b/testdata/result/statement/create_sequance.sql.txt index ffb91fe6..e38e825b 100644 --- a/testdata/result/statement/create_sequance.sql.txt +++ b/testdata/result/statement/create_sequance.sql.txt @@ -7,8 +7,7 @@ CREATE SEQUENCE IF NOT EXISTS MySequence OPTIONS ( --- AST &ast.CreateSequence{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 30, @@ -18,7 +17,6 @@ CREATE SEQUENCE IF NOT EXISTS MySequence OPTIONS ( }, }, IfNotExists: true, - Params: []ast.SequenceParam(nil), Options: &ast.Options{ Options: 41, Rparen: 172, diff --git a/testdata/result/statement/create_table.sql.txt b/testdata/result/statement/create_table.sql.txt index 9f7692d8..f3d84cdf 100644 --- a/testdata/result/statement/create_table.sql.txt +++ b/testdata/result/statement/create_table.sql.txt @@ -16,10 +16,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 573, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 573, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -40,12 +38,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: 50, @@ -58,12 +51,8 @@ create table foo ( NamePos: 38, Name: "FLOAT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 78, @@ -76,7 +65,6 @@ create table foo ( NamePos: 62, Rparen: 72, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 69, ValueEnd: 72, @@ -84,12 +72,9 @@ create table foo ( Value: "255", }, }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: &ast.Options{ + NotNull: true, + Hidden: -1, + Options: &ast.Options{ Options: 83, Rparen: 120, Records: []*ast.OptionsDef{ @@ -117,7 +102,6 @@ create table foo ( NamePos: 129, Rparen: 139, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 136, ValueEnd: 139, @@ -126,7 +110,6 @@ create table foo ( }, }, NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), GeneratedExpr: &ast.GeneratedColumnExpr{ As: 150, Stored: 172, @@ -138,8 +121,7 @@ create table foo ( NameEnd: 160, Name: "concat", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 161, @@ -155,14 +137,9 @@ create table foo ( }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -175,12 +152,7 @@ create table foo ( NamePos: 487, Name: "JSON", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: 515, @@ -204,23 +176,14 @@ create table foo ( NameEnd: 546, Name: "current_timestamp", }, - Distinct: false, - Args: []ast.Arg(nil), - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, TableConstraints: []*ast.TableConstraint{ &ast.TableConstraint{ ConstraintPos: -1, - Name: (*ast.Ident)(nil), Constraint: &ast.ForeignKey{ Foreign: 182, Rparen: 221, @@ -248,12 +211,10 @@ create table foo ( Name: "t2key1", }, }, - OnDelete: "", }, }, &ast.TableConstraint{ ConstraintPos: -1, - Name: (*ast.Ident)(nil), Constraint: &ast.ForeignKey{ Foreign: 226, Rparen: 265, @@ -286,7 +247,6 @@ create table foo ( }, &ast.TableConstraint{ ConstraintPos: -1, - Name: (*ast.Ident)(nil), Constraint: &ast.ForeignKey{ Foreign: 288, Rparen: 327, @@ -361,12 +321,10 @@ create table foo ( Name: "t2key2", }, }, - OnDelete: "", }, }, &ast.TableConstraint{ ConstraintPos: -1, - Name: (*ast.Ident)(nil), Constraint: &ast.Check{ Check: 427, Rparen: 441, @@ -421,7 +379,6 @@ create table foo ( NameEnd: 568, Name: "foo", }, - Dir: "", }, &ast.IndexKey{ DirPos: -1, @@ -430,12 +387,8 @@ create table foo ( NameEnd: 573, Name: "bar", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_cluster.sql.txt b/testdata/result/statement/create_table_cluster.sql.txt index bcce26e8..bacaadc3 100644 --- a/testdata/result/statement/create_table_cluster.sql.txt +++ b/testdata/result/statement/create_table_cluster.sql.txt @@ -7,10 +7,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 59, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 59, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -31,12 +29,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -49,18 +42,10 @@ create table foo ( NamePos: 38, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey(nil), - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 60, OnDeleteEnd: -1, TableName: &ast.Path{ @@ -72,9 +57,7 @@ create table foo ( }, }, }, - OnDelete: "", }, - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_cluster_and_row_deletion_policy.sql.txt b/testdata/result/statement/create_table_cluster_and_row_deletion_policy.sql.txt index b10f3b8e..0f37325d 100644 --- a/testdata/result/statement/create_table_cluster_and_row_deletion_policy.sql.txt +++ b/testdata/result/statement/create_table_cluster_and_row_deletion_policy.sql.txt @@ -9,10 +9,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 77, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 77, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -33,12 +31,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -51,12 +44,7 @@ create table foo ( NamePos: 38, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -69,18 +57,10 @@ create table foo ( NamePos: 51, Name: "TIMESTAMP", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey(nil), - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 78, OnDeleteEnd: -1, TableName: &ast.Path{ @@ -92,7 +72,6 @@ create table foo ( }, }, }, - OnDelete: "", }, RowDeletionPolicy: &ast.CreateRowDeletionPolicy{ Comma: 109, diff --git a/testdata/result/statement/create_table_cluster_on_delete_no_action.sql.txt b/testdata/result/statement/create_table_cluster_on_delete_no_action.sql.txt index cef4f6b3..393b0989 100644 --- a/testdata/result/statement/create_table_cluster_on_delete_no_action.sql.txt +++ b/testdata/result/statement/create_table_cluster_on_delete_no_action.sql.txt @@ -6,10 +6,8 @@ create table foo ( on delete no action --- AST &ast.CreateTable{ - Create: 0, - Rparen: 50, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 50, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -30,16 +28,10 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -47,11 +39,9 @@ create table foo ( NameEnd: 50, Name: "foo", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 51, OnDeleteEnd: 115, TableName: &ast.Path{ @@ -65,7 +55,6 @@ create table foo ( }, OnDelete: "ON DELETE NO ACTION", }, - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_cluster_set_on_delete.sql.txt b/testdata/result/statement/create_table_cluster_set_on_delete.sql.txt index 57616e41..8f8605c5 100644 --- a/testdata/result/statement/create_table_cluster_set_on_delete.sql.txt +++ b/testdata/result/statement/create_table_cluster_set_on_delete.sql.txt @@ -6,10 +6,8 @@ create table foo ( on delete cascade --- AST &ast.CreateTable{ - Create: 0, - Rparen: 49, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 49, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -30,16 +28,10 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -47,11 +39,9 @@ create table foo ( NameEnd: 49, Name: "foo", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 50, OnDeleteEnd: 112, TableName: &ast.Path{ @@ -65,7 +55,6 @@ create table foo ( }, OnDelete: "ON DELETE CASCADE", }, - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_fulltext_albums.sql.txt b/testdata/result/statement/create_table_fulltext_albums.sql.txt index 3bacaa14..7f90a442 100644 --- a/testdata/result/statement/create_table_fulltext_albums.sql.txt +++ b/testdata/result/statement/create_table_fulltext_albums.sql.txt @@ -11,10 +11,9 @@ CREATE TABLE Albums ( ) PRIMARY KEY(AlbumId) --- AST &ast.CreateTable{ - Create: 105, - Rparen: 575, - IfNotExists: false, - Name: &ast.Path{ + Create: 105, + Rparen: 575, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 118, @@ -36,14 +35,9 @@ CREATE TABLE Albums ( Rparen: 169, Name: "STRING", Max: true, - Size: nil, - }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + }, + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 224, @@ -56,12 +50,8 @@ CREATE TABLE Albums ( NamePos: 214, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 281, @@ -74,12 +64,8 @@ CREATE TABLE Albums ( NamePos: 271, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -93,14 +79,8 @@ CREATE TABLE Albums ( Rparen: 332, Name: "STRING", Max: true, - Size: nil, - }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + }, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -113,12 +93,7 @@ CREATE TABLE Albums ( NamePos: 366, Name: "FLOAT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -131,8 +106,6 @@ CREATE TABLE Albums ( NamePos: 417, Name: "TOKENLIST", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), GeneratedExpr: &ast.GeneratedColumnExpr{ As: 427, Stored: -1, @@ -144,8 +117,7 @@ CREATE TABLE Albums ( NameEnd: 448, Name: "TOKENIZE_FULLTEXT", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 449, @@ -154,14 +126,9 @@ CREATE TABLE Albums ( }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: 462, - Options: (*ast.Options)(nil), + Hidden: 462, }, &ast.ColumnDef{ Null: -1, @@ -174,8 +141,6 @@ CREATE TABLE Albums ( NamePos: 508, Name: "TOKENLIST", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), GeneratedExpr: &ast.GeneratedColumnExpr{ As: 518, Stored: -1, @@ -187,8 +152,7 @@ CREATE TABLE Albums ( NameEnd: 537, Name: "TOKENIZE_NUMBER", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Ident{ NamePos: 538, @@ -197,18 +161,12 @@ CREATE TABLE Albums ( }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: 547, - Options: (*ast.Options)(nil), + Hidden: 547, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -216,12 +174,8 @@ CREATE TABLE Albums ( NameEnd: 575, Name: "AlbumId", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_if_not_exists.sql.txt b/testdata/result/statement/create_table_if_not_exists.sql.txt index 54bf5846..b7b52448 100644 --- a/testdata/result/statement/create_table_if_not_exists.sql.txt +++ b/testdata/result/statement/create_table_if_not_exists.sql.txt @@ -6,7 +6,6 @@ create table if not exists foo ( --- AST &ast.CreateTable{ - Create: 0, Rparen: 93, IfNotExists: true, Name: &ast.Path{ @@ -30,12 +29,7 @@ create table if not exists foo ( NamePos: 39, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: 64, @@ -48,16 +42,11 @@ create table if not exists foo ( NamePos: 52, Name: "FLOAT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -65,7 +54,6 @@ create table if not exists foo ( NameEnd: 88, Name: "foo", }, - Dir: "", }, &ast.IndexKey{ DirPos: -1, @@ -74,12 +62,8 @@ create table if not exists foo ( NameEnd: 93, Name: "bar", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_row_deletion_policy.sql.txt b/testdata/result/statement/create_table_row_deletion_policy.sql.txt index 4ccdd66f..047b3cf6 100644 --- a/testdata/result/statement/create_table_row_deletion_policy.sql.txt +++ b/testdata/result/statement/create_table_row_deletion_policy.sql.txt @@ -8,10 +8,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 77, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 77, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -32,12 +30,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -50,12 +43,7 @@ create table foo ( NamePos: 38, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -68,18 +56,9 @@ create table foo ( NamePos: 51, Name: "TIMESTAMP", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey(nil), - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), RowDeletionPolicy: &ast.CreateRowDeletionPolicy{ Comma: 78, RowDeletionPolicy: &ast.RowDeletionPolicy{ diff --git a/testdata/result/statement/create_table_synonyms.sql.txt b/testdata/result/statement/create_table_synonyms.sql.txt index 0cdf1a53..1346e7d5 100644 --- a/testdata/result/statement/create_table_synonyms.sql.txt +++ b/testdata/result/statement/create_table_synonyms.sql.txt @@ -6,10 +6,8 @@ CREATE TABLE Singers ( ) PRIMARY KEY (SingerId) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 126, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 126, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -30,12 +28,8 @@ CREATE TABLE Singers ( NamePos: 36, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -48,7 +42,6 @@ CREATE TABLE Singers ( NamePos: 67, Rparen: 78, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 74, ValueEnd: 78, @@ -56,16 +49,10 @@ CREATE TABLE Singers ( Value: "1024", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -73,7 +60,6 @@ CREATE TABLE Singers ( NameEnd: 126, Name: "SingerId", }, - Dir: "", }, }, Synonyms: []*ast.Synonym{ @@ -87,8 +73,6 @@ CREATE TABLE Singers ( }, }, }, - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_synonyms_abnormal.sql.txt b/testdata/result/statement/create_table_synonyms_abnormal.sql.txt index 4c2f1993..43efa244 100644 --- a/testdata/result/statement/create_table_synonyms_abnormal.sql.txt +++ b/testdata/result/statement/create_table_synonyms_abnormal.sql.txt @@ -8,10 +8,9 @@ CREATE TABLE Singers ( ) PRIMARY KEY (SingerId) --- AST &ast.CreateTable{ - Create: 45, - Rparen: 194, - IfNotExists: false, - Name: &ast.Path{ + Create: 45, + Rparen: 194, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 58, @@ -32,12 +31,8 @@ CREATE TABLE Singers ( NamePos: 104, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -50,7 +45,6 @@ CREATE TABLE Singers ( NamePos: 135, Rparen: 146, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 142, ValueEnd: 146, @@ -58,16 +52,10 @@ CREATE TABLE Singers ( Value: "1024", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -75,7 +63,6 @@ CREATE TABLE Singers ( NameEnd: 194, Name: "SingerId", }, - Dir: "", }, }, Synonyms: []*ast.Synonym{ @@ -98,8 +85,6 @@ CREATE TABLE Singers ( }, }, }, - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_trailing_comma.sql.txt b/testdata/result/statement/create_table_trailing_comma.sql.txt index 013c1a92..0e7ddcdb 100644 --- a/testdata/result/statement/create_table_trailing_comma.sql.txt +++ b/testdata/result/statement/create_table_trailing_comma.sql.txt @@ -9,10 +9,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 83, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 83, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -33,12 +31,7 @@ create table foo ( NamePos: 25, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -51,16 +44,10 @@ create table foo ( NamePos: 38, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: 66, Name: &ast.Ident{ @@ -80,9 +67,6 @@ create table foo ( Dir: "DESC", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_types.sql.txt b/testdata/result/statement/create_table_types.sql.txt index e9a93352..0dd70563 100644 --- a/testdata/result/statement/create_table_types.sql.txt +++ b/testdata/result/statement/create_table_types.sql.txt @@ -13,14 +13,13 @@ create table types ( ab array, abs array, p examples.ProtoType, + af32vl array(vector_length=>128), ) primary key (i) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 252, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 297, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -41,12 +40,7 @@ create table types ( NamePos: 25, Name: "BOOL", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -59,12 +53,7 @@ create table types ( NamePos: 35, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -77,12 +66,7 @@ create table types ( NamePos: 48, Name: "FLOAT32", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -95,12 +79,7 @@ create table types ( NamePos: 61, Name: "FLOAT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -113,12 +92,7 @@ create table types ( NamePos: 74, Name: "DATE", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -131,12 +105,7 @@ create table types ( NamePos: 84, Name: "TIMESTAMP", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -149,7 +118,6 @@ create table types ( NamePos: 99, Rparen: 109, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 106, ValueEnd: 109, @@ -157,12 +125,7 @@ create table types ( Value: "256", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -176,14 +139,8 @@ create table types ( Rparen: 129, Name: "STRING", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -196,7 +153,6 @@ create table types ( NamePos: 137, Rparen: 146, Name: "BYTES", - Max: false, Size: &ast.IntLiteral{ ValuePos: 143, ValueEnd: 146, @@ -204,12 +160,7 @@ create table types ( Value: "256", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -223,14 +174,8 @@ create table types ( Rparen: 166, Name: "BYTES", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -240,19 +185,15 @@ create table types ( Name: "ab", }, Type: &ast.ArraySchemaType{ - Array: 174, - Gt: 184, - Item: &ast.ScalarSchemaType{ + Array: 174, + Gt: 184, + Rparen: -1, + Item: &ast.ScalarSchemaType{ NamePos: 180, Name: "BOOL", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -262,22 +203,17 @@ create table types ( Name: "abs", }, Type: &ast.ArraySchemaType{ - Array: 193, - Gt: 209, - Item: &ast.SizedSchemaType{ + Array: 193, + Gt: 209, + Rparen: -1, + Item: &ast.SizedSchemaType{ NamePos: 199, Rparen: 208, Name: "BYTES", Max: true, - Size: nil, }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -300,30 +236,53 @@ create table types ( }, }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, + }, + &ast.ColumnDef{ + Null: -1, + Name: &ast.Ident{ + NamePos: 238, + NameEnd: 244, + Name: "af32vl", + }, + Type: &ast.ArraySchemaType{ + Array: 245, + Gt: 258, + Rparen: 278, + Item: &ast.ScalarSchemaType{ + NamePos: 251, + Name: "FLOAT32", + }, + NamedArgs: []*ast.NamedArg{ + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 260, + NameEnd: 273, + Name: "vector_length", + }, + Value: &ast.IntLiteral{ + ValuePos: 275, + ValueEnd: 278, + Base: 10, + Value: "128", + }, + }, + }, + }, + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ - NamePos: 251, - NameEnd: 252, + NamePos: 296, + NameEnd: 297, Name: "i", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL -CREATE TABLE types (b BOOL, i INT64, f32 FLOAT32, f FLOAT64, d DATE, t TIMESTAMP, s STRING(256), smax STRING(MAX), bs BYTES(256), bsmax BYTES(MAX), ab ARRAY, abs ARRAY, p examples.ProtoType) PRIMARY KEY (i) +CREATE TABLE types (b BOOL, i INT64, f32 FLOAT32, f FLOAT64, d DATE, t TIMESTAMP, s STRING(256), smax STRING(MAX), bs BYTES(256), bsmax BYTES(MAX), ab ARRAY, abs ARRAY, p examples.ProtoType, af32vl ARRAY(vector_length => 128)) PRIMARY KEY (i) diff --git a/testdata/result/statement/create_table_with_identity_columns.sql.txt b/testdata/result/statement/create_table_with_identity_columns.sql.txt index 8b13d846..61c5f53b 100644 --- a/testdata/result/statement/create_table_with_identity_columns.sql.txt +++ b/testdata/result/statement/create_table_with_identity_columns.sql.txt @@ -11,10 +11,8 @@ create table foo ( --- AST &ast.CreateTable{ - Create: 0, - Rparen: 457, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 457, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -35,9 +33,6 @@ create table foo ( NamePos: 26, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), IdentityColumn: &ast.IdentityColumn{ Generated: 32, Identity: 56, @@ -72,8 +67,7 @@ create table foo ( }, }, }, - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -86,9 +80,6 @@ create table foo ( NamePos: 158, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), IdentityColumn: &ast.IdentityColumn{ Generated: 164, Identity: 188, @@ -108,8 +99,7 @@ create table foo ( }, }, }, - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -122,9 +112,6 @@ create table foo ( NamePos: 269, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), IdentityColumn: &ast.IdentityColumn{ Generated: 275, Identity: 299, @@ -150,8 +137,7 @@ create table foo ( }, }, }, - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -164,9 +150,6 @@ create table foo ( NamePos: 375, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), IdentityColumn: &ast.IdentityColumn{ Generated: 381, Identity: 405, @@ -177,12 +160,10 @@ create table foo ( }, }, }, - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -190,12 +171,8 @@ create table foo ( NameEnd: 457, Name: "id", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_table_with_sequence_function.sql.txt b/testdata/result/statement/create_table_with_sequence_function.sql.txt index 0eb6c3c7..cb4bd4d0 100644 --- a/testdata/result/statement/create_table_with_sequence_function.sql.txt +++ b/testdata/result/statement/create_table_with_sequence_function.sql.txt @@ -8,10 +8,8 @@ CREATE TABLE foo --- AST &ast.CreateTable{ - Create: 0, - Rparen: 143, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 143, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -32,7 +30,6 @@ CREATE TABLE foo NamePos: 27, Name: "INT64", }, - NotNull: false, DefaultExpr: &ast.ColumnDefaultExpr{ Default: 33, Rparen: 88, @@ -43,8 +40,7 @@ CREATE TABLE foo NameEnd: 65, Name: "GET_NEXT_SEQUENCE_VALUE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.SequenceArg{ Sequence: 66, Expr: &ast.Ident{ @@ -54,15 +50,9 @@ CREATE TABLE foo }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -76,14 +66,8 @@ CREATE TABLE foo Rparen: 110, Name: "STRING", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -96,16 +80,10 @@ CREATE TABLE foo NamePos: 121, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -113,12 +91,8 @@ CREATE TABLE foo NameEnd: 143, Name: "id", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/create_uniq_null_filtered_index.sql.txt b/testdata/result/statement/create_uniq_null_filtered_index.sql.txt index 8337e5b6..c6f2a636 100644 --- a/testdata/result/statement/create_uniq_null_filtered_index.sql.txt +++ b/testdata/result/statement/create_uniq_null_filtered_index.sql.txt @@ -3,11 +3,9 @@ create unique null_filtered index foo_bar on foo (foo) --- AST &ast.CreateIndex{ - Create: 0, Rparen: 53, Unique: true, NullFiltered: true, - IfNotExists: false, Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ @@ -34,12 +32,9 @@ create unique null_filtered index foo_bar on foo (foo) NameEnd: 53, Name: "foo", }, - Dir: "", }, }, - Storing: (*ast.Storing)(nil), - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE UNIQUE NULL_FILTERED INDEX foo_bar ON foo (foo) +CREATE UNIQUE NULL_FILTERED INDEX foo_bar ON foo(foo) diff --git a/testdata/result/statement/create_vector_index.sql.txt b/testdata/result/statement/create_vector_index.sql.txt index ed7d5a6c..e2b93b86 100644 --- a/testdata/result/statement/create_vector_index.sql.txt +++ b/testdata/result/statement/create_vector_index.sql.txt @@ -3,7 +3,6 @@ CREATE VECTOR INDEX IF NOT EXISTS hello_vector_index ON hello(embedding) OPTIONS(distance_type = 'COSINE') --- AST &ast.CreateVectorIndex{ - Create: 0, IfNotExists: true, Name: &ast.Ident{ NamePos: 34, @@ -20,7 +19,6 @@ OPTIONS(distance_type = 'COSINE') NameEnd: 71, Name: "embedding", }, - Where: (*ast.Where)(nil), Options: &ast.Options{ Options: 73, Rparen: 105, diff --git a/testdata/result/statement/create_vector_index_where_column_not_null.sql.txt b/testdata/result/statement/create_vector_index_where_column_not_null.sql.txt index 965499aa..b77f7dea 100644 --- a/testdata/result/statement/create_vector_index_where_column_not_null.sql.txt +++ b/testdata/result/statement/create_vector_index_where_column_not_null.sql.txt @@ -4,9 +4,7 @@ WHERE embedding IS NOT NULL OPTIONS(distance_type = 'COSINE') --- AST &ast.CreateVectorIndex{ - Create: 0, - IfNotExists: false, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 20, NameEnd: 38, Name: "hello_vector_index", diff --git a/testdata/result/statement/create_view.sql.txt b/testdata/result/statement/create_view.sql.txt index 09d3e5f3..7842821f 100644 --- a/testdata/result/statement/create_view.sql.txt +++ b/testdata/result/statement/create_view.sql.txt @@ -8,8 +8,7 @@ from singers --- AST &ast.CreateView{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -18,13 +17,10 @@ from singers }, }, }, - OrReplace: false, SecurityType: "INVOKER", Query: &ast.Select{ - Select: 48, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 48, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -107,16 +103,8 @@ from singers NameEnd: 158, Name: "singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/create_view_sql_security_definer.sql.txt b/testdata/result/statement/create_view_sql_security_definer.sql.txt index 345b29a3..a04d0c2f 100644 --- a/testdata/result/statement/create_view_sql_security_definer.sql.txt +++ b/testdata/result/statement/create_view_sql_security_definer.sql.txt @@ -8,8 +8,7 @@ from singers --- AST &ast.CreateView{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -18,13 +17,10 @@ from singers }, }, }, - OrReplace: false, SecurityType: "DEFINER", Query: &ast.Select{ - Select: 48, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 48, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -107,16 +103,8 @@ from singers NameEnd: 158, Name: "singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/delete _from.sql.txt b/testdata/result/statement/delete _from.sql.txt index 29eddeae..ef9d1756 100644 --- a/testdata/result/statement/delete _from.sql.txt +++ b/testdata/result/statement/delete _from.sql.txt @@ -2,13 +2,11 @@ delete from foo where foo = 1 and bar = 2 --- AST &ast.Delete{ - Delete: 0, TableName: &ast.Ident{ NamePos: 12, NameEnd: 15, Name: "foo", }, - As: (*ast.AsAlias)(nil), Where: &ast.Where{ Where: 16, Expr: &ast.BinaryExpr{ @@ -43,7 +41,6 @@ delete from foo where foo = 1 and bar = 2 }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/delete.sql.txt b/testdata/result/statement/delete.sql.txt index 1bf07ded..6c7b6ce8 100644 --- a/testdata/result/statement/delete.sql.txt +++ b/testdata/result/statement/delete.sql.txt @@ -2,13 +2,11 @@ delete foo where foo = 1 and bar = 2 --- AST &ast.Delete{ - Delete: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", }, - As: (*ast.AsAlias)(nil), Where: &ast.Where{ Where: 11, Expr: &ast.BinaryExpr{ @@ -43,7 +41,6 @@ delete foo where foo = 1 and bar = 2 }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/delete_as.sql.txt b/testdata/result/statement/delete_as.sql.txt index 36c330e3..f0758fd5 100644 --- a/testdata/result/statement/delete_as.sql.txt +++ b/testdata/result/statement/delete_as.sql.txt @@ -2,7 +2,6 @@ delete foo as F where F.foo = 1 --- AST &ast.Delete{ - Delete: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, @@ -42,7 +41,6 @@ delete foo as F where F.foo = 1 }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/delete_then_return.sql.txt b/testdata/result/statement/delete_then_return.sql.txt index 94b742a1..6c160a1f 100644 --- a/testdata/result/statement/delete_then_return.sql.txt +++ b/testdata/result/statement/delete_then_return.sql.txt @@ -2,13 +2,11 @@ delete foo where foo = 1 and bar = 2 then return * --- AST &ast.Delete{ - Delete: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", }, - As: (*ast.AsAlias)(nil), Where: &ast.Where{ Where: 11, Expr: &ast.BinaryExpr{ @@ -44,9 +42,8 @@ delete foo where foo = 1 and bar = 2 then return * }, }, ThenReturn: &ast.ThenReturn{ - Then: 37, - WithAction: (*ast.WithAction)(nil), - Items: []ast.SelectItem{ + Then: 37, + Items: []ast.SelectItem{ &ast.Star{ Star: 49, }, diff --git a/testdata/result/statement/drop_change_stream.sql.txt b/testdata/result/statement/drop_change_stream.sql.txt index ecbe86f7..edac2ca2 100644 --- a/testdata/result/statement/drop_change_stream.sql.txt +++ b/testdata/result/statement/drop_change_stream.sql.txt @@ -3,7 +3,6 @@ DROP CHANGE STREAM change_stream_name --- AST &ast.DropChangeStream{ - Drop: 0, Name: &ast.Ident{ NamePos: 19, NameEnd: 37, diff --git a/testdata/result/statement/drop_index.sql.txt b/testdata/result/statement/drop_index.sql.txt index 47ac6572..1896e268 100644 --- a/testdata/result/statement/drop_index.sql.txt +++ b/testdata/result/statement/drop_index.sql.txt @@ -3,9 +3,7 @@ drop index foo_bar --- AST &ast.DropIndex{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 11, diff --git a/testdata/result/statement/drop_index_if_exists.sql.txt b/testdata/result/statement/drop_index_if_exists.sql.txt index 54cf0a6a..5b190902 100644 --- a/testdata/result/statement/drop_index_if_exists.sql.txt +++ b/testdata/result/statement/drop_index_if_exists.sql.txt @@ -3,7 +3,6 @@ drop index if exists foo_bar --- AST &ast.DropIndex{ - Drop: 0, IfExists: true, Name: &ast.Path{ Idents: []*ast.Ident{ diff --git a/testdata/result/statement/drop_model.sql.txt b/testdata/result/statement/drop_model.sql.txt index be705286..c75558e9 100644 --- a/testdata/result/statement/drop_model.sql.txt +++ b/testdata/result/statement/drop_model.sql.txt @@ -2,9 +2,7 @@ DROP MODEL MyClassificationModel --- AST &ast.DropModel{ - Drop: 0, - IfExists: false, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 11, NameEnd: 32, Name: "MyClassificationModel", diff --git a/testdata/result/statement/drop_model_if_exists.sql.txt b/testdata/result/statement/drop_model_if_exists.sql.txt index 67ac03dc..99e670a2 100644 --- a/testdata/result/statement/drop_model_if_exists.sql.txt +++ b/testdata/result/statement/drop_model_if_exists.sql.txt @@ -2,7 +2,6 @@ DROP MODEL IF EXISTS MyClassificationModel --- AST &ast.DropModel{ - Drop: 0, IfExists: true, Name: &ast.Ident{ NamePos: 21, diff --git a/testdata/result/statement/drop_proto_bunldle.sql.txt b/testdata/result/statement/drop_proto_bunldle.sql.txt index b36d664b..3f5c6f02 100644 --- a/testdata/result/statement/drop_proto_bunldle.sql.txt +++ b/testdata/result/statement/drop_proto_bunldle.sql.txt @@ -2,7 +2,6 @@ DROP PROTO BUNDLE --- AST &ast.DropProtoBundle{ - Drop: 0, Bundle: 11, } diff --git a/testdata/result/statement/drop_role.sql.txt b/testdata/result/statement/drop_role.sql.txt index 62eadcab..45972f1a 100644 --- a/testdata/result/statement/drop_role.sql.txt +++ b/testdata/result/statement/drop_role.sql.txt @@ -3,7 +3,6 @@ DROP ROLE hr_manager --- AST &ast.DropRole{ - Drop: 0, Name: &ast.Ident{ NamePos: 10, NameEnd: 20, diff --git a/testdata/result/statement/drop_schema.sql.txt b/testdata/result/statement/drop_schema.sql.txt index b9356805..9916952a 100644 --- a/testdata/result/statement/drop_schema.sql.txt +++ b/testdata/result/statement/drop_schema.sql.txt @@ -2,7 +2,6 @@ DROP SCHEMA sch1 --- AST &ast.DropSchema{ - Drop: 0, Name: &ast.Ident{ NamePos: 12, NameEnd: 16, diff --git a/testdata/result/statement/drop_search_index.sql.txt b/testdata/result/statement/drop_search_index.sql.txt index fe6d374c..ca99f2d1 100644 --- a/testdata/result/statement/drop_search_index.sql.txt +++ b/testdata/result/statement/drop_search_index.sql.txt @@ -2,7 +2,6 @@ DROP SEARCH INDEX IF EXISTS AlbumsIndex --- AST &ast.DropSearchIndex{ - Drop: 0, IfExists: true, Name: &ast.Ident{ NamePos: 28, diff --git a/testdata/result/statement/drop_sequence.sql.txt b/testdata/result/statement/drop_sequence.sql.txt index 74d0585c..b8a4b84e 100644 --- a/testdata/result/statement/drop_sequence.sql.txt +++ b/testdata/result/statement/drop_sequence.sql.txt @@ -3,9 +3,7 @@ DROP SEQUENCE my_sequence --- AST &ast.DropSequence{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 14, diff --git a/testdata/result/statement/drop_sequence_if_exits.sql.txt b/testdata/result/statement/drop_sequence_if_exits.sql.txt index f8dd5731..34c58016 100644 --- a/testdata/result/statement/drop_sequence_if_exits.sql.txt +++ b/testdata/result/statement/drop_sequence_if_exits.sql.txt @@ -3,7 +3,6 @@ DROP SEQUENCE IF EXISTS my_sequence --- AST &ast.DropSequence{ - Drop: 0, IfExists: true, Name: &ast.Path{ Idents: []*ast.Ident{ diff --git a/testdata/result/statement/drop_table.sql.txt b/testdata/result/statement/drop_table.sql.txt index 099b9936..727dfa76 100644 --- a/testdata/result/statement/drop_table.sql.txt +++ b/testdata/result/statement/drop_table.sql.txt @@ -3,9 +3,7 @@ drop table foo --- AST &ast.DropTable{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 11, diff --git a/testdata/result/statement/drop_table_if_exists.sql.txt b/testdata/result/statement/drop_table_if_exists.sql.txt index de5578ca..053346fe 100644 --- a/testdata/result/statement/drop_table_if_exists.sql.txt +++ b/testdata/result/statement/drop_table_if_exists.sql.txt @@ -3,7 +3,6 @@ drop table if exists foo --- AST &ast.DropTable{ - Drop: 0, IfExists: true, Name: &ast.Path{ Idents: []*ast.Ident{ diff --git a/testdata/result/statement/drop_vector_index.sql.txt b/testdata/result/statement/drop_vector_index.sql.txt index 6c7fa9e2..f9a30112 100644 --- a/testdata/result/statement/drop_vector_index.sql.txt +++ b/testdata/result/statement/drop_vector_index.sql.txt @@ -2,9 +2,7 @@ DROP VECTOR INDEX hello_vector_index --- AST &ast.DropVectorIndex{ - Drop: 0, - IfExists: false, - Name: &ast.Ident{ + Name: &ast.Ident{ NamePos: 18, NameEnd: 36, Name: "hello_vector_index", diff --git a/testdata/result/statement/drop_view.sql.txt b/testdata/result/statement/drop_view.sql.txt index 959ce82d..c3c58848 100644 --- a/testdata/result/statement/drop_view.sql.txt +++ b/testdata/result/statement/drop_view.sql.txt @@ -2,7 +2,6 @@ DROP VIEW SingersView --- AST &ast.DropView{ - Drop: 0, Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ diff --git a/testdata/result/statement/edge_case_dot_star_except.sql.txt b/testdata/result/statement/edge_case_dot_star_except.sql.txt new file mode 100644 index 00000000..c4a182e7 --- /dev/null +++ b/testdata/result/statement/edge_case_dot_star_except.sql.txt @@ -0,0 +1,101 @@ +--- edge_case_dot_star_except.sql +SELECT (SELECT T.* EXCEPT (s)) AS n FROM (SELECT 1 AS n, "foo" AS s) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.ScalarSubQuery{ + Lparen: 7, + Rparen: 29, + Query: &ast.Select{ + Select: 8, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 17, + Expr: &ast.Ident{ + NamePos: 15, + NameEnd: 16, + Name: "T", + }, + Except: &ast.StarModifierExcept{ + Except: 19, + Rparen: 28, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 27, + NameEnd: 28, + Name: "s", + }, + }, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 31, + Alias: &ast.Ident{ + NamePos: 34, + NameEnd: 35, + Name: "n", + }, + }, + }, + }, + From: &ast.From{ + From: 36, + Source: &ast.SubQueryTableExpr{ + Lparen: 41, + Rparen: 67, + Query: &ast.Select{ + Select: 42, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 49, + ValueEnd: 50, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: 51, + Alias: &ast.Ident{ + NamePos: 54, + NameEnd: 55, + Name: "n", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 57, + ValueEnd: 62, + Value: "foo", + }, + As: &ast.AsAlias{ + As: 63, + Alias: &ast.Ident{ + NamePos: 66, + NameEnd: 67, + Name: "s", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 69, + Alias: &ast.Ident{ + NamePos: 72, + NameEnd: 73, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT (SELECT T.* EXCEPT (s)) AS n FROM (SELECT 1 AS n, "foo" AS s) AS T diff --git a/testdata/result/statement/edge_case_dot_star_except_all.sql.txt b/testdata/result/statement/edge_case_dot_star_except_all.sql.txt new file mode 100644 index 00000000..43f7a941 --- /dev/null +++ b/testdata/result/statement/edge_case_dot_star_except_all.sql.txt @@ -0,0 +1,94 @@ +--- edge_case_dot_star_except_all.sql +SELECT (SELECT T.* EXCEPT ALL SELECT T.*) AS n FROM (SELECT 1 AS n) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.ScalarSubQuery{ + Lparen: 7, + Rparen: 40, + Query: &ast.CompoundQuery{ + Op: "EXCEPT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ + &ast.Select{ + Select: 8, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 17, + Expr: &ast.Ident{ + NamePos: 15, + NameEnd: 16, + Name: "T", + }, + }, + }, + }, + &ast.Select{ + Select: 30, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 39, + Expr: &ast.Ident{ + NamePos: 37, + NameEnd: 38, + Name: "T", + }, + }, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 42, + Alias: &ast.Ident{ + NamePos: 45, + NameEnd: 46, + Name: "n", + }, + }, + }, + }, + From: &ast.From{ + From: 47, + Source: &ast.SubQueryTableExpr{ + Lparen: 52, + Rparen: 66, + Query: &ast.Select{ + Select: 53, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 60, + ValueEnd: 61, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: 62, + Alias: &ast.Ident{ + NamePos: 65, + NameEnd: 66, + Name: "n", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 68, + Alias: &ast.Ident{ + NamePos: 71, + NameEnd: 72, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT (SELECT T.* EXCEPT ALL SELECT T.*) AS n FROM (SELECT 1 AS n) AS T diff --git a/testdata/result/statement/edge_case_dot_star_except_distinct.sql.txt b/testdata/result/statement/edge_case_dot_star_except_distinct.sql.txt new file mode 100644 index 00000000..fd8ecccc --- /dev/null +++ b/testdata/result/statement/edge_case_dot_star_except_distinct.sql.txt @@ -0,0 +1,94 @@ +--- edge_case_dot_star_except_distinct.sql +SELECT (SELECT T.* EXCEPT DISTINCT SELECT T.*) AS n FROM (SELECT 1 AS n) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.ScalarSubQuery{ + Lparen: 7, + Rparen: 45, + Query: &ast.CompoundQuery{ + Op: "EXCEPT", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ + &ast.Select{ + Select: 8, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 17, + Expr: &ast.Ident{ + NamePos: 15, + NameEnd: 16, + Name: "T", + }, + }, + }, + }, + &ast.Select{ + Select: 35, + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 44, + Expr: &ast.Ident{ + NamePos: 42, + NameEnd: 43, + Name: "T", + }, + }, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 47, + Alias: &ast.Ident{ + NamePos: 50, + NameEnd: 51, + Name: "n", + }, + }, + }, + }, + From: &ast.From{ + From: 52, + Source: &ast.SubQueryTableExpr{ + Lparen: 57, + Rparen: 71, + Query: &ast.Select{ + Select: 58, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 65, + ValueEnd: 66, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: 67, + Alias: &ast.Ident{ + NamePos: 70, + NameEnd: 71, + Name: "n", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 73, + Alias: &ast.Ident{ + NamePos: 76, + NameEnd: 77, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT (SELECT T.* EXCEPT DISTINCT SELECT T.*) AS n FROM (SELECT 1 AS n) AS T diff --git a/testdata/result/statement/from_query.sql.txt b/testdata/result/statement/from_query.sql.txt new file mode 100644 index 00000000..4276cf6c --- /dev/null +++ b/testdata/result/statement/from_query.sql.txt @@ -0,0 +1,19 @@ +--- from_query.sql +FROM Singers +--- AST +&ast.QueryStatement{ + Query: &ast.FromQuery{ + From: &ast.From{ + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 5, + NameEnd: 12, + Name: "Singers", + }, + }, + }, + }, +} + +--- SQL +FROM Singers diff --git a/testdata/result/statement/grant_change_stream_privilege.sql.txt b/testdata/result/statement/grant_change_stream_privilege.sql.txt index 92016944..7bae5ed3 100644 --- a/testdata/result/statement/grant_change_stream_privilege.sql.txt +++ b/testdata/result/statement/grant_change_stream_privilege.sql.txt @@ -2,7 +2,6 @@ GRANT SELECT ON CHANGE STREAM cs_name_one, cs_name_two TO ROLE hr_manager --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.SelectPrivilegeOnChangeStream{ Select: 6, Names: []*ast.Ident{ diff --git a/testdata/result/statement/grant_execute_on_table_function.sql.txt b/testdata/result/statement/grant_execute_on_table_function.sql.txt index a7b0f16d..c3070368 100644 --- a/testdata/result/statement/grant_execute_on_table_function.sql.txt +++ b/testdata/result/statement/grant_execute_on_table_function.sql.txt @@ -2,7 +2,6 @@ GRANT EXECUTE ON TABLE FUNCTION READ_SingersNameStream TO ROLE hr_manager --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.ExecutePrivilegeOnTableFunction{ Execute: 6, Names: []*ast.Ident{ diff --git a/testdata/result/statement/grant_privileges.sql.txt b/testdata/result/statement/grant_privileges.sql.txt index 12634b04..b9cc5586 100644 --- a/testdata/result/statement/grant_privileges.sql.txt +++ b/testdata/result/statement/grant_privileges.sql.txt @@ -3,7 +3,6 @@ GRANT SELECT(name, level, location), UPDATE(location) ON TABLE employees, contra --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.PrivilegeOnTable{ Privileges: []ast.TablePrivilege{ &ast.SelectPrivilege{ diff --git a/testdata/result/statement/grant_role.sql.txt b/testdata/result/statement/grant_role.sql.txt index b748b957..c5df7aff 100644 --- a/testdata/result/statement/grant_role.sql.txt +++ b/testdata/result/statement/grant_role.sql.txt @@ -3,7 +3,6 @@ GRANT ROLE pii_access, pii_writter TO ROLE hr_manager, hr_director --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.RolePrivilege{ Role: 6, Names: []*ast.Ident{ diff --git a/testdata/result/statement/grant_select_on_view.sql.txt b/testdata/result/statement/grant_select_on_view.sql.txt index 0c96a499..dbab8e74 100644 --- a/testdata/result/statement/grant_select_on_view.sql.txt +++ b/testdata/result/statement/grant_select_on_view.sql.txt @@ -2,7 +2,6 @@ GRANT SELECT ON VIEW singernames TO ROLE hr_manager --- AST &ast.Grant{ - Grant: 0, Privilege: &ast.SelectPrivilegeOnView{ Select: 6, Names: []*ast.Ident{ diff --git a/testdata/result/statement/insert_cte_select.sql.txt b/testdata/result/statement/insert_cte_select.sql.txt new file mode 100644 index 00000000..13e64ec7 --- /dev/null +++ b/testdata/result/statement/insert_cte_select.sql.txt @@ -0,0 +1,89 @@ +--- insert_cte_select.sql +insert foo (foo, bar) +with cte AS (select 1 as foo, 2 as bar) +select * +--- AST +&ast.Insert{ + TableName: &ast.Ident{ + NamePos: 7, + NameEnd: 10, + Name: "foo", + }, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 12, + NameEnd: 15, + Name: "foo", + }, + &ast.Ident{ + NamePos: 17, + NameEnd: 20, + Name: "bar", + }, + }, + Input: &ast.SubQueryInput{ + Query: &ast.Query{ + With: &ast.With{ + With: 22, + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 60, + Name: &ast.Ident{ + NamePos: 27, + NameEnd: 30, + Name: "cte", + }, + QueryExpr: &ast.Select{ + Select: 35, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 42, + ValueEnd: 43, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: 44, + Alias: &ast.Ident{ + NamePos: 47, + NameEnd: 50, + Name: "foo", + }, + }, + }, + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 52, + ValueEnd: 53, + Base: 10, + Value: "2", + }, + As: &ast.AsAlias{ + As: 54, + Alias: &ast.Ident{ + NamePos: 57, + NameEnd: 60, + Name: "bar", + }, + }, + }, + }, + }, + }, + }, + }, + Query: &ast.Select{ + Select: 62, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 69, + }, + }, + }, + }, + }, +} + +--- SQL +INSERT INTO foo (foo, bar) WITH cte AS (SELECT 1 AS foo, 2 AS bar) SELECT * diff --git a/testdata/result/statement/insert_into_values.sql.txt b/testdata/result/statement/insert_into_values.sql.txt index dc897ce3..670a2c4b 100644 --- a/testdata/result/statement/insert_into_values.sql.txt +++ b/testdata/result/statement/insert_into_values.sql.txt @@ -4,9 +4,7 @@ values (1, 2, 3), (4, 5, 6) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 12, NameEnd: 15, Name: "foo", @@ -37,7 +35,6 @@ values (1, 2, 3), Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 40, ValueEnd: 41, @@ -47,7 +44,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 43, ValueEnd: 44, @@ -57,7 +53,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 46, ValueEnd: 47, @@ -73,7 +68,6 @@ values (1, 2, 3), Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 58, ValueEnd: 59, @@ -83,7 +77,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 61, ValueEnd: 62, @@ -93,7 +86,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 64, ValueEnd: 65, @@ -105,7 +97,6 @@ values (1, 2, 3), }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/insert_or_ignore.sql.txt b/testdata/result/statement/insert_or_ignore.sql.txt index 9994ff8e..43d4b19e 100644 --- a/testdata/result/statement/insert_or_ignore.sql.txt +++ b/testdata/result/statement/insert_or_ignore.sql.txt @@ -3,7 +3,6 @@ INSERT OR IGNORE INTO foo (foo, bar) VALUES (1, 2) --- AST &ast.Insert{ - Insert: 0, InsertOrType: "IGNORE", TableName: &ast.Ident{ NamePos: 22, @@ -31,7 +30,6 @@ INSERT OR IGNORE INTO foo Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 45, ValueEnd: 46, @@ -41,7 +39,6 @@ INSERT OR IGNORE INTO foo }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 48, ValueEnd: 49, @@ -53,7 +50,6 @@ INSERT OR IGNORE INTO foo }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/insert_or_update.sql.txt b/testdata/result/statement/insert_or_update.sql.txt index a87b61f8..4ecc3acc 100644 --- a/testdata/result/statement/insert_or_update.sql.txt +++ b/testdata/result/statement/insert_or_update.sql.txt @@ -3,7 +3,6 @@ INSERT OR UPDATE INTO foo (foo, bar) VALUES (1, 2) --- AST &ast.Insert{ - Insert: 0, InsertOrType: "UPDATE", TableName: &ast.Ident{ NamePos: 22, @@ -31,7 +30,6 @@ INSERT OR UPDATE INTO foo Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 45, ValueEnd: 46, @@ -41,7 +39,6 @@ INSERT OR UPDATE INTO foo }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 48, ValueEnd: 49, @@ -53,7 +50,6 @@ INSERT OR UPDATE INTO foo }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/insert_or_update_then_return_with_action_as.sql.txt b/testdata/result/statement/insert_or_update_then_return_with_action_as.sql.txt index ab5e4a6d..665e0e2a 100644 --- a/testdata/result/statement/insert_or_update_then_return_with_action_as.sql.txt +++ b/testdata/result/statement/insert_or_update_then_return_with_action_as.sql.txt @@ -4,7 +4,6 @@ INSERT OR UPDATE INTO foo THEN RETURN WITH ACTION AS act * --- AST &ast.Insert{ - Insert: 0, InsertOrType: "UPDATE", TableName: &ast.Ident{ NamePos: 22, @@ -32,7 +31,6 @@ THEN RETURN WITH ACTION AS act * Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 45, ValueEnd: 46, @@ -42,7 +40,6 @@ THEN RETURN WITH ACTION AS act * }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 48, ValueEnd: 49, diff --git a/testdata/result/statement/insert_select.sql.txt b/testdata/result/statement/insert_select.sql.txt index 5b3b5590..2b2e713b 100644 --- a/testdata/result/statement/insert_select.sql.txt +++ b/testdata/result/statement/insert_select.sql.txt @@ -3,9 +3,7 @@ insert foo (foo, bar) select * from unnest([(1, 2), (3, 4)]) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", @@ -24,10 +22,8 @@ select * from unnest([(1, 2), (3, 4)]) }, Input: &ast.SubQueryInput{ Query: &ast.Select{ - Select: 22, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 22, + Results: []ast.SelectItem{ &ast.Star{ Star: 29, }, @@ -41,7 +37,6 @@ select * from unnest([(1, 2), (3, 4)]) Array: -1, Lbrack: 43, Rbrack: 58, - Type: nil, Values: []ast.Expr{ &ast.TupleStructLiteral{ Lparen: 44, @@ -81,20 +76,10 @@ select * from unnest([(1, 2), (3, 4)]) }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/insert_values.sql.txt b/testdata/result/statement/insert_values.sql.txt index aae84cad..e791c60d 100644 --- a/testdata/result/statement/insert_values.sql.txt +++ b/testdata/result/statement/insert_values.sql.txt @@ -4,9 +4,7 @@ values (1, 2, 3), (4, 5, 6) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", @@ -37,7 +35,6 @@ values (1, 2, 3), Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 35, ValueEnd: 36, @@ -47,7 +44,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 38, ValueEnd: 39, @@ -57,7 +53,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 41, ValueEnd: 42, @@ -73,7 +68,6 @@ values (1, 2, 3), Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 53, ValueEnd: 54, @@ -83,7 +77,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 56, ValueEnd: 57, @@ -93,7 +86,6 @@ values (1, 2, 3), }, &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 59, ValueEnd: 60, @@ -105,7 +97,6 @@ values (1, 2, 3), }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/insert_values_default.sql.txt b/testdata/result/statement/insert_values_default.sql.txt index 2b3b0083..b379cda6 100644 --- a/testdata/result/statement/insert_values_default.sql.txt +++ b/testdata/result/statement/insert_values_default.sql.txt @@ -3,9 +3,7 @@ insert foo (foo, bar) values (1, default) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", @@ -31,7 +29,6 @@ values (1, default) Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.IntLiteral{ ValuePos: 30, ValueEnd: 31, @@ -42,13 +39,11 @@ values (1, default) &ast.DefaultExpr{ DefaultPos: 33, Default: true, - Expr: nil, }, }, }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/insert_with_sequence_function.sql.txt b/testdata/result/statement/insert_with_sequence_function.sql.txt index c78a7cd4..0183ca51 100644 --- a/testdata/result/statement/insert_with_sequence_function.sql.txt +++ b/testdata/result/statement/insert_with_sequence_function.sql.txt @@ -3,9 +3,7 @@ INSERT INTO foo(bar) VALUES (GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence)) --- AST &ast.Insert{ - Insert: 0, - InsertOrType: "", - TableName: &ast.Ident{ + TableName: &ast.Ident{ NamePos: 12, NameEnd: 15, Name: "foo", @@ -26,7 +24,6 @@ INSERT INTO foo(bar) VALUES (GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence)) Exprs: []*ast.DefaultExpr{ &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.CallExpr{ Rparen: 73, Func: &ast.Ident{ @@ -34,8 +31,7 @@ INSERT INTO foo(bar) VALUES (GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence)) NameEnd: 52, Name: "GET_NEXT_SEQUENCE_VALUE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.SequenceArg{ Sequence: 53, Expr: &ast.Ident{ @@ -45,16 +41,12 @@ INSERT INTO foo(bar) VALUES (GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence)) }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, }, }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/named_schema_create_table_backquoted.sql.txt b/testdata/result/statement/named_schema_create_table_backquoted.sql.txt index 2773b76e..f2c9bff6 100644 --- a/testdata/result/statement/named_schema_create_table_backquoted.sql.txt +++ b/testdata/result/statement/named_schema_create_table_backquoted.sql.txt @@ -2,10 +2,8 @@ CREATE TABLE `ORDER`.`ORDER`(PK INT64) PRIMARY KEY(PK) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 53, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 53, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -31,16 +29,10 @@ CREATE TABLE `ORDER`.`ORDER`(PK INT64) PRIMARY KEY(PK) NamePos: 32, Name: "INT64", }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -48,12 +40,8 @@ CREATE TABLE `ORDER`.`ORDER`(PK INT64) PRIMARY KEY(PK) NameEnd: 53, Name: "PK", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/named_schemas_alter_index.sql.txt b/testdata/result/statement/named_schemas_alter_index.sql.txt index 9d5151de..5fd00cd8 100644 --- a/testdata/result/statement/named_schemas_alter_index.sql.txt +++ b/testdata/result/statement/named_schemas_alter_index.sql.txt @@ -2,8 +2,7 @@ ALTER INDEX sch1.indexOnSingers ADD STORED COLUMN SingerInfo --- AST &ast.AlterIndex{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/named_schemas_alter_sequence.sql.txt b/testdata/result/statement/named_schemas_alter_sequence.sql.txt index 31ef7b41..35240b72 100644 --- a/testdata/result/statement/named_schemas_alter_sequence.sql.txt +++ b/testdata/result/statement/named_schemas_alter_sequence.sql.txt @@ -3,8 +3,7 @@ ALTER SEQUENCE sch1.sequence SET OPTIONS (skip_range_min=1, skip_range_max=1234567) --- AST &ast.AlterSequence{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 15, @@ -50,9 +49,6 @@ ALTER SEQUENCE sch1.sequence }, }, }, - RestartCounterWith: (*ast.RestartCounterWith)(nil), - SkipRange: (*ast.SkipRange)(nil), - NoSkipRange: (*ast.NoSkipRange)(nil), } --- SQL diff --git a/testdata/result/statement/named_schemas_alter_table_add_constraint.sql.txt b/testdata/result/statement/named_schemas_alter_table_add_constraint.sql.txt index 92b6c59f..c91c4229 100644 --- a/testdata/result/statement/named_schemas_alter_table_add_constraint.sql.txt +++ b/testdata/result/statement/named_schemas_alter_table_add_constraint.sql.txt @@ -3,8 +3,7 @@ ALTER TABLE sch1.ShoppingCarts ADD CONSTRAINT FKShoppingCartsCustomers FOREIGN K REFERENCES sch1.Customers(CustomerId, CustomerName) ON DELETE CASCADE --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/named_schemas_alter_table_drop_constraints.sql.txt b/testdata/result/statement/named_schemas_alter_table_drop_constraints.sql.txt index e76de6a7..83f44484 100644 --- a/testdata/result/statement/named_schemas_alter_table_drop_constraints.sql.txt +++ b/testdata/result/statement/named_schemas_alter_table_drop_constraints.sql.txt @@ -2,8 +2,7 @@ ALTER TABLE sch1.ShoppingCarts DROP CONSTRAINT FKShoppingCartsCustomers --- AST &ast.AlterTable{ - Alter: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, diff --git a/testdata/result/statement/named_schemas_create_index.sql.txt b/testdata/result/statement/named_schemas_create_index.sql.txt index 7f58a8e0..46e400bb 100644 --- a/testdata/result/statement/named_schemas_create_index.sql.txt +++ b/testdata/result/statement/named_schemas_create_index.sql.txt @@ -2,12 +2,8 @@ CREATE INDEX sch1.indexOnSingers ON sch1.Singers(FirstName) --- AST &ast.CreateIndex{ - Create: 0, - Rparen: 58, - Unique: false, - NullFiltered: false, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 58, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -43,12 +39,9 @@ CREATE INDEX sch1.indexOnSingers ON sch1.Singers(FirstName) NameEnd: 58, Name: "FirstName", }, - Dir: "", }, }, - Storing: (*ast.Storing)(nil), - InterleaveIn: (*ast.InterleaveIn)(nil), } --- SQL -CREATE INDEX sch1.indexOnSingers ON sch1.Singers (FirstName) +CREATE INDEX sch1.indexOnSingers ON sch1.Singers(FirstName) diff --git a/testdata/result/statement/named_schemas_create_sequence.sql.txt b/testdata/result/statement/named_schemas_create_sequence.sql.txt index bbaa6e61..7749d978 100644 --- a/testdata/result/statement/named_schemas_create_sequence.sql.txt +++ b/testdata/result/statement/named_schemas_create_sequence.sql.txt @@ -4,8 +4,7 @@ CREATE SEQUENCE sch1.sequence OPTIONS ( ) --- AST &ast.CreateSequence{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 16, @@ -19,9 +18,7 @@ CREATE SEQUENCE sch1.sequence OPTIONS ( }, }, }, - IfNotExists: false, - Params: []ast.SequenceParam(nil), - Options: &ast.Options{ + Options: &ast.Options{ Options: 30, Rparen: 82, Records: []*ast.OptionsDef{ diff --git a/testdata/result/statement/named_schemas_create_table.sql.txt b/testdata/result/statement/named_schemas_create_table.sql.txt index 583cfa80..beb9447b 100644 --- a/testdata/result/statement/named_schemas_create_table.sql.txt +++ b/testdata/result/statement/named_schemas_create_table.sql.txt @@ -7,10 +7,8 @@ CREATE TABLE sch1.Singers ( ) PRIMARY KEY(SingerId) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 161, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 161, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -36,12 +34,8 @@ CREATE TABLE sch1.Singers ( NamePos: 41, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -54,7 +48,6 @@ CREATE TABLE sch1.Singers ( NamePos: 71, Rparen: 82, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 78, ValueEnd: 82, @@ -62,12 +55,7 @@ CREATE TABLE sch1.Singers ( Value: "1024", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -80,7 +68,6 @@ CREATE TABLE sch1.Singers ( NamePos: 98, Rparen: 109, Name: "STRING", - Max: false, Size: &ast.IntLiteral{ ValuePos: 105, ValueEnd: 109, @@ -88,12 +75,7 @@ CREATE TABLE sch1.Singers ( Value: "1024", }, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -107,18 +89,11 @@ CREATE TABLE sch1.Singers ( Rparen: 136, Name: "BYTES", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -126,12 +101,8 @@ CREATE TABLE sch1.Singers ( NameEnd: 161, Name: "SingerId", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/named_schemas_create_table_foreign_key.sql.txt b/testdata/result/statement/named_schemas_create_table_foreign_key.sql.txt index 82b1bb68..deb384e1 100644 --- a/testdata/result/statement/named_schemas_create_table_foreign_key.sql.txt +++ b/testdata/result/statement/named_schemas_create_table_foreign_key.sql.txt @@ -8,10 +8,8 @@ CREATE TABLE sch1.ShoppingCarts ( ) PRIMARY KEY(CartId) --- AST &ast.CreateTable{ - Create: 0, - Rparen: 296, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 296, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -37,12 +35,8 @@ CREATE TABLE sch1.ShoppingCarts ( NamePos: 43, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 82, @@ -55,12 +49,8 @@ CREATE TABLE sch1.ShoppingCarts ( NamePos: 72, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 119, @@ -74,14 +64,9 @@ CREATE TABLE sch1.ShoppingCarts ( Rparen: 113, Name: "STRING", Max: true, - Size: nil, }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, }, TableConstraints: []*ast.TableConstraint{ @@ -146,12 +131,8 @@ CREATE TABLE sch1.ShoppingCarts ( NameEnd: 296, Name: "CartId", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: (*ast.Cluster)(nil), - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/named_schemas_create_table_interleave.sql.txt b/testdata/result/statement/named_schemas_create_table_interleave.sql.txt index d54a49ff..82983cde 100644 --- a/testdata/result/statement/named_schemas_create_table_interleave.sql.txt +++ b/testdata/result/statement/named_schemas_create_table_interleave.sql.txt @@ -7,10 +7,8 @@ CREATE TABLE sch1.Albums ( INTERLEAVE IN PARENT sch1.Singers ON DELETE CASCADE --- AST &ast.CreateTable{ - Create: 0, - Rparen: 137, - IfNotExists: false, - Name: &ast.Path{ + Rparen: 137, + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 13, @@ -36,12 +34,8 @@ CREATE TABLE sch1.Albums ( NamePos: 38, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: 74, @@ -54,12 +48,8 @@ CREATE TABLE sch1.Albums ( NamePos: 64, Name: "INT64", }, - NotNull: true, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + NotNull: true, + Hidden: -1, }, &ast.ColumnDef{ Null: -1, @@ -73,18 +63,11 @@ CREATE TABLE sch1.Albums ( Rparen: 103, Name: "STRING", Max: true, - Size: nil, }, - NotNull: false, - DefaultExpr: (*ast.ColumnDefaultExpr)(nil), - GeneratedExpr: (*ast.GeneratedColumnExpr)(nil), - IdentityColumn: (*ast.IdentityColumn)(nil), - Hidden: -1, - Options: (*ast.Options)(nil), + Hidden: -1, }, }, - TableConstraints: []*ast.TableConstraint(nil), - PrimaryKeys: []*ast.IndexKey{ + PrimaryKeys: []*ast.IndexKey{ &ast.IndexKey{ DirPos: -1, Name: &ast.Ident{ @@ -92,7 +75,6 @@ CREATE TABLE sch1.Albums ( NameEnd: 128, Name: "SingerId", }, - Dir: "", }, &ast.IndexKey{ DirPos: -1, @@ -101,11 +83,9 @@ CREATE TABLE sch1.Albums ( NameEnd: 137, Name: "AlbumId", }, - Dir: "", }, }, - Synonyms: []*ast.Synonym(nil), - Cluster: &ast.Cluster{ + Cluster: &ast.Cluster{ Comma: 138, OnDeleteEnd: 193, TableName: &ast.Path{ @@ -124,7 +104,6 @@ CREATE TABLE sch1.Albums ( }, OnDelete: "ON DELETE CASCADE", }, - RowDeletionPolicy: (*ast.CreateRowDeletionPolicy)(nil), } --- SQL diff --git a/testdata/result/statement/named_schemas_create_view.sql.txt b/testdata/result/statement/named_schemas_create_view.sql.txt index 19615943..bda5fae5 100644 --- a/testdata/result/statement/named_schemas_create_view.sql.txt +++ b/testdata/result/statement/named_schemas_create_view.sql.txt @@ -4,8 +4,7 @@ AS Select s.FirstName, s.LastName, s.SingerInfo FROM sch1.Singers AS s WHERE s.SingerId = 123456 --- AST &ast.CreateView{ - Create: 0, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 12, @@ -19,13 +18,10 @@ AS Select s.FirstName, s.LastName, s.SingerInfo }, }, }, - OrReplace: false, SecurityType: "INVOKER", Query: &ast.Select{ - Select: 52, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 52, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -92,8 +88,7 @@ AS Select s.FirstName, s.LastName, s.SingerInfo }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 118, Alias: &ast.Ident{ NamePos: 121, @@ -101,8 +96,6 @@ AS Select s.FirstName, s.LastName, s.SingerInfo Name: "s", }, }, - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -131,10 +124,6 @@ AS Select s.FirstName, s.LastName, s.SingerInfo }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/named_schemas_drop_index.sql.txt b/testdata/result/statement/named_schemas_drop_index.sql.txt index e39e22d3..a5ac72df 100644 --- a/testdata/result/statement/named_schemas_drop_index.sql.txt +++ b/testdata/result/statement/named_schemas_drop_index.sql.txt @@ -2,9 +2,7 @@ DROP INDEX sch1.indexOnSingers --- AST &ast.DropIndex{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 11, diff --git a/testdata/result/statement/named_schemas_drop_sequence.sql.txt b/testdata/result/statement/named_schemas_drop_sequence.sql.txt index 1714e94e..7252d218 100644 --- a/testdata/result/statement/named_schemas_drop_sequence.sql.txt +++ b/testdata/result/statement/named_schemas_drop_sequence.sql.txt @@ -2,9 +2,7 @@ DROP SEQUENCE sch1.sequence --- AST &ast.DropSequence{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 14, diff --git a/testdata/result/statement/named_schemas_drop_table.sql.txt b/testdata/result/statement/named_schemas_drop_table.sql.txt index f4a3fc70..f68cc7ba 100644 --- a/testdata/result/statement/named_schemas_drop_table.sql.txt +++ b/testdata/result/statement/named_schemas_drop_table.sql.txt @@ -2,9 +2,7 @@ DROP TABLE sch1.ShoppingCarts --- AST &ast.DropTable{ - Drop: 0, - IfExists: false, - Name: &ast.Path{ + Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ NamePos: 11, diff --git a/testdata/result/statement/named_schemas_drop_view.sql.txt b/testdata/result/statement/named_schemas_drop_view.sql.txt index 0431f46a..6a963dbe 100644 --- a/testdata/result/statement/named_schemas_drop_view.sql.txt +++ b/testdata/result/statement/named_schemas_drop_view.sql.txt @@ -2,7 +2,6 @@ DROP VIEW sch1.SingerView --- AST &ast.DropView{ - Drop: 0, Name: &ast.Path{ Idents: []*ast.Ident{ &ast.Ident{ diff --git a/testdata/result/statement/pipe_cte_from.sql.txt b/testdata/result/statement/pipe_cte_from.sql.txt new file mode 100644 index 00000000..337944bc --- /dev/null +++ b/testdata/result/statement/pipe_cte_from.sql.txt @@ -0,0 +1,48 @@ +--- pipe_cte_from.sql +WITH cte AS (SELECT 1) +FROM cte +--- AST +&ast.QueryStatement{ + Query: &ast.Query{ + With: &ast.With{ + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 21, + Name: &ast.Ident{ + NamePos: 5, + NameEnd: 8, + Name: "cte", + }, + QueryExpr: &ast.Select{ + Select: 13, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 20, + ValueEnd: 21, + Base: 10, + Value: "1", + }, + }, + }, + }, + }, + }, + }, + Query: &ast.FromQuery{ + From: &ast.From{ + From: 23, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 28, + NameEnd: 31, + Name: "cte", + }, + }, + }, + }, + }, +} + +--- SQL +WITH cte AS (SELECT 1) FROM cte diff --git a/testdata/result/statement/pipe_from_select_all.sql.txt b/testdata/result/statement/pipe_from_select_all.sql.txt new file mode 100644 index 00000000..c4834e43 --- /dev/null +++ b/testdata/result/statement/pipe_from_select_all.sql.txt @@ -0,0 +1,33 @@ +--- pipe_from_select_all.sql +FROM Singers +|> SELECT ALL * +--- AST +&ast.QueryStatement{ + Query: &ast.Query{ + Query: &ast.FromQuery{ + From: &ast.From{ + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 5, + NameEnd: 12, + Name: "Singers", + }, + }, + }, + }, + PipeOperators: []ast.PipeOperator{ + &ast.PipeSelect{ + Pipe: 13, + AllOrDistinct: "ALL", + Results: []ast.SelectItem{ + &ast.Star{ + Star: 27, + }, + }, + }, + }, + }, +} + +--- SQL +FROM Singers |> SELECT ALL * diff --git a/testdata/result/statement/pipe_from_where_select_distinct.sql.txt b/testdata/result/statement/pipe_from_where_select_distinct.sql.txt new file mode 100644 index 00000000..d3572d6b --- /dev/null +++ b/testdata/result/statement/pipe_from_where_select_distinct.sql.txt @@ -0,0 +1,50 @@ +--- pipe_from_where_select_distinct.sql +FROM Singers +|> WHERE FirstName = "John" +|> SELECT DISTINCT * +--- AST +&ast.QueryStatement{ + Query: &ast.Query{ + Query: &ast.FromQuery{ + From: &ast.From{ + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 5, + NameEnd: 12, + Name: "Singers", + }, + }, + }, + }, + PipeOperators: []ast.PipeOperator{ + &ast.PipeWhere{ + Pipe: 13, + Expr: &ast.BinaryExpr{ + Op: "=", + Left: &ast.Ident{ + NamePos: 22, + NameEnd: 31, + Name: "FirstName", + }, + Right: &ast.StringLiteral{ + ValuePos: 34, + ValueEnd: 40, + Value: "John", + }, + }, + }, + &ast.PipeSelect{ + Pipe: 41, + AllOrDistinct: "DISTINCT", + Results: []ast.SelectItem{ + &ast.Star{ + Star: 60, + }, + }, + }, + }, + }, +} + +--- SQL +FROM Singers |> WHERE FirstName = "John" |> SELECT DISTINCT * diff --git a/testdata/result/statement/rename_table_multiple.sql.txt b/testdata/result/statement/rename_table_multiple.sql.txt index e075f639..735954fc 100644 --- a/testdata/result/statement/rename_table_multiple.sql.txt +++ b/testdata/result/statement/rename_table_multiple.sql.txt @@ -2,8 +2,7 @@ RENAME TABLE Singers TO Artists, Albums TO Recordings --- AST &ast.RenameTable{ - Rename: 0, - Tos: []*ast.RenameTableTo{ + Tos: []*ast.RenameTableTo{ &ast.RenameTableTo{ Old: &ast.Ident{ NamePos: 13, diff --git a/testdata/result/statement/rename_table_single.sql.txt b/testdata/result/statement/rename_table_single.sql.txt index a6358055..7390f014 100644 --- a/testdata/result/statement/rename_table_single.sql.txt +++ b/testdata/result/statement/rename_table_single.sql.txt @@ -2,8 +2,7 @@ RENAME TABLE Singers TO Artists --- AST &ast.RenameTable{ - Rename: 0, - Tos: []*ast.RenameTableTo{ + Tos: []*ast.RenameTableTo{ &ast.RenameTableTo{ Old: &ast.Ident{ NamePos: 13, diff --git a/testdata/result/statement/revoke_change_stream_privilege.sql.txt b/testdata/result/statement/revoke_change_stream_privilege.sql.txt index b3f9b42c..59695a63 100644 --- a/testdata/result/statement/revoke_change_stream_privilege.sql.txt +++ b/testdata/result/statement/revoke_change_stream_privilege.sql.txt @@ -2,7 +2,6 @@ REVOKE SELECT ON CHANGE STREAM cs_name_one, cs_name_two FROM ROLE hr_manager --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.SelectPrivilegeOnChangeStream{ Select: 7, Names: []*ast.Ident{ diff --git a/testdata/result/statement/revoke_execute_on_table_function.sql.txt b/testdata/result/statement/revoke_execute_on_table_function.sql.txt index 4dd6b857..b7695b39 100644 --- a/testdata/result/statement/revoke_execute_on_table_function.sql.txt +++ b/testdata/result/statement/revoke_execute_on_table_function.sql.txt @@ -2,7 +2,6 @@ REVOKE EXECUTE ON TABLE FUNCTION READ_SingersNameStream FROM ROLE hr_manager --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.ExecutePrivilegeOnTableFunction{ Execute: 7, Names: []*ast.Ident{ diff --git a/testdata/result/statement/revoke_privileges.sql.txt b/testdata/result/statement/revoke_privileges.sql.txt index 1d0f03bf..700fab92 100644 --- a/testdata/result/statement/revoke_privileges.sql.txt +++ b/testdata/result/statement/revoke_privileges.sql.txt @@ -3,7 +3,6 @@ REVOKE SELECT(name, level, location), UPDATE(location) ON TABLE employees, contr --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.PrivilegeOnTable{ Privileges: []ast.TablePrivilege{ &ast.SelectPrivilege{ diff --git a/testdata/result/statement/revoke_role.sql.txt b/testdata/result/statement/revoke_role.sql.txt index e9424539..532ada8b 100644 --- a/testdata/result/statement/revoke_role.sql.txt +++ b/testdata/result/statement/revoke_role.sql.txt @@ -3,7 +3,6 @@ REVOKE ROLE pii_access, pii_writter FROM ROLE hr_manager, hr_director --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.RolePrivilege{ Role: 7, Names: []*ast.Ident{ diff --git a/testdata/result/statement/revoke_select_on_view.sql.txt b/testdata/result/statement/revoke_select_on_view.sql.txt index ecf3c1dd..4f45d474 100644 --- a/testdata/result/statement/revoke_select_on_view.sql.txt +++ b/testdata/result/statement/revoke_select_on_view.sql.txt @@ -2,7 +2,6 @@ REVOKE SELECT ON VIEW singernames FROM ROLE hr_manager --- AST &ast.Revoke{ - Revoke: 0, Privilege: &ast.SelectPrivilegeOnView{ Select: 7, Names: []*ast.Ident{ diff --git a/testdata/result/statement/select_album_with_index_directive.sql.txt b/testdata/result/statement/select_album_with_index_directive.sql.txt index d919f75e..9e4e6986 100644 --- a/testdata/result/statement/select_album_with_index_directive.sql.txt +++ b/testdata/result/statement/select_album_with_index_directive.sql.txt @@ -5,13 +5,8 @@ WHERE AlbumTitle >= @startTitle AND AlbumTitle < @endTitle --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 7, @@ -60,8 +55,6 @@ WHERE AlbumTitle >= @startTitle AND AlbumTitle < @endTitle }, }, }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -94,10 +87,6 @@ WHERE AlbumTitle >= @startTitle AND AlbumTitle < @endTitle }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_alias_without_as.sql.txt b/testdata/result/statement/select_alias_without_as.sql.txt index c4604a96..2c446b42 100644 --- a/testdata/result/statement/select_alias_without_as.sql.txt +++ b/testdata/result/statement/select_alias_without_as.sql.txt @@ -3,13 +3,8 @@ select 1 A --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.IntLiteral{ ValuePos: 7, @@ -27,12 +22,6 @@ select 1 A }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_array_with_struct.sql.txt b/testdata/result/statement/select_array_with_struct.sql.txt index 32f645d4..752145e7 100644 --- a/testdata/result/statement/select_array_with_struct.sql.txt +++ b/testdata/result/statement/select_array_with_struct.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -91,17 +86,8 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_call_with_named_expr.sql.txt b/testdata/result/statement/select_call_with_named_expr.sql.txt index bae8b868..11f82c13 100644 --- a/testdata/result/statement/select_call_with_named_expr.sql.txt +++ b/testdata/result/statement/select_call_with_named_expr.sql.txt @@ -4,13 +4,8 @@ FROM Albums a WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_query => TRUE) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -52,8 +47,7 @@ WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_q NameEnd: 43, Name: "Albums", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 44, @@ -61,7 +55,6 @@ WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_q Name: "a", }, }, - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -98,8 +91,7 @@ WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_q NameEnd: 77, Name: "SEARCH", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -137,15 +129,9 @@ WHERE a.SingerId = 1 AND SEARCH(a.DescriptionTokens, 'classic albums', enhance_q }, }, }, - NullHandling: nil, - Having: nil, }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_cast.sql.txt b/testdata/result/statement/select_cast.sql.txt index 84154e99..db776822 100644 --- a/testdata/result/statement/select_cast.sql.txt +++ b/testdata/result/statement/select_cast.sql.txt @@ -7,156 +7,145 @@ limit cast(1 as INT64) offset cast(@foo as INT64) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.CastExpr{ - Cast: 7, - Rparen: 22, - Safe: false, - Expr: &ast.IntLiteral{ - ValuePos: 12, - ValueEnd: 13, - Base: 10, - Value: "1", - }, - Type: &ast.SimpleType{ - NamePos: 17, - Name: "INT64", + Query: &ast.Query{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.CastExpr{ + Cast: 7, + Rparen: 22, + Expr: &ast.IntLiteral{ + ValuePos: 12, + ValueEnd: 13, + Base: 10, + Value: "1", + }, + Type: &ast.SimpleType{ + NamePos: 17, + Name: "INT64", + }, }, }, - }, - &ast.ExprSelectItem{ - Expr: &ast.CastExpr{ - Cast: 25, - Rparen: 44, - Safe: false, - Expr: &ast.FloatLiteral{ - ValuePos: 30, - ValueEnd: 33, - Value: "0.1", - }, - Type: &ast.SimpleType{ - NamePos: 37, - Name: "FLOAT32", + &ast.ExprSelectItem{ + Expr: &ast.CastExpr{ + Cast: 25, + Rparen: 44, + Expr: &ast.FloatLiteral{ + ValuePos: 30, + ValueEnd: 33, + Value: "0.1", + }, + Type: &ast.SimpleType{ + NamePos: 37, + Name: "FLOAT32", + }, }, }, - }, - &ast.ExprSelectItem{ - Expr: &ast.CastExpr{ - Cast: 47, - Rparen: 147, - Safe: false, - Expr: &ast.TupleStructLiteral{ - Lparen: 52, - Rparen: 84, - Values: []ast.Expr{ - &ast.TypelessStructLiteral{ - Struct: 53, - Rparen: 60, - Values: []ast.TypelessStructLiteralArg(nil), - }, - &ast.IntLiteral{ - ValuePos: 63, - ValueEnd: 64, - Base: 10, - Value: "1", - }, - &ast.ArrayLiteral{ - Array: -1, - Lbrack: 66, - Rbrack: 71, - Type: nil, - Values: []ast.Expr{ - &ast.IntLiteral{ - ValuePos: 67, - ValueEnd: 68, - Base: 10, - Value: "2", - }, - &ast.IntLiteral{ - ValuePos: 70, - ValueEnd: 71, - Base: 10, - Value: "3", - }, + &ast.ExprSelectItem{ + Expr: &ast.CastExpr{ + Cast: 47, + Rparen: 147, + Expr: &ast.TupleStructLiteral{ + Lparen: 52, + Rparen: 84, + Values: []ast.Expr{ + &ast.TypelessStructLiteral{ + Struct: 53, + Rparen: 60, }, - }, - &ast.ArrayLiteral{ - Array: -1, - Lbrack: 74, - Rbrack: 83, - Type: nil, - Values: []ast.Expr{ - &ast.StringLiteral{ - ValuePos: 75, - ValueEnd: 78, - Value: "4", + &ast.IntLiteral{ + ValuePos: 63, + ValueEnd: 64, + Base: 10, + Value: "1", + }, + &ast.ArrayLiteral{ + Array: -1, + Lbrack: 66, + Rbrack: 71, + Values: []ast.Expr{ + &ast.IntLiteral{ + ValuePos: 67, + ValueEnd: 68, + Base: 10, + Value: "2", + }, + &ast.IntLiteral{ + ValuePos: 70, + ValueEnd: 71, + Base: 10, + Value: "3", + }, }, - &ast.StringLiteral{ - ValuePos: 80, - ValueEnd: 83, - Value: "5", + }, + &ast.ArrayLiteral{ + Array: -1, + Lbrack: 74, + Rbrack: 83, + Values: []ast.Expr{ + &ast.StringLiteral{ + ValuePos: 75, + ValueEnd: 78, + Value: "4", + }, + &ast.StringLiteral{ + ValuePos: 80, + ValueEnd: 83, + Value: "5", + }, }, }, }, }, - }, - Type: &ast.StructType{ - Struct: 89, - Gt: 146, - Fields: []*ast.StructField{ - &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.StructType{ - Struct: 96, - Gt: 103, - Fields: []*ast.StructField(nil), - }, - }, - &ast.StructField{ - Ident: &ast.Ident{ - NamePos: 106, - NameEnd: 107, - Name: "x", - }, - Type: &ast.SimpleType{ - NamePos: 108, - Name: "INT64", - }, - }, - &ast.StructField{ - Ident: &ast.Ident{ - NamePos: 115, - NameEnd: 116, - Name: "y", + Type: &ast.StructType{ + Struct: 89, + Gt: 146, + Fields: []*ast.StructField{ + &ast.StructField{ + Type: &ast.StructType{ + Struct: 96, + Gt: 103, + }, }, - Type: &ast.ArrayType{ - Array: 117, - Gt: 128, - Item: &ast.SimpleType{ - NamePos: 123, + &ast.StructField{ + Ident: &ast.Ident{ + NamePos: 106, + NameEnd: 107, + Name: "x", + }, + Type: &ast.SimpleType{ + NamePos: 108, Name: "INT64", }, }, - }, - &ast.StructField{ - Ident: &ast.Ident{ - NamePos: 131, - NameEnd: 132, - Name: "z", + &ast.StructField{ + Ident: &ast.Ident{ + NamePos: 115, + NameEnd: 116, + Name: "y", + }, + Type: &ast.ArrayType{ + Array: 117, + Gt: 128, + Item: &ast.SimpleType{ + NamePos: 123, + Name: "INT64", + }, + }, }, - Type: &ast.ArrayType{ - Array: 133, - Gt: 145, - Item: &ast.SimpleType{ - NamePos: 139, - Name: "STRING", + &ast.StructField{ + Ident: &ast.Ident{ + NamePos: 131, + NameEnd: 132, + Name: "z", + }, + Type: &ast.ArrayType{ + Array: 133, + Gt: 145, + Item: &ast.SimpleType{ + NamePos: 139, + Name: "STRING", + }, }, }, }, @@ -164,67 +153,84 @@ limit cast(1 as INT64) offset cast(@foo as INT64) }, }, }, - }, - From: &ast.From{ - From: 149, - Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 154, - NameEnd: 155, - Name: "x", + From: &ast.From{ + From: 149, + Source: &ast.Join{ + Op: ",", + Left: &ast.Join{ + Op: ",", + Left: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 154, + NameEnd: 155, + Name: "x", + }, + Sample: &ast.TableSample{ + TableSample: 156, + Method: "BERNOULLI", + Size: &ast.TableSampleSize{ + Lparen: 178, + Rparen: 207, + Value: &ast.CastNumValue{ + Cast: 179, + Rparen: 198, + Expr: &ast.FloatLiteral{ + ValuePos: 184, + ValueEnd: 187, + Value: "0.1", + }, + Type: "FLOAT64", + }, + Unit: "PERCENT", + }, + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: &ast.TableSample{ - TableSample: 156, - Method: "BERNOULLI", - Size: &ast.TableSampleSize{ - Lparen: 178, - Rparen: 207, - Value: &ast.CastNumValue{ - Cast: 179, - Rparen: 198, - Expr: &ast.FloatLiteral{ - ValuePos: 184, - ValueEnd: 187, - Value: "0.1", + Right: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 215, + NameEnd: 216, + Name: "y", + }, + Sample: &ast.TableSample{ + TableSample: 217, + Method: "BERNOULLI", + Size: &ast.TableSampleSize{ + Lparen: 239, + Rparen: 261, + Value: &ast.CastNumValue{ + Cast: 240, + Rparen: 255, + Expr: &ast.IntLiteral{ + ValuePos: 245, + ValueEnd: 246, + Base: 10, + Value: "1", + }, + Type: "INT64", }, - Type: "FLOAT64", + Unit: "ROWS", }, - Unit: "PERCENT", }, }, }, Right: &ast.TableName{ Table: &ast.Ident{ - NamePos: 215, - NameEnd: 216, - Name: "y", + NamePos: 269, + NameEnd: 270, + Name: "z", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), Sample: &ast.TableSample{ - TableSample: 217, + TableSample: 271, Method: "BERNOULLI", Size: &ast.TableSampleSize{ - Lparen: 239, - Rparen: 261, + Lparen: 293, + Rparen: 320, Value: &ast.CastNumValue{ - Cast: 240, - Rparen: 255, - Expr: &ast.IntLiteral{ - ValuePos: 245, - ValueEnd: 246, - Base: 10, - Value: "1", + Cast: 294, + Rparen: 314, + Expr: &ast.Param{ + Atmark: 299, + Name: "param", }, Type: "INT64", }, @@ -232,43 +238,10 @@ limit cast(1 as INT64) offset cast(@foo as INT64) }, }, }, - Cond: nil, - }, - Right: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 269, - NameEnd: 270, - Name: "z", - }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: &ast.TableSample{ - TableSample: 271, - Method: "BERNOULLI", - Size: &ast.TableSampleSize{ - Lparen: 293, - Rparen: 320, - Value: &ast.CastNumValue{ - Cast: 294, - Rparen: 314, - Expr: &ast.Param{ - Atmark: 299, - Name: "param", - }, - Type: "INT64", - }, - Unit: "ROWS", - }, - }, }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 322, Count: &ast.CastIntValue{ Cast: 328, diff --git a/testdata/result/statement/select_complex_with_array_path.sql.txt b/testdata/result/statement/select_complex_with_array_path.sql.txt index 2ce3e66a..cbfb49b5 100644 --- a/testdata/result/statement/select_complex_with_array_path.sql.txt +++ b/testdata/result/statement/select_complex_with_array_path.sql.txt @@ -7,13 +7,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -21,18 +16,13 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: ",", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 30, Name: "ComplexTable", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, Right: &ast.PathTableExpr{ Path: &ast.Path{ @@ -49,19 +39,9 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_complex_with_unnest_array_path.sql.txt b/testdata/result/statement/select_complex_with_unnest_array_path.sql.txt index 200e7d61..5008c0b7 100644 --- a/testdata/result/statement/select_complex_with_unnest_array_path.sql.txt +++ b/testdata/result/statement/select_complex_with_unnest_array_path.sql.txt @@ -7,13 +7,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -21,18 +16,13 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: ",", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 30, Name: "ComplexTable", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, Right: &ast.Unnest{ Unnest: 34, @@ -51,19 +41,9 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_count_asterisk.sql.txt b/testdata/result/statement/select_count_asterisk.sql.txt index 5dcbd0b7..92036b3d 100644 --- a/testdata/result/statement/select_count_asterisk.sql.txt +++ b/testdata/result/statement/select_count_asterisk.sql.txt @@ -3,13 +3,8 @@ select count(*) from singers --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.CountStarExpr{ Count: 7, @@ -25,16 +20,8 @@ select count(*) from singers NameEnd: 28, Name: "singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_count_distinct.sql.txt b/testdata/result/statement/select_count_distinct.sql.txt index 76755e4a..f32ac131 100644 --- a/testdata/result/statement/select_count_distinct.sql.txt +++ b/testdata/result/statement/select_count_distinct.sql.txt @@ -2,13 +2,8 @@ select count(distinct x) from foo --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.CallExpr{ Rparen: 23, @@ -27,9 +22,6 @@ select count(distinct x) from foo }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, }, @@ -41,16 +33,8 @@ select count(distinct x) from foo NameEnd: 33, Name: "foo", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_dot_star.sql.txt b/testdata/result/statement/select_dot_star.sql.txt new file mode 100644 index 00000000..584d57e2 --- /dev/null +++ b/testdata/result/statement/select_dot_star.sql.txt @@ -0,0 +1,70 @@ +--- select_dot_star.sql +SELECT T.* FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 9, + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 8, + Name: "T", + }, + }, + }, + From: &ast.From{ + From: 11, + Source: &ast.SubQueryTableExpr{ + Lparen: 16, + Rparen: 63, + Query: &ast.Select{ + Select: 17, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 24, + ValueEnd: 31, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 32, + Alias: &ast.Ident{ + NamePos: 35, + NameEnd: 40, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 42, + ValueEnd: 50, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 51, + Alias: &ast.Ident{ + NamePos: 54, + NameEnd: 63, + Name: "vegetable", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: -1, + Alias: &ast.Ident{ + NamePos: 65, + NameEnd: 66, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT T.* FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) T diff --git a/testdata/result/statement/select_dot_star_except.sql.txt b/testdata/result/statement/select_dot_star_except.sql.txt new file mode 100644 index 00000000..76614ca2 --- /dev/null +++ b/testdata/result/statement/select_dot_star_except.sql.txt @@ -0,0 +1,81 @@ +--- select_dot_star_except.sql +SELECT T.* EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 9, + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 8, + Name: "T", + }, + Except: &ast.StarModifierExcept{ + Except: 11, + Rparen: 28, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 19, + NameEnd: 28, + Name: "vegetable", + }, + }, + }, + }, + }, + From: &ast.From{ + From: 30, + Source: &ast.SubQueryTableExpr{ + Lparen: 35, + Rparen: 82, + Query: &ast.Select{ + Select: 36, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 43, + ValueEnd: 50, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 51, + Alias: &ast.Ident{ + NamePos: 54, + NameEnd: 59, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 61, + ValueEnd: 69, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 70, + Alias: &ast.Ident{ + NamePos: 73, + NameEnd: 82, + Name: "vegetable", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 84, + Alias: &ast.Ident{ + NamePos: 87, + NameEnd: 88, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT T.* EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T diff --git a/testdata/result/statement/select_dot_star_except_replace.sql.txt b/testdata/result/statement/select_dot_star_except_replace.sql.txt new file mode 100644 index 00000000..84bfae1f --- /dev/null +++ b/testdata/result/statement/select_dot_star_except_replace.sql.txt @@ -0,0 +1,99 @@ +--- select_dot_star_except_replace.sql +SELECT T.* EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 9, + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 8, + Name: "T", + }, + Except: &ast.StarModifierExcept{ + Except: 11, + Rparen: 28, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 19, + NameEnd: 28, + Name: "vegetable", + }, + }, + }, + Replace: &ast.StarModifierReplace{ + Replace: 30, + Rparen: 56, + Columns: []*ast.StarModifierReplaceItem{ + &ast.StarModifierReplaceItem{ + Expr: &ast.StringLiteral{ + ValuePos: 39, + ValueEnd: 47, + Value: "orange", + }, + Name: &ast.Ident{ + NamePos: 51, + NameEnd: 56, + Name: "fruit", + }, + }, + }, + }, + }, + }, + From: &ast.From{ + From: 58, + Source: &ast.SubQueryTableExpr{ + Lparen: 63, + Rparen: 110, + Query: &ast.Select{ + Select: 64, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 71, + ValueEnd: 78, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 79, + Alias: &ast.Ident{ + NamePos: 82, + NameEnd: 87, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 89, + ValueEnd: 97, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 98, + Alias: &ast.Ident{ + NamePos: 101, + NameEnd: 110, + Name: "vegetable", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 112, + Alias: &ast.Ident{ + NamePos: 115, + NameEnd: 116, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT T.* EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T diff --git a/testdata/result/statement/select_dot_star_replace.sql.txt b/testdata/result/statement/select_dot_star_replace.sql.txt new file mode 100644 index 00000000..8e21e232 --- /dev/null +++ b/testdata/result/statement/select_dot_star_replace.sql.txt @@ -0,0 +1,88 @@ +--- select_dot_star_replace.sql +SELECT T.* REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.DotStar{ + Star: 9, + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 8, + Name: "T", + }, + Replace: &ast.StarModifierReplace{ + Replace: 11, + Rparen: 37, + Columns: []*ast.StarModifierReplaceItem{ + &ast.StarModifierReplaceItem{ + Expr: &ast.StringLiteral{ + ValuePos: 20, + ValueEnd: 28, + Value: "orange", + }, + Name: &ast.Ident{ + NamePos: 32, + NameEnd: 37, + Name: "fruit", + }, + }, + }, + }, + }, + }, + From: &ast.From{ + From: 39, + Source: &ast.SubQueryTableExpr{ + Lparen: 44, + Rparen: 91, + Query: &ast.Select{ + Select: 45, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 52, + ValueEnd: 59, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 60, + Alias: &ast.Ident{ + NamePos: 63, + NameEnd: 68, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 70, + ValueEnd: 78, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 79, + Alias: &ast.Ident{ + NamePos: 82, + NameEnd: 91, + Name: "vegetable", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 93, + Alias: &ast.Ident{ + NamePos: 96, + NameEnd: 97, + Name: "T", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT T.* REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) AS T diff --git a/testdata/result/statement/select_expr.sql.txt b/testdata/result/statement/select_expr.sql.txt index 21b2ce8d..817c41bf 100644 --- a/testdata/result/statement/select_expr.sql.txt +++ b/testdata/result/statement/select_expr.sql.txt @@ -31,13 +31,8 @@ select 1 + 2, 1 - 2, --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BinaryExpr{ Op: "+", @@ -328,10 +323,8 @@ select 1 + 2, 1 - 2, Lparen: 194, Rparen: 207, Query: &ast.Select{ - Select: 195, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 195, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.IntLiteral{ ValuePos: 202, @@ -349,12 +342,6 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, Ident: &ast.Ident{ @@ -385,7 +372,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 240, Rbrack: 248, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 241, @@ -427,7 +413,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 269, Rbrack: 277, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 270, @@ -469,7 +454,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 300, Rbrack: 308, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 301, @@ -508,7 +492,6 @@ select 1 + 2, 1 - 2, Expr: &ast.CaseExpr{ Case: 330, EndPos: 403, - Expr: nil, Whens: []*ast.CaseWhen{ &ast.CaseWhen{ When: 342, @@ -602,8 +585,7 @@ select 1 + 2, 1 - 2, NameEnd: 522, Name: "date_add", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.DateLiteral{ Date: 523, @@ -629,9 +611,6 @@ select 1 + 2, 1 - 2, }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -642,8 +621,7 @@ select 1 + 2, 1 - 2, NameEnd: 579, Name: "timestamp_add", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.TimestampLiteral{ Timestamp: 580, @@ -669,14 +647,10 @@ select 1 + 2, 1 - 2, }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ Expr: &ast.InExpr{ - Not: false, Left: &ast.IntLiteral{ ValuePos: 638, ValueEnd: 639, @@ -711,7 +685,6 @@ select 1 + 2, 1 - 2, }, &ast.ExprSelectItem{ Expr: &ast.InExpr{ - Not: false, Left: &ast.IntLiteral{ ValuePos: 661, ValueEnd: 662, @@ -725,7 +698,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 673, Rbrack: 681, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 674, @@ -752,7 +724,6 @@ select 1 + 2, 1 - 2, }, &ast.ExprSelectItem{ Expr: &ast.InExpr{ - Not: false, Left: &ast.IntLiteral{ ValuePos: 692, ValueEnd: 693, @@ -763,14 +734,12 @@ select 1 + 2, 1 - 2, Lparen: 697, Rparen: 744, Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 698, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 698, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 705, @@ -780,18 +749,10 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.Select{ - Select: 717, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 717, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 724, @@ -801,18 +762,10 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.Select{ - Select: 736, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 736, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 743, @@ -822,16 +775,8 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -843,7 +788,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 754, Rbrack: 756, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 755, @@ -857,7 +801,6 @@ select 1 + 2, 1 - 2, Array: -1, Lbrack: 761, Rbrack: 763, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 762, @@ -920,12 +863,6 @@ select 1 + 2, 1 - 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_expr_extract.sql.txt b/testdata/result/statement/select_expr_extract.sql.txt index 3ecdd405..788ea52f 100644 --- a/testdata/result/statement/select_expr_extract.sql.txt +++ b/testdata/result/statement/select_expr_extract.sql.txt @@ -21,13 +21,8 @@ select --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ExtractExpr{ Extract: 11, @@ -45,7 +40,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -65,7 +59,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -85,7 +78,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -105,7 +97,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -125,7 +116,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -145,7 +135,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -165,7 +154,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -185,7 +173,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -205,7 +192,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -225,7 +211,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -245,7 +230,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -265,7 +249,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -285,7 +268,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -305,7 +287,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -325,7 +306,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -345,7 +325,6 @@ select Value: "2019-09-01", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -365,7 +344,6 @@ select Value: "2019-09-01 08:11:23", }, }, - AtTimeZone: (*ast.AtTimeZone)(nil), }, }, &ast.ExprSelectItem{ @@ -396,12 +374,6 @@ select }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_from_change_stream.sql.txt b/testdata/result/statement/select_from_change_stream.sql.txt new file mode 100644 index 00000000..c94185fd --- /dev/null +++ b/testdata/result/statement/select_from_change_stream.sql.txt @@ -0,0 +1,86 @@ +--- select_from_change_stream.sql +SELECT ChangeRecord FROM READ_SingersNameStream ( + start_timestamp => "2022-05-01T09:00:00Z", + end_timestamp => NULL, + partition_token => NULL, + heartbeat_milliseconds => 10000 +) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 19, + Name: "ChangeRecord", + }, + }, + }, + From: &ast.From{ + From: 20, + Source: &ast.TVFCallExpr{ + Rparen: 181, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 25, + NameEnd: 47, + Name: "READ_SingersNameStream", + }, + }, + }, + NamedArgs: []*ast.NamedArg{ + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 52, + NameEnd: 67, + Name: "start_timestamp", + }, + Value: &ast.StringLiteral{ + ValuePos: 71, + ValueEnd: 93, + Value: "2022-05-01T09:00:00Z", + }, + }, + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 97, + NameEnd: 110, + Name: "end_timestamp", + }, + Value: &ast.NullLiteral{ + Null: 114, + }, + }, + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 122, + NameEnd: 137, + Name: "partition_token", + }, + Value: &ast.NullLiteral{ + Null: 141, + }, + }, + &ast.NamedArg{ + Name: &ast.Ident{ + NamePos: 149, + NameEnd: 171, + Name: "heartbeat_milliseconds", + }, + Value: &ast.IntLiteral{ + ValuePos: 175, + ValueEnd: 180, + Base: 10, + Value: "10000", + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT ChangeRecord FROM READ_SingersNameStream(start_timestamp => "2022-05-01T09:00:00Z", end_timestamp => NULL, partition_token => NULL, heartbeat_milliseconds => 10000) diff --git a/testdata/result/statement/select_from_implicit_unnest.sql.txt b/testdata/result/statement/select_from_implicit_unnest.sql.txt index f1d12b88..06a9e39a 100644 --- a/testdata/result/statement/select_from_implicit_unnest.sql.txt +++ b/testdata/result/statement/select_from_implicit_unnest.sql.txt @@ -4,13 +4,8 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, t.arr AS a WITH OFFSET AS off --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 7, @@ -29,17 +24,14 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, From: &ast.From{ From: 14, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Unnest{ + Op: ",", + Left: &ast.Unnest{ Unnest: 19, Rparen: 62, Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 26, Rbrack: 61, - Type: nil, Values: []ast.Expr{ &ast.TypedStructLiteral{ Struct: 27, @@ -66,7 +58,6 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, Array: -1, Lbrack: 53, Rbrack: 59, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 54, @@ -79,8 +70,7 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 64, Alias: &ast.Ident{ NamePos: 67, @@ -88,8 +78,6 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, Name: "t", }, }, - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, Right: &ast.PathTableExpr{ Path: &ast.Path{ @@ -106,8 +94,7 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 81, Alias: &ast.Ident{ NamePos: 84, @@ -127,16 +114,9 @@ FROM UNNEST([STRUCT>(["foo"])]) AS t, }, }, }, - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_from_ml_predict_hint.sql.txt b/testdata/result/statement/select_from_ml_predict_hint.sql.txt new file mode 100644 index 00000000..cc99b9a8 --- /dev/null +++ b/testdata/result/statement/select_from_ml_predict_hint.sql.txt @@ -0,0 +1,175 @@ +--- select_from_ml_predict_hint.sql +-- https://cloud.google.com/spanner/docs/ml-tutorial-generative-ai?hl=en#register_a_generative_ai_model_in_a_schema +SELECT content +FROM ML.PREDICT( + MODEL TextBison, + (SELECT "Is 13 prime?" AS prompt), + STRUCT(256 AS maxOutputTokens, 0.2 AS temperature, 40 as topK, 0.95 AS topP) +) @{remote_udf_max_rows_per_rpc=1} +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Select: 116, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 123, + NameEnd: 130, + Name: "content", + }, + }, + }, + From: &ast.From{ + From: 131, + Source: &ast.TVFCallExpr{ + Rparen: 289, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 136, + NameEnd: 138, + Name: "ML", + }, + &ast.Ident{ + NamePos: 139, + NameEnd: 146, + Name: "PREDICT", + }, + }, + }, + Args: []ast.TVFArg{ + &ast.ModelArg{ + Model: 152, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 158, + NameEnd: 167, + Name: "TextBison", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.ScalarSubQuery{ + Lparen: 173, + Rparen: 205, + Query: &ast.Select{ + Select: 174, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 181, + ValueEnd: 195, + Value: "Is 13 prime?", + }, + As: &ast.AsAlias{ + As: 196, + Alias: &ast.Ident{ + NamePos: 199, + NameEnd: 205, + Name: "prompt", + }, + }, + }, + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.TypelessStructLiteral{ + Struct: 212, + Rparen: 287, + Values: []ast.TypelessStructLiteralArg{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 219, + ValueEnd: 222, + Base: 10, + Value: "256", + }, + As: &ast.AsAlias{ + As: 223, + Alias: &ast.Ident{ + NamePos: 226, + NameEnd: 241, + Name: "maxOutputTokens", + }, + }, + }, + &ast.Alias{ + Expr: &ast.FloatLiteral{ + ValuePos: 243, + ValueEnd: 246, + Value: "0.2", + }, + As: &ast.AsAlias{ + As: 247, + Alias: &ast.Ident{ + NamePos: 250, + NameEnd: 261, + Name: "temperature", + }, + }, + }, + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 263, + ValueEnd: 265, + Base: 10, + Value: "40", + }, + As: &ast.AsAlias{ + As: 266, + Alias: &ast.Ident{ + NamePos: 269, + NameEnd: 273, + Name: "topK", + }, + }, + }, + &ast.Alias{ + Expr: &ast.FloatLiteral{ + ValuePos: 275, + ValueEnd: 279, + Value: "0.95", + }, + As: &ast.AsAlias{ + As: 280, + Alias: &ast.Ident{ + NamePos: 283, + NameEnd: 287, + Name: "topP", + }, + }, + }, + }, + }, + }, + }, + Hint: &ast.Hint{ + Atmark: 291, + Rbrace: 322, + Records: []*ast.HintRecord{ + &ast.HintRecord{ + Key: &ast.Ident{ + NamePos: 293, + NameEnd: 320, + Name: "remote_udf_max_rows_per_rpc", + }, + Value: &ast.IntLiteral{ + ValuePos: 321, + ValueEnd: 322, + Base: 10, + Value: "1", + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT content FROM ML.PREDICT(MODEL TextBison, (SELECT "Is 13 prime\?" AS prompt), STRUCT(256 AS maxOutputTokens, 0.2 AS temperature, 40 AS topK, 0.95 AS topP)) @{remote_udf_max_rows_per_rpc=1} diff --git a/testdata/result/statement/select_from_ml_predict_simple.sql.txt b/testdata/result/statement/select_from_ml_predict_simple.sql.txt new file mode 100644 index 00000000..06c7e7df --- /dev/null +++ b/testdata/result/statement/select_from_ml_predict_simple.sql.txt @@ -0,0 +1,80 @@ +--- select_from_ml_predict_simple.sql +SELECT id, color, value +FROM ML.PREDICT(MODEL DiamondAppraise, TABLE Diamonds) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 9, + Name: "id", + }, + }, + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 11, + NameEnd: 16, + Name: "color", + }, + }, + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 18, + NameEnd: 23, + Name: "value", + }, + }, + }, + From: &ast.From{ + From: 24, + Source: &ast.TVFCallExpr{ + Rparen: 77, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 29, + NameEnd: 31, + Name: "ML", + }, + &ast.Ident{ + NamePos: 32, + NameEnd: 39, + Name: "PREDICT", + }, + }, + }, + Args: []ast.TVFArg{ + &ast.ModelArg{ + Model: 40, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 46, + NameEnd: 61, + Name: "DiamondAppraise", + }, + }, + }, + }, + &ast.TableArg{ + Table: 63, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 69, + NameEnd: 77, + Name: "Diamonds", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT id, color, value FROM ML.PREDICT(MODEL DiamondAppraise, TABLE Diamonds) diff --git a/testdata/result/statement/select_from_ml_predict_textbison.sql.txt b/testdata/result/statement/select_from_ml_predict_textbison.sql.txt new file mode 100644 index 00000000..1d267c79 --- /dev/null +++ b/testdata/result/statement/select_from_ml_predict_textbison.sql.txt @@ -0,0 +1,370 @@ +--- select_from_ml_predict_textbison.sql +SELECT product_id, product_name, content +FROM ML.PREDICT( + MODEL TextBison, + (SELECT + product.id as product_id, + product.name as product_name, + CONCAT("Is this product safe for infants?", "\n", + "Product Name: ", product.name, "\n", + "Category Name: ", category.name, "\n", + "Product Description:", product.description) AS prompt + FROM + Products AS product JOIN Categories AS category + ON product.category_id = category.id), + STRUCT(100 AS maxOutputTokens) +) @{remote_udf_max_rows_per_rpc=1} +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 7, + NameEnd: 17, + Name: "product_id", + }, + }, + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 19, + NameEnd: 31, + Name: "product_name", + }, + }, + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 33, + NameEnd: 40, + Name: "content", + }, + }, + }, + From: &ast.From{ + From: 41, + Source: &ast.TVFCallExpr{ + Rparen: 580, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 46, + NameEnd: 48, + Name: "ML", + }, + &ast.Ident{ + NamePos: 49, + NameEnd: 56, + Name: "PREDICT", + }, + }, + }, + Args: []ast.TVFArg{ + &ast.ModelArg{ + Model: 62, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 68, + NameEnd: 77, + Name: "TextBison", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.ScalarSubQuery{ + Lparen: 83, + Rparen: 542, + Query: &ast.Select{ + Select: 84, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 100, + NameEnd: 107, + Name: "product", + }, + &ast.Ident{ + NamePos: 108, + NameEnd: 110, + Name: "id", + }, + }, + }, + As: &ast.AsAlias{ + As: 111, + Alias: &ast.Ident{ + NamePos: 114, + NameEnd: 124, + Name: "product_id", + }, + }, + }, + &ast.Alias{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 135, + NameEnd: 142, + Name: "product", + }, + &ast.Ident{ + NamePos: 143, + NameEnd: 147, + Name: "name", + }, + }, + }, + As: &ast.AsAlias{ + As: 148, + Alias: &ast.Ident{ + NamePos: 151, + NameEnd: 163, + Name: "product_name", + }, + }, + }, + &ast.Alias{ + Expr: &ast.CallExpr{ + Rparen: 393, + Func: &ast.Ident{ + NamePos: 174, + NameEnd: 180, + Name: "CONCAT", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 181, + ValueEnd: 216, + Value: "Is this product safe for infants?", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 218, + ValueEnd: 222, + Value: "\n", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 240, + ValueEnd: 256, + Value: "Product Name: ", + }, + }, + &ast.ExprArg{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 258, + NameEnd: 265, + Name: "product", + }, + &ast.Ident{ + NamePos: 266, + NameEnd: 270, + Name: "name", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 272, + ValueEnd: 276, + Value: "\n", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 294, + ValueEnd: 311, + Value: "Category Name: ", + }, + }, + &ast.ExprArg{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 313, + NameEnd: 321, + Name: "category", + }, + &ast.Ident{ + NamePos: 322, + NameEnd: 326, + Name: "name", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 328, + ValueEnd: 332, + Value: "\n", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 350, + ValueEnd: 372, + Value: "Product Description:", + }, + }, + &ast.ExprArg{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 374, + NameEnd: 381, + Name: "product", + }, + &ast.Ident{ + NamePos: 382, + NameEnd: 393, + Name: "description", + }, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 395, + Alias: &ast.Ident{ + NamePos: 398, + NameEnd: 404, + Name: "prompt", + }, + }, + }, + }, + From: &ast.From{ + From: 410, + Source: &ast.Join{ + Op: "INNER JOIN", + Left: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 424, + NameEnd: 432, + Name: "Products", + }, + As: &ast.AsAlias{ + As: 433, + Alias: &ast.Ident{ + NamePos: 436, + NameEnd: 443, + Name: "product", + }, + }, + }, + Right: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 449, + NameEnd: 459, + Name: "Categories", + }, + As: &ast.AsAlias{ + As: 460, + Alias: &ast.Ident{ + NamePos: 463, + NameEnd: 471, + Name: "category", + }, + }, + }, + Cond: &ast.On{ + On: 506, + Expr: &ast.BinaryExpr{ + Op: "=", + Left: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 509, + NameEnd: 516, + Name: "product", + }, + &ast.Ident{ + NamePos: 517, + NameEnd: 528, + Name: "category_id", + }, + }, + }, + Right: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 531, + NameEnd: 539, + Name: "category", + }, + &ast.Ident{ + NamePos: 540, + NameEnd: 542, + Name: "id", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.TypelessStructLiteral{ + Struct: 549, + Rparen: 578, + Values: []ast.TypelessStructLiteralArg{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 556, + ValueEnd: 559, + Base: 10, + Value: "100", + }, + As: &ast.AsAlias{ + As: 560, + Alias: &ast.Ident{ + NamePos: 563, + NameEnd: 578, + Name: "maxOutputTokens", + }, + }, + }, + }, + }, + }, + }, + Hint: &ast.Hint{ + Atmark: 582, + Rbrace: 613, + Records: []*ast.HintRecord{ + &ast.HintRecord{ + Key: &ast.Ident{ + NamePos: 584, + NameEnd: 611, + Name: "remote_udf_max_rows_per_rpc", + }, + Value: &ast.IntLiteral{ + ValuePos: 612, + ValueEnd: 613, + Base: 10, + Value: "1", + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT product_id, product_name, content FROM ML.PREDICT(MODEL TextBison, (SELECT product.id AS product_id, product.name AS product_name, CONCAT("Is this product safe for infants\?", "\n", "Product Name: ", product.name, "\n", "Category Name: ", category.name, "\n", "Product Description:", product.description) AS prompt FROM Products AS product INNER JOIN Categories AS category ON product.category_id = category.id), STRUCT(100 AS maxOutputTokens)) @{remote_udf_max_rows_per_rpc=1} diff --git a/testdata/result/statement/select_from_path.sql.txt b/testdata/result/statement/select_from_path.sql.txt index d58a1d70..d2ce6e21 100644 --- a/testdata/result/statement/select_from_path.sql.txt +++ b/testdata/result/statement/select_from_path.sql.txt @@ -5,13 +5,8 @@ FROM INFORMATION_SCHEMA.TABLES AS t TABLESAMPLE RESERVOIR (10 ROWS) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -33,8 +28,7 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 44, Alias: &ast.Ident{ NamePos: 47, @@ -42,8 +36,7 @@ FROM Name: "t", }, }, - WithOffset: (*ast.WithOffset)(nil), - Sample: &ast.TableSample{ + Sample: &ast.TableSample{ TableSample: 49, Method: "RESERVOIR", Size: &ast.TableSampleSize{ @@ -60,11 +53,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_function_hints.sql.txt b/testdata/result/statement/select_function_hints.sql.txt new file mode 100644 index 00000000..0aeff394 --- /dev/null +++ b/testdata/result/statement/select_function_hints.sql.txt @@ -0,0 +1,185 @@ +--- select_function_hints.sql +-- https://cloud.google.com/spanner/docs/reference/standard-sql/functions-reference#function_hints +SELECT + SUBSTRING(CAST(x AS STRING), 2, 5) AS w, + SUBSTRING(CAST(x AS STRING), 3, 7) AS y +FROM (SELECT SHA512(z) @{DISABLE_INLINE = TRUE} AS x FROM t) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Select: 99, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.CallExpr{ + Rparen: 143, + Func: &ast.Ident{ + NamePos: 110, + NameEnd: 119, + Name: "SUBSTRING", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.CastExpr{ + Cast: 120, + Rparen: 136, + Expr: &ast.Ident{ + NamePos: 125, + NameEnd: 126, + Name: "x", + }, + Type: &ast.SimpleType{ + NamePos: 130, + Name: "STRING", + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.IntLiteral{ + ValuePos: 139, + ValueEnd: 140, + Base: 10, + Value: "2", + }, + }, + &ast.ExprArg{ + Expr: &ast.IntLiteral{ + ValuePos: 142, + ValueEnd: 143, + Base: 10, + Value: "5", + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 145, + Alias: &ast.Ident{ + NamePos: 148, + NameEnd: 149, + Name: "w", + }, + }, + }, + &ast.Alias{ + Expr: &ast.CallExpr{ + Rparen: 188, + Func: &ast.Ident{ + NamePos: 155, + NameEnd: 164, + Name: "SUBSTRING", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.CastExpr{ + Cast: 165, + Rparen: 181, + Expr: &ast.Ident{ + NamePos: 170, + NameEnd: 171, + Name: "x", + }, + Type: &ast.SimpleType{ + NamePos: 175, + Name: "STRING", + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.IntLiteral{ + ValuePos: 184, + ValueEnd: 185, + Base: 10, + Value: "3", + }, + }, + &ast.ExprArg{ + Expr: &ast.IntLiteral{ + ValuePos: 187, + ValueEnd: 188, + Base: 10, + Value: "7", + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 190, + Alias: &ast.Ident{ + NamePos: 193, + NameEnd: 194, + Name: "y", + }, + }, + }, + }, + From: &ast.From{ + From: 195, + Source: &ast.SubQueryTableExpr{ + Lparen: 200, + Rparen: 254, + Query: &ast.Select{ + Select: 201, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.CallExpr{ + Rparen: 216, + Func: &ast.Ident{ + NamePos: 208, + NameEnd: 214, + Name: "SHA512", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.Ident{ + NamePos: 215, + NameEnd: 216, + Name: "z", + }, + }, + }, + Hint: &ast.Hint{ + Atmark: 218, + Rbrace: 241, + Records: []*ast.HintRecord{ + &ast.HintRecord{ + Key: &ast.Ident{ + NamePos: 220, + NameEnd: 234, + Name: "DISABLE_INLINE", + }, + Value: &ast.BoolLiteral{ + ValuePos: 237, + Value: true, + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 243, + Alias: &ast.Ident{ + NamePos: 246, + NameEnd: 247, + Name: "x", + }, + }, + }, + }, + From: &ast.From{ + From: 248, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 253, + NameEnd: 254, + Name: "t", + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT SUBSTRING(CAST(x AS STRING), 2, 5) AS w, SUBSTRING(CAST(x AS STRING), 3, 7) AS y FROM (SELECT SHA512(z) @{DISABLE_INLINE=TRUE} AS x FROM t) diff --git a/testdata/result/statement/select_hint.sql.txt b/testdata/result/statement/select_hint.sql.txt index de37c85f..374f27f1 100644 --- a/testdata/result/statement/select_hint.sql.txt +++ b/testdata/result/statement/select_hint.sql.txt @@ -3,7 +3,6 @@ --- AST &ast.QueryStatement{ Hint: &ast.Hint{ - Atmark: 0, Rbrace: 22, Records: []*ast.HintRecord{ &ast.HintRecord{ @@ -34,12 +33,9 @@ }, }, }, - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 24, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 24, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 31, @@ -48,12 +44,6 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_all.sql.txt b/testdata/result/statement/select_literals_all.sql.txt index 17137993..da902945 100644 --- a/testdata/result/statement/select_literals_all.sql.txt +++ b/testdata/result/statement/select_literals_all.sql.txt @@ -49,13 +49,8 @@ lines''', true, false --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.StringLiteral{ ValuePos: 9, @@ -152,7 +147,7 @@ lines''', ValuePos: 204, ValueEnd: 210, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -161,7 +156,7 @@ lines''', ValuePos: 214, ValueEnd: 224, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -170,7 +165,7 @@ lines''', ValuePos: 228, ValueEnd: 238, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -179,7 +174,7 @@ lines''', ValuePos: 242, ValueEnd: 250, Value: []uint8{ - 0x61, 0x62, 0x63, 0x2b, + 97, 98, 99, 43, }, }, }, @@ -188,7 +183,7 @@ lines''', ValuePos: 254, ValueEnd: 262, Value: []uint8{ - 0x61, 0x62, 0x63, 0x2b, + 97, 98, 99, 43, }, }, }, @@ -197,7 +192,7 @@ lines''', ValuePos: 266, ValueEnd: 277, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -266,7 +261,6 @@ lines''', Array: -1, Lbrack: 352, Rbrack: 360, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 353, @@ -294,7 +288,6 @@ lines''', Array: -1, Lbrack: 365, Rbrack: 380, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 366, @@ -319,7 +312,6 @@ lines''', Array: 385, Lbrack: 390, Rbrack: 398, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 391, @@ -379,7 +371,6 @@ lines''', NamePos: 442, Name: "INT64", }, - Values: []ast.Expr(nil), }, }, &ast.ExprSelectItem{ @@ -387,10 +378,8 @@ lines''', Array: 454, Rparen: 482, Query: &ast.Select{ - Select: 460, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 460, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 467, @@ -424,12 +413,6 @@ lines''', }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -438,10 +421,8 @@ lines''', Array: 487, Rparen: 509, Query: &ast.Select{ - Select: 493, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 493, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TupleStructLiteral{ Lparen: 500, @@ -469,12 +450,6 @@ lines''', }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -496,8 +471,7 @@ lines''', NameEnd: 539, Name: "DATE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 540, @@ -506,9 +480,6 @@ lines''', }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -549,8 +520,7 @@ lines''', NameEnd: 690, Name: "TIMESTAMP", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 691, @@ -559,9 +529,6 @@ lines''', }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -623,16 +590,9 @@ lines''', &ast.ExprSelectItem{ Expr: &ast.BoolLiteral{ ValuePos: 785, - Value: false, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_array.sql.txt b/testdata/result/statement/select_literals_array.sql.txt index 5955dc62..24ad47f4 100644 --- a/testdata/result/statement/select_literals_array.sql.txt +++ b/testdata/result/statement/select_literals_array.sql.txt @@ -8,19 +8,13 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 9, Rbrack: 17, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 10, @@ -48,7 +42,6 @@ SELECT Array: -1, Lbrack: 22, Rbrack: 37, - Type: nil, Values: []ast.Expr{ &ast.StringLiteral{ ValuePos: 23, @@ -73,7 +66,6 @@ SELECT Array: 42, Lbrack: 47, Rbrack: 55, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 48, @@ -133,16 +125,9 @@ SELECT NamePos: 99, Name: "INT64", }, - Values: []ast.Expr(nil), }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_array_invalid.sql.txt b/testdata/result/statement/select_literals_array_invalid.sql.txt index 2ffd9a3e..c4c94b67 100644 --- a/testdata/result/statement/select_literals_array_invalid.sql.txt +++ b/testdata/result/statement/select_literals_array_invalid.sql.txt @@ -4,25 +4,18 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArrayLiteral{ Array: -1, Lbrack: 9, Rbrack: 41, - Type: nil, Values: []ast.Expr{ &ast.ArrayLiteral{ Array: -1, Lbrack: 10, Rbrack: 18, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 11, @@ -48,7 +41,6 @@ SELECT Array: -1, Lbrack: 21, Rbrack: 29, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 22, @@ -74,7 +66,6 @@ SELECT Array: -1, Lbrack: 32, Rbrack: 40, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 33, @@ -100,12 +91,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_bytes.sql.txt b/testdata/result/statement/select_literals_bytes.sql.txt index 09b7dbee..498b1214 100644 --- a/testdata/result/statement/select_literals_bytes.sql.txt +++ b/testdata/result/statement/select_literals_bytes.sql.txt @@ -13,19 +13,14 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BytesLiteral{ ValuePos: 9, ValueEnd: 15, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -34,7 +29,7 @@ SELECT ValuePos: 19, ValueEnd: 29, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -43,7 +38,7 @@ SELECT ValuePos: 33, ValueEnd: 43, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -52,7 +47,7 @@ SELECT ValuePos: 47, ValueEnd: 59, Value: []uint8{ - 0x61, 0x62, 0x63, 0x0a, + 97, 98, 99, 10, }, }, }, @@ -61,7 +56,7 @@ SELECT ValuePos: 63, ValueEnd: 71, Value: []uint8{ - 0x61, 0x62, 0x63, 0x2b, + 97, 98, 99, 43, }, }, }, @@ -70,7 +65,7 @@ SELECT ValuePos: 75, ValueEnd: 83, Value: []uint8{ - 0x61, 0x62, 0x63, 0x2b, + 97, 98, 99, 43, }, }, }, @@ -79,7 +74,7 @@ SELECT ValuePos: 87, ValueEnd: 98, Value: []uint8{ - 0x61, 0x62, 0x63, + 97, 98, 99, }, }, }, @@ -88,7 +83,7 @@ SELECT ValuePos: 102, ValueEnd: 115, Value: []uint8{ - 0x61, 0x62, 0x63, 0x5c, 0x6e, + 97, 98, 99, 92, 110, }, }, }, @@ -97,7 +92,7 @@ SELECT ValuePos: 119, ValueEnd: 126, Value: []uint8{ - 0x00, + 0, }, }, }, @@ -106,17 +101,11 @@ SELECT ValuePos: 130, ValueEnd: 145, Value: []uint8{ - 0x3f, 0x3f, 0x3f, + 63, 63, 63, }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_date.sql.txt b/testdata/result/statement/select_literals_date.sql.txt index 7d21137b..fafc2985 100644 --- a/testdata/result/statement/select_literals_date.sql.txt +++ b/testdata/result/statement/select_literals_date.sql.txt @@ -13,13 +13,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.DateLiteral{ Date: 9, @@ -38,8 +33,7 @@ SELECT NameEnd: 33, Name: "DATE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 34, @@ -48,9 +42,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -101,8 +92,7 @@ SELECT NameEnd: 206, Name: "TIMESTAMP", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 207, @@ -111,9 +101,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, }, &ast.ExprSelectItem{ @@ -134,8 +121,7 @@ SELECT NameEnd: 255, Name: "DATE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 256, @@ -144,9 +130,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, As: &ast.AsAlias{ As: 270, @@ -165,8 +148,7 @@ SELECT NameEnd: 289, Name: "TIMESTAMP", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.ExprArg{ Expr: &ast.StringLiteral{ ValuePos: 290, @@ -175,9 +157,6 @@ SELECT }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, As: &ast.AsAlias{ As: 304, @@ -189,12 +168,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_float.sql.txt b/testdata/result/statement/select_literals_float.sql.txt index 1f90c1d9..3ccf54f0 100644 --- a/testdata/result/statement/select_literals_float.sql.txt +++ b/testdata/result/statement/select_literals_float.sql.txt @@ -7,13 +7,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.FloatLiteral{ ValuePos: 9, @@ -43,12 +38,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_int.sql.txt b/testdata/result/statement/select_literals_int.sql.txt index 4634fef4..385b2f03 100644 --- a/testdata/result/statement/select_literals_int.sql.txt +++ b/testdata/result/statement/select_literals_int.sql.txt @@ -7,13 +7,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 9, @@ -47,12 +42,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_paren.sql.txt b/testdata/result/statement/select_literals_paren.sql.txt index 34ae9052..5c845ef2 100644 --- a/testdata/result/statement/select_literals_paren.sql.txt +++ b/testdata/result/statement/select_literals_paren.sql.txt @@ -3,13 +3,8 @@ SELECT (1) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ParenExpr{ Lparen: 7, @@ -23,12 +18,6 @@ SELECT (1) }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_paren_with_operator.sql.txt b/testdata/result/statement/select_literals_paren_with_operator.sql.txt index 3efa5f2e..a0c52ced 100644 --- a/testdata/result/statement/select_literals_paren_with_operator.sql.txt +++ b/testdata/result/statement/select_literals_paren_with_operator.sql.txt @@ -3,13 +3,8 @@ SELECT (1+1) --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ParenExpr{ Lparen: 7, @@ -32,12 +27,6 @@ SELECT (1+1) }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_string.sql.txt b/testdata/result/statement/select_literals_string.sql.txt index c18ac805..8686fd58 100644 --- a/testdata/result/statement/select_literals_string.sql.txt +++ b/testdata/result/statement/select_literals_string.sql.txt @@ -25,13 +25,8 @@ lines''', --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.StringLiteral{ ValuePos: 9, @@ -180,12 +175,6 @@ lines''', }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_literals_struct.sql.txt b/testdata/result/statement/select_literals_struct.sql.txt index 3b45c25d..656850ee 100644 --- a/testdata/result/statement/select_literals_struct.sql.txt +++ b/testdata/result/statement/select_literals_struct.sql.txt @@ -18,22 +18,15 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArraySubQuery{ Array: 9, Rparen: 37, Query: &ast.Select{ - Select: 15, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 15, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 22, @@ -67,12 +60,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -81,10 +68,8 @@ SELECT Array: 42, Rparen: 73, Query: &ast.Select{ - Select: 48, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 48, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 55, @@ -116,12 +101,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -130,10 +109,8 @@ SELECT Array: 78, Rparen: 133, Query: &ast.Select{ - Select: 84, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 84, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 91, @@ -196,12 +173,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -210,10 +181,8 @@ SELECT Array: 138, Rparen: 181, Query: &ast.Select{ - Select: 144, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 144, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 151, @@ -271,12 +240,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -285,32 +248,27 @@ SELECT Array: 186, Rparen: 235, Query: &ast.Select{ - Select: 192, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 192, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 199, Rparen: 234, Fields: []*ast.StructField{ &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 206, Name: "INT64", }, }, &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 213, Name: "INT64", }, }, &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 220, Name: "INT64", }, @@ -339,12 +297,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -353,10 +305,8 @@ SELECT Array: 240, Rparen: 291, Query: &ast.Select{ - Select: 246, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 246, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 253, @@ -374,15 +324,13 @@ SELECT }, }, &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 269, Name: "INT64", }, }, &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 276, Name: "INT64", }, @@ -411,12 +359,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -425,10 +367,8 @@ SELECT Array: 296, Rparen: 329, Query: &ast.Select{ - Select: 302, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 302, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 309, @@ -470,12 +410,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -484,10 +418,8 @@ SELECT Array: 334, Rparen: 356, Query: &ast.Select{ - Select: 340, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 340, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TupleStructLiteral{ Lparen: 347, @@ -515,12 +447,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -529,10 +455,8 @@ SELECT Array: 361, Rparen: 392, Query: &ast.Select{ - Select: 367, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 367, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 374, @@ -561,12 +485,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -575,10 +493,8 @@ SELECT Array: 397, Rparen: 424, Query: &ast.Select{ - Select: 403, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 403, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 410, @@ -604,12 +520,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -618,18 +528,15 @@ SELECT Array: 429, Rparen: 458, Query: &ast.Select{ - Select: 435, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 435, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 442, Rparen: 457, Fields: []*ast.StructField{ &ast.StructField{ - Ident: (*ast.Ident)(nil), - Type: &ast.SimpleType{ + Type: &ast.SimpleType{ NamePos: 449, Name: "INT64", }, @@ -646,12 +553,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -660,10 +561,8 @@ SELECT Array: 463, Rparen: 485, Query: &ast.Select{ - Select: 469, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 469, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 476, @@ -681,12 +580,6 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -695,25 +588,15 @@ SELECT Array: 490, Rparen: 513, Query: &ast.Select{ - Select: 496, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 496, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 503, Rparen: 512, - Fields: []*ast.StructField(nil), - Values: []ast.Expr(nil), }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -722,24 +605,15 @@ SELECT Array: 518, Rparen: 539, Query: &ast.Select{ - Select: 524, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 524, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypelessStructLiteral{ Struct: 531, Rparen: 538, - Values: []ast.TypelessStructLiteralArg(nil), }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, @@ -747,12 +621,9 @@ SELECT Expr: &ast.ExistsSubQuery{ Exists: 544, Rparen: 564, - Hint: (*ast.Hint)(nil), Query: &ast.Select{ - Select: 551, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 551, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TupleStructLiteral{ Lparen: 558, @@ -774,22 +645,10 @@ SELECT }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_nest_complex.sql.txt b/testdata/result/statement/select_nest_complex.sql.txt index 81059415..19613b2e 100644 --- a/testdata/result/statement/select_nest_complex.sql.txt +++ b/testdata/result/statement/select_nest_complex.sql.txt @@ -8,13 +8,8 @@ from ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 7, }, @@ -25,122 +20,87 @@ from ( Lparen: 14, Rparen: 131, Source: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.SubQueryTableExpr{ + Op: "INNER JOIN", + Left: &ast.SubQueryTableExpr{ Lparen: 20, Rparen: 90, - Query: &ast.SubQuery{ - Lparen: 21, - Rparen: 81, - Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: true, - Queries: []ast.QueryExpr{ - &ast.SubQuery{ - Lparen: 22, - Rparen: 54, - Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ - &ast.Select{ - Select: 23, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Alias{ - Expr: &ast.IntLiteral{ - ValuePos: 30, - ValueEnd: 31, - Base: 10, - Value: "1", - }, - As: &ast.AsAlias{ - As: -1, - Alias: &ast.Ident{ - NamePos: 32, - NameEnd: 33, - Name: "A", + Query: &ast.Query{ + Query: &ast.SubQuery{ + Lparen: 21, + Rparen: 81, + Query: &ast.CompoundQuery{ + Op: "UNION", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ + &ast.SubQuery{ + Lparen: 22, + Rparen: 54, + Query: &ast.CompoundQuery{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ + &ast.Select{ + Select: 23, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.IntLiteral{ + ValuePos: 30, + ValueEnd: 31, + Base: 10, + Value: "1", + }, + As: &ast.AsAlias{ + As: -1, + Alias: &ast.Ident{ + NamePos: 32, + NameEnd: 33, + Name: "A", + }, }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), - }, - &ast.SubQuery{ - Lparen: 44, - Rparen: 53, - Query: &ast.Select{ - Select: 45, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.IntLiteral{ - ValuePos: 52, - ValueEnd: 53, - Base: 10, - Value: "2", + &ast.SubQuery{ + Lparen: 44, + Rparen: 53, + Query: &ast.Select{ + Select: 45, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 52, + ValueEnd: 53, + Base: 10, + Value: "2", + }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), - }, - &ast.SubQuery{ - Lparen: 71, - Rparen: 80, - Query: &ast.Select{ - Select: 72, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.IntLiteral{ - ValuePos: 79, - ValueEnd: 80, - Base: 10, - Value: "1", + &ast.SubQuery{ + Lparen: 71, + Rparen: 80, + Query: &ast.Select{ + Select: 72, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 79, + ValueEnd: 80, + Base: 10, + Value: "1", + }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 83, Count: &ast.IntLiteral{ ValuePos: 89, @@ -148,20 +108,15 @@ from ( Base: 10, Value: "1", }, - Offset: (*ast.Offset)(nil), }, }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, Right: &ast.SubQueryTableExpr{ Lparen: 103, Rparen: 119, Query: &ast.Select{ - Select: 104, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 104, + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.IntLiteral{ ValuePos: 111, @@ -195,15 +150,7 @@ from ( }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, Cond: &ast.Using{ Using: 121, @@ -217,14 +164,8 @@ from ( }, }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_select_limit_expr.sql.txt b/testdata/result/statement/select_select_limit_expr.sql.txt index 7a4f364a..673e13ae 100644 --- a/testdata/result/statement/select_select_limit_expr.sql.txt +++ b/testdata/result/statement/select_select_limit_expr.sql.txt @@ -3,45 +3,33 @@ select ((select 1) limit 1 offset 0) + 3 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BinaryExpr{ Op: "+", Left: &ast.ScalarSubQuery{ Lparen: 7, Rparen: 35, - Query: &ast.SubQuery{ - Lparen: 8, - Rparen: 17, - Query: &ast.Select{ - Select: 9, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.IntLiteral{ - ValuePos: 16, - ValueEnd: 17, - Base: 10, - Value: "1", + Query: &ast.Query{ + Query: &ast.SubQuery{ + Lparen: 8, + Rparen: 17, + Query: &ast.Select{ + Select: 9, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 16, + ValueEnd: 17, + Base: 10, + Value: "1", + }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 19, Count: &ast.IntLiteral{ ValuePos: 25, @@ -70,12 +58,6 @@ select ((select 1) limit 1 offset 0) + 3 }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_select_set_operator_expr.sql.txt b/testdata/result/statement/select_select_set_operator_expr.sql.txt index fc1d824d..141358d5 100644 --- a/testdata/result/statement/select_select_set_operator_expr.sql.txt +++ b/testdata/result/statement/select_select_set_operator_expr.sql.txt @@ -5,13 +5,8 @@ select ((select 1) union all (select 2)) + 3, --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BinaryExpr{ Op: "+", @@ -19,17 +14,15 @@ select ((select 1) union all (select 2)) + 3, Lparen: 7, Rparen: 39, Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.SubQuery{ Lparen: 8, Rparen: 17, Query: &ast.Select{ - Select: 9, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 9, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 16, @@ -39,24 +32,14 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 29, Rparen: 38, Query: &ast.Select{ - Select: 30, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 30, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 37, @@ -66,19 +49,9 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, Right: &ast.IntLiteral{ @@ -96,17 +69,15 @@ select ((select 1) union all (select 2)) + 3, Lparen: 53, Rparen: 89, Query: &ast.CompoundQuery{ - Op: "INTERSECT", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "INTERSECT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.SubQuery{ Lparen: 54, Rparen: 63, Query: &ast.Select{ - Select: 55, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 55, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 62, @@ -116,24 +87,14 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 79, Rparen: 88, Query: &ast.Select{ - Select: 80, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 80, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 87, @@ -143,19 +104,9 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, Right: &ast.IntLiteral{ @@ -173,17 +124,15 @@ select ((select 1) union all (select 2)) + 3, Lparen: 103, Rparen: 136, Query: &ast.CompoundQuery{ - Op: "EXCEPT", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "EXCEPT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.SubQuery{ Lparen: 104, Rparen: 113, Query: &ast.Select{ - Select: 105, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 105, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 112, @@ -193,24 +142,14 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 126, Rparen: 135, Query: &ast.Select{ - Select: 127, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 127, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 134, @@ -220,19 +159,9 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, Right: &ast.IntLiteral{ @@ -244,12 +173,6 @@ select ((select 1) union all (select 2)) + 3, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_as_struct_subquery.sql.txt b/testdata/result/statement/select_singer_with_as_struct_subquery.sql.txt index 5bac5fd7..0aa86fe2 100644 --- a/testdata/result/statement/select_singer_with_as_struct_subquery.sql.txt +++ b/testdata/result/statement/select_singer_with_as_struct_subquery.sql.txt @@ -10,13 +10,8 @@ SELECT --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArraySubQuery{ Array: 9, @@ -24,36 +19,30 @@ SELECT Query: &ast.SubQuery{ Lparen: 20, Rparen: 88, - Query: &ast.Select{ - Select: 28, - Distinct: false, - As: &ast.AsStruct{ - As: 35, - Struct: 38, - }, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 53, + Query: &ast.Query{ + Query: &ast.Select{ + Select: 28, + As: &ast.AsStruct{ + As: 35, + Struct: 38, }, - }, - From: &ast.From{ - From: 61, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 66, - NameEnd: 73, - Name: "Singers", + Results: []ast.SelectItem{ + &ast.Star{ + Star: 53, + }, + }, + From: &ast.From{ + From: 61, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 66, + NameEnd: 73, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 74, Count: &ast.IntLiteral{ ValuePos: 80, @@ -61,21 +50,12 @@ SELECT Base: 10, Value: "100", }, - Offset: (*ast.Offset)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_asterisk.sql.txt b/testdata/result/statement/select_singer_with_asterisk.sql.txt index 2ef354d2..3511b775 100644 --- a/testdata/result/statement/select_singer_with_asterisk.sql.txt +++ b/testdata/result/statement/select_singer_with_asterisk.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,16 +20,8 @@ FROM NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_column_and_asterisk.sql.txt b/testdata/result/statement/select_singer_with_column_and_asterisk.sql.txt index 4aace401..40ae9fad 100644 --- a/testdata/result/statement/select_singer_with_column_and_asterisk.sql.txt +++ b/testdata/result/statement/select_singer_with_column_and_asterisk.sql.txt @@ -7,13 +7,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 9, @@ -33,16 +28,8 @@ FROM NameEnd: 37, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_column_names.sql.txt b/testdata/result/statement/select_singer_with_column_names.sql.txt index 7bef784a..31e86dce 100644 --- a/testdata/result/statement/select_singer_with_column_names.sql.txt +++ b/testdata/result/statement/select_singer_with_column_names.sql.txt @@ -9,13 +9,8 @@ FROM Singers --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.Ident{ NamePos: 9, @@ -68,16 +63,8 @@ FROM Singers NameEnd: 88, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_cross_join.sql.txt b/testdata/result/statement/select_singer_with_cross_join.sql.txt index f7be0a42..34362fa4 100644 --- a/testdata/result/statement/select_singer_with_cross_join.sql.txt +++ b/testdata/result/statement/select_singer_with_cross_join.sql.txt @@ -8,13 +8,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -22,17 +17,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "CROSS JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "CROSS JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -40,7 +32,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -48,8 +39,7 @@ FROM NameEnd: 50, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 51, @@ -57,16 +47,9 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_distinct.sql.txt b/testdata/result/statement/select_singer_with_distinct.sql.txt index e3018b3e..7875b0ea 100644 --- a/testdata/result/statement/select_singer_with_distinct.sql.txt +++ b/testdata/result/statement/select_singer_with_distinct.sql.txt @@ -7,13 +7,9 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: true, - As: nil, - Results: []ast.SelectItem{ + AllOrDistinct: "DISTINCT", + Results: []ast.SelectItem{ &ast.Star{ Star: 20, }, @@ -26,16 +22,8 @@ FROM NameEnd: 36, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_full_join.sql.txt b/testdata/result/statement/select_singer_with_full_join.sql.txt index 8e364024..4036f6ce 100644 --- a/testdata/result/statement/select_singer_with_full_join.sql.txt +++ b/testdata/result/statement/select_singer_with_full_join.sql.txt @@ -7,13 +7,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -21,17 +16,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: ",", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 26, Alias: &ast.Ident{ NamePos: 29, @@ -39,7 +31,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -47,8 +38,7 @@ FROM NameEnd: 41, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 42, Alias: &ast.Ident{ NamePos: 45, @@ -56,16 +46,9 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_groupby.sql.txt b/testdata/result/statement/select_singer_with_groupby.sql.txt index 2e8f6f26..0c93d97d 100644 --- a/testdata/result/statement/select_singer_with_groupby.sql.txt +++ b/testdata/result/statement/select_singer_with_groupby.sql.txt @@ -8,13 +8,8 @@ GROUP BY --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 9, @@ -38,12 +33,8 @@ GROUP BY NameEnd: 44, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), GroupBy: &ast.GroupBy{ Group: 45, Exprs: []ast.Expr{ @@ -59,9 +50,6 @@ GROUP BY }, }, }, - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_hash_join.sql.txt b/testdata/result/statement/select_singer_with_hash_join.sql.txt index 51741f24..cd61e22e 100644 --- a/testdata/result/statement/select_singer_with_hash_join.sql.txt +++ b/testdata/result/statement/select_singer_with_hash_join.sql.txt @@ -8,13 +8,8 @@ FROM ON A.SingerID = B.SingerID --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -24,15 +19,13 @@ FROM Source: &ast.Join{ Op: "INNER JOIN", Method: "HASH", - Hint: (*ast.Hint)(nil), Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -40,7 +33,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -48,8 +40,7 @@ FROM NameEnd: 49, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 50, @@ -57,7 +48,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 54, @@ -95,11 +85,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_having.sql.txt b/testdata/result/statement/select_singer_with_having.sql.txt index 9d853bd1..c0af45ac 100644 --- a/testdata/result/statement/select_singer_with_having.sql.txt +++ b/testdata/result/statement/select_singer_with_having.sql.txt @@ -10,13 +10,8 @@ HAVING --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Ident{ NamePos: 9, @@ -33,12 +28,8 @@ HAVING NameEnd: 32, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), GroupBy: &ast.GroupBy{ Group: 33, Exprs: []ast.Expr{ @@ -66,8 +57,6 @@ HAVING }, }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_in_and_unnest.sql.txt b/testdata/result/statement/select_singer_with_in_and_unnest.sql.txt index ac358ab5..c410d65a 100644 --- a/testdata/result/statement/select_singer_with_in_and_unnest.sql.txt +++ b/testdata/result/statement/select_singer_with_in_and_unnest.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,15 +22,11 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ Where: 26, Expr: &ast.InExpr{ - Not: false, Left: &ast.Ident{ NamePos: 34, NameEnd: 42, @@ -48,7 +39,6 @@ WHERE Array: 53, Lbrack: 58, Rbrack: 66, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 59, @@ -73,10 +63,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_in_and_unnest_with_query_parameter.sql.txt b/testdata/result/statement/select_singer_with_in_and_unnest_with_query_parameter.sql.txt index 456d2286..293e2401 100644 --- a/testdata/result/statement/select_singer_with_in_and_unnest_with_query_parameter.sql.txt +++ b/testdata/result/statement/select_singer_with_in_and_unnest_with_query_parameter.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,15 +22,11 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ Where: 26, Expr: &ast.InExpr{ - Not: false, Left: &ast.Ident{ NamePos: 34, NameEnd: 42, @@ -51,10 +42,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_join.sql.txt b/testdata/result/statement/select_singer_with_join.sql.txt index ab573b3f..70831a2f 100644 --- a/testdata/result/statement/select_singer_with_join.sql.txt +++ b/testdata/result/statement/select_singer_with_join.sql.txt @@ -9,13 +9,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -23,17 +18,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "LEFT OUTER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -41,7 +33,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -49,8 +40,7 @@ FROM NameEnd: 55, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 56, @@ -58,7 +48,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 60, @@ -96,11 +85,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_join_hint.sql.txt b/testdata/result/statement/select_singer_with_join_hint.sql.txt index 92a14a85..272a54be 100644 --- a/testdata/result/statement/select_singer_with_join_hint.sql.txt +++ b/testdata/result/statement/select_singer_with_join_hint.sql.txt @@ -18,13 +18,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -32,9 +27,8 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: &ast.Hint{ + Op: "INNER JOIN", + Hint: &ast.Hint{ Atmark: 258, Rbrace: 279, Records: []*ast.HintRecord{ @@ -53,9 +47,8 @@ FROM }, }, Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: &ast.Hint{ + Op: "INNER JOIN", + Hint: &ast.Hint{ Atmark: 187, Rbrace: 209, Records: []*ast.HintRecord{ @@ -74,9 +67,8 @@ FROM }, }, Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: &ast.Hint{ + Op: "INNER JOIN", + Hint: &ast.Hint{ Atmark: 117, Rbrace: 138, Records: []*ast.HintRecord{ @@ -95,9 +87,8 @@ FROM }, }, Left: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: &ast.Hint{ + Op: "LEFT OUTER JOIN", + Hint: &ast.Hint{ Atmark: 45, Rbrace: 68, Records: []*ast.HintRecord{ @@ -120,8 +111,7 @@ FROM NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -129,7 +119,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -137,8 +126,7 @@ FROM NameEnd: 79, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 80, @@ -146,7 +134,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 84, @@ -189,8 +176,7 @@ FROM NameEnd: 149, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 150, @@ -198,7 +184,6 @@ FROM Name: "C", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 154, @@ -241,8 +226,7 @@ FROM NameEnd: 220, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 221, @@ -250,7 +234,6 @@ FROM Name: "D", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 225, @@ -293,8 +276,7 @@ FROM NameEnd: 290, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 291, @@ -302,7 +284,6 @@ FROM Name: "E", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 295, @@ -340,11 +321,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_join_twice.sql.txt b/testdata/result/statement/select_singer_with_join_twice.sql.txt index 035780a4..c2f8e6dd 100644 --- a/testdata/result/statement/select_singer_with_join_twice.sql.txt +++ b/testdata/result/statement/select_singer_with_join_twice.sql.txt @@ -12,13 +12,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -26,21 +21,16 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "INNER JOIN", + Left: &ast.Join{ + Op: "INNER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -48,7 +38,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -56,8 +45,7 @@ FROM NameEnd: 44, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 45, @@ -65,7 +53,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 49, @@ -108,8 +95,7 @@ FROM NameEnd: 98, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 99, @@ -117,7 +103,6 @@ FROM Name: "C", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 103, @@ -155,11 +140,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_join_using.sql.txt b/testdata/result/statement/select_singer_with_join_using.sql.txt index e37df1cb..a68579f7 100644 --- a/testdata/result/statement/select_singer_with_join_using.sql.txt +++ b/testdata/result/statement/select_singer_with_join_using.sql.txt @@ -9,13 +9,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -23,17 +18,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "LEFT OUTER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -41,7 +33,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -49,8 +40,7 @@ FROM NameEnd: 55, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 56, @@ -58,7 +48,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.Using{ Using: 60, @@ -78,11 +67,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_join_various.sql.txt b/testdata/result/statement/select_singer_with_join_various.sql.txt index 45d847b9..17f7be5a 100644 --- a/testdata/result/statement/select_singer_with_join_various.sql.txt +++ b/testdata/result/statement/select_singer_with_join_various.sql.txt @@ -32,13 +32,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -46,49 +41,30 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "RIGHT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "RIGHT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "FULL OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "FULL OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "CROSS JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: "INNER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "RIGHT OUTER JOIN", + Left: &ast.Join{ + Op: "RIGHT OUTER JOIN", + Left: &ast.Join{ + Op: "LEFT OUTER JOIN", + Left: &ast.Join{ + Op: "LEFT OUTER JOIN", + Left: &ast.Join{ + Op: "FULL OUTER JOIN", + Left: &ast.Join{ + Op: "FULL OUTER JOIN", + Left: &ast.Join{ + Op: "CROSS JOIN", + Left: &ast.Join{ + Op: "INNER JOIN", + Left: &ast.Join{ + Op: "INNER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -96,7 +72,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -104,8 +79,7 @@ FROM NameEnd: 44, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 45, @@ -113,7 +87,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 49, @@ -156,8 +129,7 @@ FROM NameEnd: 98, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 99, @@ -165,7 +137,6 @@ FROM Name: "C", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 103, @@ -208,8 +179,7 @@ FROM NameEnd: 152, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 153, @@ -217,9 +187,7 @@ FROM Name: "D", }, }, - Sample: (*ast.TableSample)(nil), }, - Cond: nil, }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -227,8 +195,7 @@ FROM NameEnd: 176, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 177, @@ -236,7 +203,6 @@ FROM Name: "E", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 181, @@ -279,8 +245,7 @@ FROM NameEnd: 235, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 236, @@ -288,7 +253,6 @@ FROM Name: "F", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 240, @@ -331,8 +295,7 @@ FROM NameEnd: 288, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 289, @@ -340,7 +303,6 @@ FROM Name: "G", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 293, @@ -383,8 +345,7 @@ FROM NameEnd: 347, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 348, @@ -392,7 +353,6 @@ FROM Name: "H", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 352, @@ -435,8 +395,7 @@ FROM NameEnd: 401, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 402, @@ -444,7 +403,6 @@ FROM Name: "I", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 406, @@ -487,8 +445,7 @@ FROM NameEnd: 461, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 462, @@ -496,7 +453,6 @@ FROM Name: "J", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 466, @@ -534,11 +490,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_limit.sql.txt b/testdata/result/statement/select_singer_with_limit.sql.txt index 388574d4..685f9467 100644 --- a/testdata/result/statement/select_singer_with_limit.sql.txt +++ b/testdata/result/statement/select_singer_with_limit.sql.txt @@ -7,35 +7,25 @@ LIMIT 100 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 9, + Query: &ast.Query{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 9, + }, }, - }, - From: &ast.From{ - From: 11, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 18, - NameEnd: 25, - Name: "Singers", + From: &ast.From{ + From: 11, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 18, + NameEnd: 25, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 26, Count: &ast.IntLiteral{ ValuePos: 32, @@ -43,7 +33,6 @@ LIMIT 100 Base: 10, Value: "100", }, - Offset: (*ast.Offset)(nil), }, }, } diff --git a/testdata/result/statement/select_singer_with_limit_and_skiprows.sql.txt b/testdata/result/statement/select_singer_with_limit_and_skiprows.sql.txt index f1293a6a..a076e0c3 100644 --- a/testdata/result/statement/select_singer_with_limit_and_skiprows.sql.txt +++ b/testdata/result/statement/select_singer_with_limit_and_skiprows.sql.txt @@ -8,35 +8,25 @@ OFFSET 10 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 9, + Query: &ast.Query{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 9, + }, }, - }, - From: &ast.From{ - From: 11, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 18, - NameEnd: 25, - Name: "Singers", + From: &ast.From{ + From: 11, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 18, + NameEnd: 25, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 26, Count: &ast.IntLiteral{ ValuePos: 32, diff --git a/testdata/result/statement/select_singer_with_orderby.sql.txt b/testdata/result/statement/select_singer_with_orderby.sql.txt index 564ee7f5..06a05fad 100644 --- a/testdata/result/statement/select_singer_with_orderby.sql.txt +++ b/testdata/result/statement/select_singer_with_orderby.sql.txt @@ -9,33 +9,24 @@ ORDER BY BirthDate DESC --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 9, + Query: &ast.Query{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 9, + }, }, - }, - From: &ast.From{ - From: 11, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 18, - NameEnd: 25, - Name: "Singers", + From: &ast.From{ + From: 11, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 18, + NameEnd: 25, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), OrderBy: &ast.OrderBy{ Order: 26, Items: []*ast.OrderByItem{ @@ -46,8 +37,6 @@ ORDER BY NameEnd: 46, Name: "FirstName", }, - Collate: (*ast.Collate)(nil), - Dir: "", }, &ast.OrderByItem{ DirPos: -1, @@ -64,7 +53,6 @@ ORDER BY Value: "en_US", }, }, - Dir: "", }, &ast.OrderByItem{ DirPos: 88, @@ -73,12 +61,10 @@ ORDER BY NameEnd: 87, Name: "BirthDate", }, - Collate: (*ast.Collate)(nil), - Dir: "DESC", + Dir: "DESC", }, }, }, - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_query_parameter.sql.txt b/testdata/result/statement/select_singer_with_query_parameter.sql.txt index 3ec0effb..6eb90de2 100644 --- a/testdata/result/statement/select_singer_with_query_parameter.sql.txt +++ b/testdata/result/statement/select_singer_with_query_parameter.sql.txt @@ -9,13 +9,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -28,9 +23,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -63,10 +55,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_root_parent.sql.txt b/testdata/result/statement/select_singer_with_root_parent.sql.txt index 0347bbaf..967a4a9e 100644 --- a/testdata/result/statement/select_singer_with_root_parent.sql.txt +++ b/testdata/result/statement/select_singer_with_root_parent.sql.txt @@ -3,16 +3,11 @@ --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.SubQuery{ - Lparen: 0, Rparen: 24, Query: &ast.Select{ - Select: 2, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 2, + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,19 +20,9 @@ NameEnd: 23, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_select_in_from.sql.txt b/testdata/result/statement/select_singer_with_select_in_from.sql.txt index 6502a2a8..8945f214 100644 --- a/testdata/result/statement/select_singer_with_select_in_from.sql.txt +++ b/testdata/result/statement/select_singer_with_select_in_from.sql.txt @@ -12,13 +12,8 @@ FROM ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -29,10 +24,8 @@ FROM ( Lparen: 16, Rparen: 77, Query: &ast.Select{ - Select: 20, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 20, + Results: []ast.SelectItem{ &ast.Star{ Star: 31, }, @@ -45,9 +38,6 @@ FROM ( NameEnd: 51, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -67,20 +57,9 @@ FROM ( }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_select_in_from_and_as.sql.txt b/testdata/result/statement/select_singer_with_select_in_from_and_as.sql.txt index fda2490e..7b5f6b4b 100644 --- a/testdata/result/statement/select_singer_with_select_in_from_and_as.sql.txt +++ b/testdata/result/statement/select_singer_with_select_in_from_and_as.sql.txt @@ -12,13 +12,8 @@ FROM ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -29,10 +24,8 @@ FROM ( Lparen: 16, Rparen: 77, Query: &ast.Select{ - Select: 20, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 20, + Results: []ast.SelectItem{ &ast.Star{ Star: 31, }, @@ -45,9 +38,6 @@ FROM ( NameEnd: 51, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -67,10 +57,6 @@ FROM ( }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, As: &ast.AsAlias{ As: 79, @@ -80,14 +66,8 @@ FROM ( Name: "S", }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_single_column_subquery.sql.txt b/testdata/result/statement/select_singer_with_single_column_subquery.sql.txt index 976b4b8a..7fa96ac9 100644 --- a/testdata/result/statement/select_singer_with_single_column_subquery.sql.txt +++ b/testdata/result/statement/select_singer_with_single_column_subquery.sql.txt @@ -6,48 +6,36 @@ SELECT ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ScalarSubQuery{ Lparen: 7, Rparen: 53, - Query: &ast.Select{ - Select: 11, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 18, - NameEnd: 27, - Name: "FirstName", + Query: &ast.Query{ + Query: &ast.Select{ + Select: 11, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 18, + NameEnd: 27, + Name: "FirstName", + }, }, }, - }, - From: &ast.From{ - From: 30, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 35, - NameEnd: 42, - Name: "Singers", + From: &ast.From{ + From: 30, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 35, + NameEnd: 42, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 43, Count: &ast.IntLiteral{ ValuePos: 49, @@ -55,18 +43,11 @@ SELECT ( Base: 10, Value: "100", }, - Offset: (*ast.Offset)(nil), }, }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_single_column_subquery_with_at.sql.txt b/testdata/result/statement/select_singer_with_single_column_subquery_with_at.sql.txt index c420f982..b536ed0f 100644 --- a/testdata/result/statement/select_singer_with_single_column_subquery_with_at.sql.txt +++ b/testdata/result/statement/select_singer_with_single_column_subquery_with_at.sql.txt @@ -6,48 +6,36 @@ SELECT ( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.ScalarSubQuery{ Lparen: 7, Rparen: 53, - Query: &ast.Select{ - Select: 11, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 18, - NameEnd: 27, - Name: "FirstName", + Query: &ast.Query{ + Query: &ast.Select{ + Select: 11, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 18, + NameEnd: 27, + Name: "FirstName", + }, }, }, - }, - From: &ast.From{ - From: 30, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 35, - NameEnd: 42, - Name: "Singers", + From: &ast.From{ + From: 30, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 35, + NameEnd: 42, + Name: "Singers", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: &ast.Limit{ + Limit: &ast.Limit{ Limit: 43, Count: &ast.IntLiteral{ ValuePos: 49, @@ -55,7 +43,6 @@ SELECT ( Base: 10, Value: "100", }, - Offset: (*ast.Offset)(nil), }, }, }, @@ -69,12 +56,6 @@ SELECT ( }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_table_alias.sql.txt b/testdata/result/statement/select_singer_with_table_alias.sql.txt index 190521fb..e4423eb7 100644 --- a/testdata/result/statement/select_singer_with_table_alias.sql.txt +++ b/testdata/result/statement/select_singer_with_table_alias.sql.txt @@ -7,13 +7,8 @@ FROM Singers S --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.DotStar{ Star: 11, Expr: &ast.Ident{ @@ -71,8 +66,7 @@ FROM Singers S NameEnd: 60, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 61, @@ -80,14 +74,8 @@ FROM Singers S Name: "S", }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_table_alias_with_hint.sql.txt b/testdata/result/statement/select_singer_with_table_alias_with_hint.sql.txt index 3d72f5bf..0632d7a7 100644 --- a/testdata/result/statement/select_singer_with_table_alias_with_hint.sql.txt +++ b/testdata/result/statement/select_singer_with_table_alias_with_hint.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -51,14 +46,8 @@ FROM Name: "S", }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_table_hint.sql.txt b/testdata/result/statement/select_singer_with_table_hint.sql.txt index 5bac204b..ceac381e 100644 --- a/testdata/result/statement/select_singer_with_table_hint.sql.txt +++ b/testdata/result/statement/select_singer_with_table_hint.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -43,15 +38,8 @@ FROM }, }, }, - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_tablesample.sql.txt b/testdata/result/statement/select_singer_with_tablesample.sql.txt index f333017d..6f4e56c8 100644 --- a/testdata/result/statement/select_singer_with_tablesample.sql.txt +++ b/testdata/result/statement/select_singer_with_tablesample.sql.txt @@ -8,13 +8,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -22,21 +17,16 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.Join{ - Op: ",", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: ",", + Left: &ast.Join{ + Op: ",", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 26, Alias: &ast.Ident{ NamePos: 29, @@ -66,8 +56,7 @@ FROM NameEnd: 74, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 75, Alias: &ast.Ident{ NamePos: 78, @@ -90,7 +79,6 @@ FROM }, }, }, - Cond: nil, }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -98,8 +86,7 @@ FROM NameEnd: 126, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 127, Alias: &ast.Ident{ NamePos: 130, @@ -122,14 +109,8 @@ FROM }, }, }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_tableset.sql.txt b/testdata/result/statement/select_singer_with_tableset.sql.txt index d86f32dc..3b6a2daf 100644 --- a/testdata/result/statement/select_singer_with_tableset.sql.txt +++ b/testdata/result/statement/select_singer_with_tableset.sql.txt @@ -5,17 +5,12 @@ SELECT * FROM Singers --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 7, }, @@ -28,22 +23,12 @@ SELECT * FROM Singers NameEnd: 21, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.Select{ - Select: 32, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 32, + Results: []ast.SelectItem{ &ast.Star{ Star: 39, }, @@ -56,20 +41,10 @@ SELECT * FROM Singers NameEnd: 53, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_tableset_complex.sql.txt b/testdata/result/statement/select_singer_with_tableset_complex.sql.txt index 39c7e022..bcea2468 100644 --- a/testdata/result/statement/select_singer_with_tableset_complex.sql.txt +++ b/testdata/result/statement/select_singer_with_tableset_complex.sql.txt @@ -25,17 +25,12 @@ UNION ALL --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 7, }, @@ -48,29 +43,19 @@ UNION ALL NameEnd: 21, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 32, Rparen: 367, Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: true, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 36, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 36, + Results: []ast.SelectItem{ &ast.Star{ Star: 43, }, @@ -83,29 +68,19 @@ UNION ALL NameEnd: 57, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 77, Rparen: 365, Query: &ast.CompoundQuery{ - Op: "INTERSECT", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "INTERSECT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 83, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 83, + Results: []ast.SelectItem{ &ast.Star{ Star: 90, }, @@ -118,29 +93,19 @@ UNION ALL NameEnd: 104, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 127, Rparen: 361, Query: &ast.CompoundQuery{ - Op: "INTERSECT", - Distinct: true, - Queries: []ast.QueryExpr{ + Op: "INTERSECT", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 135, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 135, + Results: []ast.SelectItem{ &ast.Star{ Star: 142, }, @@ -153,29 +118,19 @@ UNION ALL NameEnd: 156, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 188, Rparen: 355, Query: &ast.CompoundQuery{ - Op: "EXCEPT", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "EXCEPT", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 198, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 198, + Results: []ast.SelectItem{ &ast.Star{ Star: 205, }, @@ -188,29 +143,19 @@ UNION ALL NameEnd: 219, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 247, Rparen: 347, Query: &ast.CompoundQuery{ - Op: "EXCEPT", - Distinct: true, - Queries: []ast.QueryExpr{ + Op: "EXCEPT", + AllOrDistinct: "DISTINCT", + Queries: []ast.QueryExpr{ &ast.Select{ - Select: 259, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 259, + Results: []ast.SelectItem{ &ast.Star{ Star: 266, }, @@ -223,22 +168,12 @@ UNION ALL NameEnd: 280, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.Select{ - Select: 317, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 317, + Results: []ast.SelectItem{ &ast.Star{ Star: 324, }, @@ -251,55 +186,25 @@ UNION ALL NameEnd: 338, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_tableset_with_where.sql.txt b/testdata/result/statement/select_singer_with_tableset_with_where.sql.txt index 06389511..56b6c6a7 100644 --- a/testdata/result/statement/select_singer_with_tableset_with_where.sql.txt +++ b/testdata/result/statement/select_singer_with_tableset_with_where.sql.txt @@ -9,83 +9,63 @@ ORDER BY --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), - Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ - &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 7, - }, - }, - From: &ast.From{ - From: 9, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 14, - NameEnd: 21, - Name: "Singers", + Query: &ast.Query{ + Query: &ast.CompoundQuery{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ + &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, - }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), - }, - &ast.Select{ - Select: 32, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 39, + From: &ast.From{ + From: 9, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 14, + NameEnd: 21, + Name: "Singers", + }, + }, }, }, - From: &ast.From{ - From: 41, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 46, - NameEnd: 53, - Name: "Singers", + &ast.Select{ + Select: 32, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 39, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, - }, - Where: &ast.Where{ - Where: 54, - Expr: &ast.BinaryExpr{ - Op: "=", - Left: &ast.Ident{ - NamePos: 62, - NameEnd: 70, - Name: "SingerId", + From: &ast.From{ + From: 41, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 46, + NameEnd: 53, + Name: "Singers", + }, }, - Right: &ast.IntLiteral{ - ValuePos: 73, - ValueEnd: 74, - Base: 10, - Value: "1", + }, + Where: &ast.Where{ + Where: 54, + Expr: &ast.BinaryExpr{ + Op: "=", + Left: &ast.Ident{ + NamePos: 62, + NameEnd: 70, + Name: "SingerId", + }, + Right: &ast.IntLiteral{ + ValuePos: 73, + ValueEnd: 74, + Base: 10, + Value: "1", + }, }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, OrderBy: &ast.OrderBy{ @@ -98,12 +78,9 @@ ORDER BY NameEnd: 95, Name: "FirstName", }, - Collate: (*ast.Collate)(nil), - Dir: "", }, }, }, - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_toplevel_join_hint.sql.txt b/testdata/result/statement/select_singer_with_toplevel_join_hint.sql.txt index 450aca21..6b0504d6 100644 --- a/testdata/result/statement/select_singer_with_toplevel_join_hint.sql.txt +++ b/testdata/result/statement/select_singer_with_toplevel_join_hint.sql.txt @@ -11,7 +11,6 @@ FROM --- AST &ast.QueryStatement{ Hint: &ast.Hint{ - Atmark: 0, Rbrace: 23, Records: []*ast.HintRecord{ &ast.HintRecord{ @@ -27,12 +26,9 @@ FROM }, }, }, - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 25, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 25, + Results: []ast.SelectItem{ &ast.Star{ Star: 34, }, @@ -40,17 +36,14 @@ FROM From: &ast.From{ From: 36, Source: &ast.Join{ - Op: "LEFT OUTER JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "LEFT OUTER JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 43, NameEnd: 50, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 51, @@ -58,7 +51,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -66,8 +58,7 @@ FROM NameEnd: 80, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 81, @@ -75,7 +66,6 @@ FROM Name: "B", }, }, - Sample: (*ast.TableSample)(nil), }, Cond: &ast.On{ On: 85, @@ -113,11 +103,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_value_hex.sql.txt b/testdata/result/statement/select_singer_with_value_hex.sql.txt index 1cd2c0fc..b1694221 100644 --- a/testdata/result/statement/select_singer_with_value_hex.sql.txt +++ b/testdata/result/statement/select_singer_with_value_hex.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,9 +22,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -49,10 +41,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_where.sql.txt b/testdata/result/statement/select_singer_with_where.sql.txt index 5c42d434..d51994ee 100644 --- a/testdata/result/statement/select_singer_with_where.sql.txt +++ b/testdata/result/statement/select_singer_with_where.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,9 +22,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -49,10 +41,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_where_and_comparison.sql.txt b/testdata/result/statement/select_singer_with_where_and_comparison.sql.txt index ba18a39e..54044e35 100644 --- a/testdata/result/statement/select_singer_with_where_and_comparison.sql.txt +++ b/testdata/result/statement/select_singer_with_where_and_comparison.sql.txt @@ -25,13 +25,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -44,9 +39,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -175,7 +167,6 @@ WHERE }, }, Right: &ast.InExpr{ - Not: false, Left: &ast.Ident{ NamePos: 145, NameEnd: 153, @@ -241,7 +232,6 @@ WHERE }, }, Right: &ast.BetweenExpr{ - Not: false, Left: &ast.Ident{ NamePos: 203, NameEnd: 211, @@ -312,7 +302,6 @@ WHERE }, Right: &ast.IsNullExpr{ Null: 329, - Not: false, Left: &ast.NullLiteral{ Null: 321, }, @@ -328,7 +317,6 @@ WHERE }, Right: &ast.IsBoolExpr{ RightPos: 379, - Not: false, Left: &ast.ParenExpr{ Lparen: 361, Rparen: 374, @@ -376,7 +364,6 @@ WHERE }, Right: &ast.IsBoolExpr{ RightPos: 439, - Not: false, Left: &ast.ParenExpr{ Lparen: 421, Rparen: 434, @@ -395,7 +382,6 @@ WHERE }, }, }, - Right: false, }, }, Right: &ast.IsBoolExpr{ @@ -419,14 +405,9 @@ WHERE }, }, }, - Right: false, }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_singer_with_where_and_op.sql.txt b/testdata/result/statement/select_singer_with_where_and_op.sql.txt index e1fa8b0c..4cdc338c 100644 --- a/testdata/result/statement/select_singer_with_where_and_op.sql.txt +++ b/testdata/result/statement/select_singer_with_where_and_op.sql.txt @@ -8,13 +8,8 @@ WHERE --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -27,9 +22,6 @@ WHERE NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -81,10 +73,6 @@ WHERE }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_star.sql.txt b/testdata/result/statement/select_star.sql.txt new file mode 100644 index 00000000..82324266 --- /dev/null +++ b/testdata/result/statement/select_star.sql.txt @@ -0,0 +1,57 @@ +--- select_star.sql +SELECT * FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, + }, + }, + From: &ast.From{ + From: 9, + Source: &ast.SubQueryTableExpr{ + Lparen: 14, + Rparen: 61, + Query: &ast.Select{ + Select: 15, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 22, + ValueEnd: 29, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 30, + Alias: &ast.Ident{ + NamePos: 33, + NameEnd: 38, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 40, + ValueEnd: 48, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 49, + Alias: &ast.Ident{ + NamePos: 52, + NameEnd: 61, + Name: "vegetable", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT * FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) diff --git a/testdata/result/statement/select_star_except.sql.txt b/testdata/result/statement/select_star_except.sql.txt new file mode 100644 index 00000000..2dc6e9c0 --- /dev/null +++ b/testdata/result/statement/select_star_except.sql.txt @@ -0,0 +1,68 @@ +--- select_star_except.sql +SELECT * EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, + Except: &ast.StarModifierExcept{ + Except: 9, + Rparen: 26, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 17, + NameEnd: 26, + Name: "vegetable", + }, + }, + }, + }, + }, + From: &ast.From{ + From: 28, + Source: &ast.SubQueryTableExpr{ + Lparen: 33, + Rparen: 80, + Query: &ast.Select{ + Select: 34, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 41, + ValueEnd: 48, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 49, + Alias: &ast.Ident{ + NamePos: 52, + NameEnd: 57, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 59, + ValueEnd: 67, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 68, + Alias: &ast.Ident{ + NamePos: 71, + NameEnd: 80, + Name: "vegetable", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT * EXCEPT (vegetable) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) diff --git a/testdata/result/statement/select_star_except_replace.sql.txt b/testdata/result/statement/select_star_except_replace.sql.txt new file mode 100644 index 00000000..f128def5 --- /dev/null +++ b/testdata/result/statement/select_star_except_replace.sql.txt @@ -0,0 +1,86 @@ +--- select_star_except_replace.sql +SELECT * EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, + Except: &ast.StarModifierExcept{ + Except: 9, + Rparen: 26, + Columns: []*ast.Ident{ + &ast.Ident{ + NamePos: 17, + NameEnd: 26, + Name: "vegetable", + }, + }, + }, + Replace: &ast.StarModifierReplace{ + Replace: 28, + Rparen: 54, + Columns: []*ast.StarModifierReplaceItem{ + &ast.StarModifierReplaceItem{ + Expr: &ast.StringLiteral{ + ValuePos: 37, + ValueEnd: 45, + Value: "orange", + }, + Name: &ast.Ident{ + NamePos: 49, + NameEnd: 54, + Name: "fruit", + }, + }, + }, + }, + }, + }, + From: &ast.From{ + From: 56, + Source: &ast.SubQueryTableExpr{ + Lparen: 61, + Rparen: 108, + Query: &ast.Select{ + Select: 62, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 69, + ValueEnd: 76, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 77, + Alias: &ast.Ident{ + NamePos: 80, + NameEnd: 85, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 87, + ValueEnd: 95, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 96, + Alias: &ast.Ident{ + NamePos: 99, + NameEnd: 108, + Name: "vegetable", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT * EXCEPT (vegetable) REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) diff --git a/testdata/result/statement/select_star_replace.sql.txt b/testdata/result/statement/select_star_replace.sql.txt new file mode 100644 index 00000000..b5b297af --- /dev/null +++ b/testdata/result/statement/select_star_replace.sql.txt @@ -0,0 +1,75 @@ +--- select_star_replace.sql +SELECT * REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Results: []ast.SelectItem{ + &ast.Star{ + Star: 7, + Replace: &ast.StarModifierReplace{ + Replace: 9, + Rparen: 35, + Columns: []*ast.StarModifierReplaceItem{ + &ast.StarModifierReplaceItem{ + Expr: &ast.StringLiteral{ + ValuePos: 18, + ValueEnd: 26, + Value: "orange", + }, + Name: &ast.Ident{ + NamePos: 30, + NameEnd: 35, + Name: "fruit", + }, + }, + }, + }, + }, + }, + From: &ast.From{ + From: 37, + Source: &ast.SubQueryTableExpr{ + Lparen: 42, + Rparen: 89, + Query: &ast.Select{ + Select: 43, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 50, + ValueEnd: 57, + Value: "apple", + }, + As: &ast.AsAlias{ + As: 58, + Alias: &ast.Ident{ + NamePos: 61, + NameEnd: 66, + Name: "fruit", + }, + }, + }, + &ast.Alias{ + Expr: &ast.StringLiteral{ + ValuePos: 68, + ValueEnd: 76, + Value: "carrot", + }, + As: &ast.AsAlias{ + As: 77, + Alias: &ast.Ident{ + NamePos: 80, + NameEnd: 89, + Name: "vegetable", + }, + }, + }, + }, + }, + }, + }, + }, +} + +--- SQL +SELECT * REPLACE ("orange" AS fruit) FROM (SELECT "apple" AS fruit, "carrot" AS vegetable) diff --git a/testdata/result/statement/select_struct_compare_eq.sql.txt b/testdata/result/statement/select_struct_compare_eq.sql.txt index ff3acbd9..2ad47609 100644 --- a/testdata/result/statement/select_struct_compare_eq.sql.txt +++ b/testdata/result/statement/select_struct_compare_eq.sql.txt @@ -9,22 +9,15 @@ SELECT ARRAY( --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.ArraySubQuery{ Array: 7, Rparen: 133, Query: &ast.Select{ - Select: 16, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 16, + Results: []ast.SelectItem{ &ast.Star{ Star: 27, }, @@ -35,10 +28,8 @@ SELECT ARRAY( Lparen: 40, Rparen: 90, Query: &ast.Select{ - Select: 41, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 41, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.TypedStructLiteral{ Struct: 48, @@ -101,12 +92,6 @@ SELECT ARRAY( }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, As: &ast.AsAlias{ As: 92, @@ -116,7 +101,6 @@ SELECT ARRAY( Name: "S", }, }, - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -168,20 +152,10 @@ SELECT ARRAY( }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_subscript_operators.sql.txt b/testdata/result/statement/select_subscript_operators.sql.txt index 64776a1d..0ee39c7b 100644 --- a/testdata/result/statement/select_subscript_operators.sql.txt +++ b/testdata/result/statement/select_subscript_operators.sql.txt @@ -15,13 +15,8 @@ select --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IndexExpr{ Rbrack: 30, @@ -29,7 +24,6 @@ select Array: -1, Lbrack: 11, Rbrack: 19, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 12, @@ -71,7 +65,6 @@ select Array: -1, Lbrack: 37, Rbrack: 45, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 38, @@ -113,7 +106,6 @@ select Array: -1, Lbrack: 64, Rbrack: 72, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 65, @@ -155,7 +147,6 @@ select Array: -1, Lbrack: 95, Rbrack: 103, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 96, @@ -197,7 +188,6 @@ select Array: -1, Lbrack: 122, Rbrack: 130, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 123, @@ -498,12 +488,6 @@ select }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_tablesample_with_cross_join.sql.txt b/testdata/result/statement/select_tablesample_with_cross_join.sql.txt index b1e29e4a..f89a73f5 100644 --- a/testdata/result/statement/select_tablesample_with_cross_join.sql.txt +++ b/testdata/result/statement/select_tablesample_with_cross_join.sql.txt @@ -9,13 +9,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -23,17 +18,14 @@ FROM From: &ast.From{ From: 11, Source: &ast.Join{ - Op: "CROSS JOIN", - Method: "", - Hint: (*ast.Hint)(nil), - Left: &ast.TableName{ + Op: "CROSS JOIN", + Left: &ast.TableName{ Table: &ast.Ident{ NamePos: 18, NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 26, @@ -41,7 +33,6 @@ FROM Name: "A", }, }, - Sample: (*ast.TableSample)(nil), }, Right: &ast.TableName{ Table: &ast.Ident{ @@ -49,8 +40,7 @@ FROM NameEnd: 50, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 51, @@ -74,14 +64,8 @@ FROM }, }, }, - Cond: nil, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_tablesample_with_subquery.sql.txt b/testdata/result/statement/select_tablesample_with_subquery.sql.txt index 07aadcab..2eca5398 100644 --- a/testdata/result/statement/select_tablesample_with_subquery.sql.txt +++ b/testdata/result/statement/select_tablesample_with_subquery.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -23,10 +18,8 @@ FROM Lparen: 18, Rparen: 40, Query: &ast.Select{ - Select: 19, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 19, + Results: []ast.SelectItem{ &ast.Star{ Star: 26, }, @@ -39,18 +32,9 @@ FROM NameEnd: 40, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - As: (*ast.AsAlias)(nil), Sample: &ast.TableSample{ TableSample: 42, Method: "BERNOULLI", @@ -68,11 +52,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_tablesample_with_table.sql.txt b/testdata/result/statement/select_tablesample_with_table.sql.txt index b6d80bc3..105c0b18 100644 --- a/testdata/result/statement/select_tablesample_with_table.sql.txt +++ b/testdata/result/statement/select_tablesample_with_table.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,8 +20,6 @@ FROM NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), Sample: &ast.TableSample{ TableSample: 26, Method: "BERNOULLI", @@ -44,11 +37,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_tablesample_with_table_alias.sql.txt b/testdata/result/statement/select_tablesample_with_table_alias.sql.txt index 102ff2ed..06e78886 100644 --- a/testdata/result/statement/select_tablesample_with_table_alias.sql.txt +++ b/testdata/result/statement/select_tablesample_with_table_alias.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,8 +20,7 @@ FROM NameEnd: 25, Name: "Singers", }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 26, Alias: &ast.Ident{ NamePos: 29, @@ -51,11 +45,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_tablesample_with_unnest_invalid.sql.txt b/testdata/result/statement/select_tablesample_with_unnest_invalid.sql.txt index 44d34a87..13ac59cf 100644 --- a/testdata/result/statement/select_tablesample_with_unnest_invalid.sql.txt +++ b/testdata/result/statement/select_tablesample_with_unnest_invalid.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -91,10 +86,7 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: &ast.TableSample{ + Sample: &ast.TableSample{ TableSample: 83, Method: "BERNOULLI", Size: &ast.TableSampleSize{ @@ -111,11 +103,6 @@ FROM }, }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_union_chain.sql.txt b/testdata/result/statement/select_union_chain.sql.txt index a26ec131..056c6bed 100644 --- a/testdata/result/statement/select_union_chain.sql.txt +++ b/testdata/result/statement/select_union_chain.sql.txt @@ -3,20 +3,15 @@ --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.CompoundQuery{ - Op: "UNION", - Distinct: false, - Queries: []ast.QueryExpr{ + Op: "UNION", + AllOrDistinct: "ALL", + Queries: []ast.QueryExpr{ &ast.SubQuery{ - Lparen: 0, Rparen: 9, Query: &ast.Select{ - Select: 1, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 1, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 8, @@ -26,24 +21,14 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 21, Rparen: 30, Query: &ast.Select{ - Select: 22, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 22, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 29, @@ -53,24 +38,14 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, &ast.SubQuery{ Lparen: 42, Rparen: 51, Query: &ast.Select{ - Select: 43, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 43, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 50, @@ -80,19 +55,9 @@ }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_unnest_with_offset.sql.txt b/testdata/result/statement/select_unnest_with_offset.sql.txt index 776191c4..11f707a2 100644 --- a/testdata/result/statement/select_unnest_with_offset.sql.txt +++ b/testdata/result/statement/select_unnest_with_offset.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -26,7 +21,6 @@ FROM Array: -1, Lbrack: 25, Rbrack: 31, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 26, @@ -67,20 +61,12 @@ FROM }, }, }, - As: (*ast.AsAlias)(nil), WithOffset: &ast.WithOffset{ With: 46, Offset: 51, - As: (*ast.AsAlias)(nil), }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_unnest_with_offset_and_alias.sql.txt b/testdata/result/statement/select_unnest_with_offset_and_alias.sql.txt index 3b88c15d..ab2f4a32 100644 --- a/testdata/result/statement/select_unnest_with_offset_and_alias.sql.txt +++ b/testdata/result/statement/select_unnest_with_offset_and_alias.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -26,7 +21,6 @@ FROM Array: -1, Lbrack: 25, Rbrack: 31, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 26, @@ -48,8 +42,7 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 34, Alias: &ast.Ident{ NamePos: 37, @@ -69,14 +62,8 @@ FROM }, }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_unnest_with_offset_and_alias_min.sql.txt b/testdata/result/statement/select_unnest_with_offset_and_alias_min.sql.txt index 684b1116..010a9a8a 100644 --- a/testdata/result/statement/select_unnest_with_offset_and_alias_min.sql.txt +++ b/testdata/result/statement/select_unnest_with_offset_and_alias_min.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -26,7 +21,6 @@ FROM Array: -1, Lbrack: 25, Rbrack: 31, - Type: nil, Values: []ast.Expr{ &ast.IntLiteral{ ValuePos: 26, @@ -48,8 +42,7 @@ FROM }, }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: -1, Alias: &ast.Ident{ NamePos: 34, @@ -69,14 +62,8 @@ FROM }, }, }, - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_with.sql.txt b/testdata/result/statement/select_with.sql.txt new file mode 100644 index 00000000..58348b5b --- /dev/null +++ b/testdata/result/statement/select_with.sql.txt @@ -0,0 +1,112 @@ +--- select_with.sql +-- https://cloud.google.com/spanner/docs/reference/standard-sql/operators#with_expression +SELECT WITH(a AS '123', -- a is '123' + b AS CONCAT(a, '456'), -- b is '123456' + c AS '789', -- c is '789' + CONCAT(b, c)) AS result -- b + c is '123456789' +--- AST +&ast.QueryStatement{ + Query: &ast.Select{ + Select: 90, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.WithExpr{ + With: 97, + Rparen: 241, + Vars: []*ast.WithExprVar{ + &ast.WithExprVar{ + Name: &ast.Ident{ + NamePos: 102, + NameEnd: 103, + Name: "a", + }, + Expr: &ast.StringLiteral{ + ValuePos: 107, + ValueEnd: 112, + Value: "123", + }, + }, + &ast.WithExprVar{ + Name: &ast.Ident{ + NamePos: 138, + NameEnd: 139, + Name: "b", + }, + Expr: &ast.CallExpr{ + Rparen: 158, + Func: &ast.Ident{ + NamePos: 143, + NameEnd: 149, + Name: "CONCAT", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.Ident{ + NamePos: 150, + NameEnd: 151, + Name: "a", + }, + }, + &ast.ExprArg{ + Expr: &ast.StringLiteral{ + ValuePos: 153, + ValueEnd: 158, + Value: "456", + }, + }, + }, + }, + }, + &ast.WithExprVar{ + Name: &ast.Ident{ + NamePos: 185, + NameEnd: 186, + Name: "c", + }, + Expr: &ast.StringLiteral{ + ValuePos: 190, + ValueEnd: 195, + Value: "789", + }, + }, + }, + Expr: &ast.CallExpr{ + Rparen: 240, + Func: &ast.Ident{ + NamePos: 229, + NameEnd: 235, + Name: "CONCAT", + }, + Args: []ast.Arg{ + &ast.ExprArg{ + Expr: &ast.Ident{ + NamePos: 236, + NameEnd: 237, + Name: "b", + }, + }, + &ast.ExprArg{ + Expr: &ast.Ident{ + NamePos: 239, + NameEnd: 240, + Name: "c", + }, + }, + }, + }, + }, + As: &ast.AsAlias{ + As: 243, + Alias: &ast.Ident{ + NamePos: 246, + NameEnd: 252, + Name: "result", + }, + }, + }, + }, + }, +} + +--- SQL +SELECT WITH(a AS "123", b AS CONCAT(a, "456"), c AS "789", CONCAT(b, c)) AS result diff --git a/testdata/result/statement/select_with_after_hint.sql.txt b/testdata/result/statement/select_with_after_hint.sql.txt index fbc3c178..5a759851 100644 --- a/testdata/result/statement/select_with_after_hint.sql.txt +++ b/testdata/result/statement/select_with_after_hint.sql.txt @@ -4,7 +4,6 @@ --- AST &ast.QueryStatement{ Hint: &ast.Hint{ - Atmark: 0, Rbrace: 11, Records: []*ast.HintRecord{ &ast.HintRecord{ @@ -22,78 +21,60 @@ }, }, }, - With: &ast.With{ - With: 13, - CTEs: []*ast.CTE{ - &ast.CTE{ - Rparen: 46, - Name: &ast.Ident{ - NamePos: 18, - NameEnd: 23, - Name: "subq1", - }, - QueryExpr: &ast.Select{ - Select: 28, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 35, - NameEnd: 37, - Name: "c1", + Query: &ast.Query{ + With: &ast.With{ + With: 13, + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 46, + Name: &ast.Ident{ + NamePos: 18, + NameEnd: 23, + Name: "subq1", + }, + QueryExpr: &ast.Select{ + Select: 28, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 35, + NameEnd: 37, + Name: "c1", + }, }, }, - }, - From: &ast.From{ - From: 38, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 43, - NameEnd: 46, - Name: "foo", + From: &ast.From{ + From: 38, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 43, + NameEnd: 46, + Name: "foo", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, - }, - Query: &ast.Select{ - Select: 48, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 55, + Query: &ast.Select{ + Select: 48, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 55, + }, }, - }, - From: &ast.From{ - From: 57, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 62, - NameEnd: 67, - Name: "subq1", + From: &ast.From{ + From: 57, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 62, + NameEnd: 67, + Name: "subq1", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_with_comment.sql.txt b/testdata/result/statement/select_with_comment.sql.txt index a19849c0..369a1a18 100644 --- a/testdata/result/statement/select_with_comment.sql.txt +++ b/testdata/result/statement/select_with_comment.sql.txt @@ -4,13 +4,9 @@ select 1 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 10, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Select: 10, + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 17, @@ -20,12 +16,6 @@ select 1 }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_with_field_path.sql.txt b/testdata/result/statement/select_with_field_path.sql.txt index fb07732a..67bd84c5 100644 --- a/testdata/result/statement/select_with_field_path.sql.txt +++ b/testdata/result/statement/select_with_field_path.sql.txt @@ -19,13 +19,8 @@ WHERE A.z.a = 2 --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.Path{ Idents: []*ast.Ident{ @@ -110,9 +105,8 @@ WHERE A.z.a = 2 Array: 57, Rparen: 251, Query: &ast.Select{ - Select: 70, - Distinct: false, - As: &ast.AsStruct{ + Select: 70, + As: &ast.AsStruct{ As: 77, Struct: 80, }, @@ -284,21 +278,11 @@ WHERE A.z.a = 2 }, }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, - Hint: (*ast.Hint)(nil), - As: &ast.AsAlias{ + As: &ast.AsAlias{ As: 257, Alias: &ast.Ident{ NamePos: 260, @@ -306,8 +290,6 @@ WHERE A.z.a = 2 Name: "A", }, }, - WithOffset: (*ast.WithOffset)(nil), - Sample: (*ast.TableSample)(nil), }, }, Where: &ast.Where{ @@ -341,10 +323,6 @@ WHERE A.z.a = 2 }, }, }, - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_with_multiple_ctes.sql.txt b/testdata/result/statement/select_with_multiple_ctes.sql.txt index f5221e7f..08eb3a79 100644 --- a/testdata/result/statement/select_with_multiple_ctes.sql.txt +++ b/testdata/result/statement/select_with_multiple_ctes.sql.txt @@ -3,119 +3,89 @@ with subq1 as (select c1 from foo), subq2 as (select c2 from foo) select * from --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: &ast.With{ - With: 0, - CTEs: []*ast.CTE{ - &ast.CTE{ - Rparen: 33, - Name: &ast.Ident{ - NamePos: 5, - NameEnd: 10, - Name: "subq1", - }, - QueryExpr: &ast.Select{ - Select: 15, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 22, - NameEnd: 24, - Name: "c1", + Query: &ast.Query{ + With: &ast.With{ + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 33, + Name: &ast.Ident{ + NamePos: 5, + NameEnd: 10, + Name: "subq1", + }, + QueryExpr: &ast.Select{ + Select: 15, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 22, + NameEnd: 24, + Name: "c1", + }, }, }, - }, - From: &ast.From{ - From: 25, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 30, - NameEnd: 33, - Name: "foo", + From: &ast.From{ + From: 25, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 30, + NameEnd: 33, + Name: "foo", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, - }, - &ast.CTE{ - Rparen: 64, - Name: &ast.Ident{ - NamePos: 36, - NameEnd: 41, - Name: "subq2", - }, - QueryExpr: &ast.Select{ - Select: 46, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.ExprSelectItem{ - Expr: &ast.Ident{ - NamePos: 53, - NameEnd: 55, - Name: "c2", + &ast.CTE{ + Rparen: 64, + Name: &ast.Ident{ + NamePos: 36, + NameEnd: 41, + Name: "subq2", + }, + QueryExpr: &ast.Select{ + Select: 46, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Ident{ + NamePos: 53, + NameEnd: 55, + Name: "c2", + }, }, }, - }, - From: &ast.From{ - From: 56, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 61, - NameEnd: 64, - Name: "foo", + From: &ast.From{ + From: 56, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 61, + NameEnd: 64, + Name: "foo", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, }, }, - }, - Query: &ast.Select{ - Select: 66, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ - &ast.Star{ - Star: 73, + Query: &ast.Select{ + Select: 66, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 73, + }, }, - }, - From: &ast.From{ - From: 75, - Source: &ast.TableName{ - Table: &ast.Ident{ - NamePos: 80, - NameEnd: 85, - Name: "subq1", + From: &ast.From{ + From: 75, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 80, + NameEnd: 85, + Name: "subq1", + }, }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_with_reservedword.sql.txt b/testdata/result/statement/select_with_reservedword.sql.txt index f310b6f0..f6a0e091 100644 --- a/testdata/result/statement/select_with_reservedword.sql.txt +++ b/testdata/result/statement/select_with_reservedword.sql.txt @@ -6,13 +6,8 @@ FROM --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Star{ Star: 9, }, @@ -25,16 +20,8 @@ FROM NameEnd: 26, Name: "UNNEST", }, - Hint: (*ast.Hint)(nil), - As: (*ast.AsAlias)(nil), - Sample: (*ast.TableSample)(nil), }, }, - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_with_sequence_function.sql.txt b/testdata/result/statement/select_with_sequence_function.sql.txt index 333ec82a..c5a07b7a 100644 --- a/testdata/result/statement/select_with_sequence_function.sql.txt +++ b/testdata/result/statement/select_with_sequence_function.sql.txt @@ -3,13 +3,8 @@ SELECT GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence) as next_id --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.Alias{ Expr: &ast.CallExpr{ Rparen: 51, @@ -18,8 +13,7 @@ SELECT GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence) as next_id NameEnd: 30, Name: "GET_NEXT_SEQUENCE_VALUE", }, - Distinct: false, - Args: []ast.Arg{ + Args: []ast.Arg{ &ast.SequenceArg{ Sequence: 31, Expr: &ast.Ident{ @@ -29,9 +23,6 @@ SELECT GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence) as next_id }, }, }, - NamedArgs: []*ast.NamedArg(nil), - NullHandling: nil, - Having: nil, }, As: &ast.AsAlias{ As: 53, @@ -43,12 +34,6 @@ SELECT GET_NEXT_SEQUENCE_VALUE(SEQUENCE my_sequence) as next_id }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/select_with_trailing_comma.sql.txt b/testdata/result/statement/select_with_trailing_comma.sql.txt index 8aba7288..835ed9e3 100644 --- a/testdata/result/statement/select_with_trailing_comma.sql.txt +++ b/testdata/result/statement/select_with_trailing_comma.sql.txt @@ -2,13 +2,8 @@ SELECT 1, 2, --- AST &ast.QueryStatement{ - Hint: (*ast.Hint)(nil), - With: (*ast.With)(nil), Query: &ast.Select{ - Select: 0, - Distinct: false, - As: nil, - Results: []ast.SelectItem{ + Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.IntLiteral{ ValuePos: 7, @@ -26,12 +21,6 @@ SELECT 1, 2, }, }, }, - From: (*ast.From)(nil), - Where: (*ast.Where)(nil), - GroupBy: (*ast.GroupBy)(nil), - Having: (*ast.Having)(nil), - OrderBy: (*ast.OrderBy)(nil), - Limit: (*ast.Limit)(nil), }, } diff --git a/testdata/result/statement/update.sql.txt b/testdata/result/statement/update.sql.txt index fcf32946..e9e63cb1 100644 --- a/testdata/result/statement/update.sql.txt +++ b/testdata/result/statement/update.sql.txt @@ -2,13 +2,11 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 --- AST &ast.Update{ - Update: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", }, - As: (*ast.AsAlias)(nil), Updates: []*ast.UpdateItem{ &ast.UpdateItem{ Path: []*ast.Ident{ @@ -20,7 +18,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.Ident{ NamePos: 21, NameEnd: 24, @@ -38,7 +35,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.Ident{ NamePos: 32, NameEnd: 35, @@ -57,7 +53,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 DefaultExpr: &ast.DefaultExpr{ DefaultPos: 43, Default: true, - Expr: nil, }, }, }, @@ -78,7 +73,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/update_as.sql.txt b/testdata/result/statement/update_as.sql.txt index 00622578..002e9210 100644 --- a/testdata/result/statement/update_as.sql.txt +++ b/testdata/result/statement/update_as.sql.txt @@ -2,7 +2,6 @@ update foo as F set F.foo = F.bar + 1 where foo = F.bar --- AST &ast.Update{ - Update: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, @@ -32,7 +31,6 @@ update foo as F set F.foo = F.bar + 1 where foo = F.bar }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.BinaryExpr{ Op: "+", Left: &ast.Path{ @@ -84,7 +82,6 @@ update foo as F set F.foo = F.bar + 1 where foo = F.bar }, }, }, - ThenReturn: (*ast.ThenReturn)(nil), } --- SQL diff --git a/testdata/result/statement/update_then_return_with_action.sql.txt b/testdata/result/statement/update_then_return_with_action.sql.txt index 438a476f..bfaba0eb 100644 --- a/testdata/result/statement/update_then_return_with_action.sql.txt +++ b/testdata/result/statement/update_then_return_with_action.sql.txt @@ -2,13 +2,11 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return with action * --- AST &ast.Update{ - Update: 0, TableName: &ast.Ident{ NamePos: 7, NameEnd: 10, Name: "foo", }, - As: (*ast.AsAlias)(nil), Updates: []*ast.UpdateItem{ &ast.UpdateItem{ Path: []*ast.Ident{ @@ -20,7 +18,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return wit }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.Ident{ NamePos: 21, NameEnd: 24, @@ -38,7 +35,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return wit }, DefaultExpr: &ast.DefaultExpr{ DefaultPos: -1, - Default: false, Expr: &ast.Ident{ NamePos: 32, NameEnd: 35, @@ -57,7 +53,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return wit DefaultExpr: &ast.DefaultExpr{ DefaultPos: 43, Default: true, - Expr: nil, }, }, }, @@ -83,7 +78,6 @@ update foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1 then return wit WithAction: &ast.WithAction{ With: 77, Action: 82, - Alias: (*ast.AsAlias)(nil), }, Items: []ast.SelectItem{ &ast.Star{ diff --git a/testdata/result/statement/update_with_safe_ml_predict.sql.txt b/testdata/result/statement/update_with_safe_ml_predict.sql.txt new file mode 100644 index 00000000..423cf296 --- /dev/null +++ b/testdata/result/statement/update_with_safe_ml_predict.sql.txt @@ -0,0 +1,205 @@ +--- update_with_safe_ml_predict.sql +-- https://cloud.google.com/spanner/docs/backfill-embeddings?hl=en#backfill +UPDATE products +SET + products.desc_embed = ( + SELECT embeddings.values + FROM SAFE.ML.PREDICT( + MODEL gecko_model, + (SELECT products.description AS content) + ) @{remote_udf_max_rows_per_rpc=200} + ), + products.desc_embed_model_version = 3 +WHERE products.desc_embed IS NULL +--- AST +&ast.Update{ + Update: 76, + TableName: &ast.Ident{ + NamePos: 83, + NameEnd: 91, + Name: "products", + }, + Updates: []*ast.UpdateItem{ + &ast.UpdateItem{ + Path: []*ast.Ident{ + &ast.Ident{ + NamePos: 100, + NameEnd: 108, + Name: "products", + }, + &ast.Ident{ + NamePos: 109, + NameEnd: 119, + Name: "desc_embed", + }, + }, + DefaultExpr: &ast.DefaultExpr{ + DefaultPos: -1, + Expr: &ast.ScalarSubQuery{ + Lparen: 122, + Rparen: 333, + Query: &ast.Select{ + Select: 132, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 139, + NameEnd: 149, + Name: "embeddings", + }, + &ast.Ident{ + NamePos: 150, + NameEnd: 156, + Name: "values", + }, + }, + }, + }, + }, + From: &ast.From{ + From: 165, + Source: &ast.TVFCallExpr{ + Rparen: 292, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 170, + NameEnd: 174, + Name: "SAFE", + }, + &ast.Ident{ + NamePos: 175, + NameEnd: 177, + Name: "ML", + }, + &ast.Ident{ + NamePos: 178, + NameEnd: 185, + Name: "PREDICT", + }, + }, + }, + Args: []ast.TVFArg{ + &ast.ModelArg{ + Model: 203, + Name: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 209, + NameEnd: 220, + Name: "gecko_model", + }, + }, + }, + }, + &ast.ExprArg{ + Expr: &ast.ScalarSubQuery{ + Lparen: 238, + Rparen: 277, + Query: &ast.Select{ + Select: 239, + Results: []ast.SelectItem{ + &ast.Alias{ + Expr: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 246, + NameEnd: 254, + Name: "products", + }, + &ast.Ident{ + NamePos: 255, + NameEnd: 266, + Name: "description", + }, + }, + }, + As: &ast.AsAlias{ + As: 267, + Alias: &ast.Ident{ + NamePos: 270, + NameEnd: 277, + Name: "content", + }, + }, + }, + }, + }, + }, + }, + }, + Hint: &ast.Hint{ + Atmark: 294, + Rbrace: 327, + Records: []*ast.HintRecord{ + &ast.HintRecord{ + Key: &ast.Ident{ + NamePos: 296, + NameEnd: 323, + Name: "remote_udf_max_rows_per_rpc", + }, + Value: &ast.IntLiteral{ + ValuePos: 324, + ValueEnd: 327, + Base: 10, + Value: "200", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + &ast.UpdateItem{ + Path: []*ast.Ident{ + &ast.Ident{ + NamePos: 340, + NameEnd: 348, + Name: "products", + }, + &ast.Ident{ + NamePos: 349, + NameEnd: 373, + Name: "desc_embed_model_version", + }, + }, + DefaultExpr: &ast.DefaultExpr{ + DefaultPos: -1, + Expr: &ast.IntLiteral{ + ValuePos: 376, + ValueEnd: 377, + Base: 10, + Value: "3", + }, + }, + }, + }, + Where: &ast.Where{ + Where: 378, + Expr: &ast.IsNullExpr{ + Null: 407, + Left: &ast.Path{ + Idents: []*ast.Ident{ + &ast.Ident{ + NamePos: 384, + NameEnd: 392, + Name: "products", + }, + &ast.Ident{ + NamePos: 393, + NameEnd: 403, + Name: "desc_embed", + }, + }, + }, + }, + }, +} + +--- SQL +UPDATE products SET products.desc_embed = (SELECT embeddings.values FROM SAFE.ML.PREDICT(MODEL gecko_model, (SELECT products.description AS content)) @{remote_udf_max_rows_per_rpc=200}), products.desc_embed_model_version = 3 WHERE products.desc_embed IS NULL diff --git a/testdata/result/statement/with_paren_query_limit.sql.txt b/testdata/result/statement/with_paren_query_limit.sql.txt new file mode 100644 index 00000000..3be484bd --- /dev/null +++ b/testdata/result/statement/with_paren_query_limit.sql.txt @@ -0,0 +1,66 @@ +--- with_paren_query_limit.sql +WITH cte AS (SELECT 1) (SELECT * FROM cte) LIMIT 1 +--- AST +&ast.QueryStatement{ + Query: &ast.Query{ + With: &ast.With{ + CTEs: []*ast.CTE{ + &ast.CTE{ + Rparen: 21, + Name: &ast.Ident{ + NamePos: 5, + NameEnd: 8, + Name: "cte", + }, + QueryExpr: &ast.Select{ + Select: 13, + Results: []ast.SelectItem{ + &ast.ExprSelectItem{ + Expr: &ast.IntLiteral{ + ValuePos: 20, + ValueEnd: 21, + Base: 10, + Value: "1", + }, + }, + }, + }, + }, + }, + }, + Query: &ast.SubQuery{ + Lparen: 23, + Rparen: 41, + Query: &ast.Select{ + Select: 24, + Results: []ast.SelectItem{ + &ast.Star{ + Star: 31, + }, + }, + From: &ast.From{ + From: 33, + Source: &ast.TableName{ + Table: &ast.Ident{ + NamePos: 38, + NameEnd: 41, + Name: "cte", + }, + }, + }, + }, + }, + Limit: &ast.Limit{ + Limit: 43, + Count: &ast.IntLiteral{ + ValuePos: 49, + ValueEnd: 50, + Base: 10, + Value: "1", + }, + }, + }, +} + +--- SQL +WITH cte AS (SELECT 1) (SELECT * FROM cte) LIMIT 1