ast

package
v0.0.0-...-f02fa7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2024 License: MIT Imports: 1 Imported by: 6

Documentation

Overview

Package ast provides AST nodes definitions.

The definitions of ASTs are based on the following document.

Each `Node`'s documentation describes its syntax (SQL representation) in a `text/template` fashion with thw following custom functions.

  • `sql node`: Returns the SQL representation of `node`.
  • `sqlOpt node`: Like `sql node`, but returns the empty string if `node` is `nil`.
  • `sqlJoin sep nodes`: Concatenates the SQL representations of `nodes` with `sep`.
  • `sqlIdentQuote x`: Quotes the given identifier string if needed.
  • `sqlStringQuote s`: Returns the SQL quoted string of `s`.
  • `sqlBytesQuote bs`: Returns the SQL quotes bytes of `bs`.
  • `isnil v`: Checks whether `v` is `nil` or others.

Each `Node`s documentation has `pos` and `end` information using the following EBNF.

PosChoice -> PosExpr ("||" PosExpr)*
PosExpr   -> PosAtom ("+" IntAtom)?
PosAtom   -> PosVar | NodeExpr "." ("pos" | "end")
NodeExpr  -> NodeAtom | "(" NodeAtom ("??" NodeAtom)* ")"
NodeAtom  -> NodeVar | NodeSliceVar "[" (IntAtom | "$") "]"
IntAtom   -> IntVal
           | "len" "(" StringVar ")"
           | "(" BoolVar "?" IntAtom ":" IntAtom ")"
IntVal    -> "0" | "1" | ...

(PosVar, NodeVar, NodeSliceVar, and BoolVar are derived by its `struct` definition.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddColumn

type AddColumn struct {
	Add token.Pos // position of "ADD" keyword

	IfNotExists bool
	Column      *ColumnDef
}

AddColumn is ADD COLUMN clause in ALTER TABLE.

ADD COLUMN {{if .IfNotExists}}IF NOT EXISTS{{end}} {{.Column | sql}}

func (*AddColumn) End

func (a *AddColumn) End() token.Pos

func (*AddColumn) Pos

func (a *AddColumn) Pos() token.Pos

func (*AddColumn) SQL

func (a *AddColumn) SQL() string

type AddRowDeletionPolicy

type AddRowDeletionPolicy struct {
	Add token.Pos // position of "ADD" keyword

	RowDeletionPolicy *RowDeletionPolicy
}

AddRowDeletionPolicy is ADD ROW DELETION POLICY clause in ALTER TABLE.

ADD {{.RowDeletionPolicy | sql}}

func (*AddRowDeletionPolicy) End

func (a *AddRowDeletionPolicy) End() token.Pos

func (*AddRowDeletionPolicy) Pos

func (a *AddRowDeletionPolicy) Pos() token.Pos

func (*AddRowDeletionPolicy) SQL

func (a *AddRowDeletionPolicy) SQL() string

type AddStoredColumn

type AddStoredColumn struct {
	Add token.Pos // position of "ADD" keyword

	Name *Ident
}

AddStoredColumn is ADD STORED COLUMN clause in ALTER INDEX.

ADD STORED COLUMN {{.Name | sql}}

func (*AddStoredColumn) End

func (a *AddStoredColumn) End() token.Pos

func (*AddStoredColumn) Pos

func (a *AddStoredColumn) Pos() token.Pos

func (*AddStoredColumn) SQL

func (a *AddStoredColumn) SQL() string

type AddTableConstraint

type AddTableConstraint struct {
	Add token.Pos // position of "ADD" keyword

	TableConstraint *TableConstraint
}

AddTableConstraint is ADD table_constraint clause in ALTER TABLE.

ADD {{.TableConstraint}}

func (*AddTableConstraint) End

func (a *AddTableConstraint) End() token.Pos

func (*AddTableConstraint) Pos

func (a *AddTableConstraint) Pos() token.Pos

func (*AddTableConstraint) SQL

func (a *AddTableConstraint) SQL() string

type Alias

type Alias struct {
	Expr Expr
	As   *AsAlias
}

Alias is aliased expression by AS clause in SELECT result columns list.

{{.Expr | sql}} {{.As | sql}}

func (*Alias) End

func (a *Alias) End() token.Pos

func (*Alias) Pos

func (a *Alias) Pos() token.Pos

func (*Alias) SQL

func (a *Alias) SQL() string

type AlterChangeStream

type AlterChangeStream struct {
	Alter token.Pos // position of "ALTER" keyword

	Name                   *Ident
	ChangeStreamAlteration ChangeStreamAlteration
}

AlterChangeStream is ALTER CHANGE STREAM statement node.

ALTER CHANGE STREAM {{.Name | sql}} {{.ChangeStreamAlteration | sql}}

func (*AlterChangeStream) End

func (a *AlterChangeStream) End() token.Pos

func (*AlterChangeStream) Pos

func (a *AlterChangeStream) Pos() token.Pos

func (*AlterChangeStream) SQL

func (a *AlterChangeStream) SQL() string

type AlterColumn

type AlterColumn struct {
	// pos = Alter
	// end = DefaultExpr.end || Null + 4 || Type.end
	Alter token.Pos // position of "ALTER" keyword
	Null  token.Pos // position of "NULL"

	Name        *Ident
	Type        SchemaType
	NotNull     bool
	DefaultExpr *ColumnDefaultExpr
}

AlterColumn is ALTER COLUMN clause in ALTER TABLE.

ALTER COLUMN {{.Name | sql}} {{.Type | sql}} {{if .NotNull}}NOT NULL{{end}} {{.DefaultExpr | sqlOpt}}

func (*AlterColumn) End

func (a *AlterColumn) End() token.Pos

func (*AlterColumn) Pos

func (a *AlterColumn) Pos() token.Pos

func (*AlterColumn) SQL

func (a *AlterColumn) SQL() string

type AlterColumnSet

type AlterColumnSet struct {
	Alter token.Pos // position of "ALTER" keyword

	Name        *Ident
	Options     *ColumnDefOptions
	DefaultExpr *ColumnDefaultExpr
}

AlterColumnSet is ALTER COLUMN SET clause in ALTER TABLE.

ALTER COLUMN {{.Name | sql}} SET {{if .Options}}{{.Options | sql}}{{else}}{{.DefaultExpr | sql}}{{end}}

func (*AlterColumnSet) End

func (a *AlterColumnSet) End() token.Pos

func (*AlterColumnSet) Pos

func (a *AlterColumnSet) Pos() token.Pos

func (*AlterColumnSet) SQL

func (a *AlterColumnSet) SQL() string

type AlterIndex

type AlterIndex struct {
	Alter token.Pos // position of "ALTER" keyword

	Name            *Ident
	IndexAlteration IndexAlteration
}

AlterIndex is ALTER INDEX statement node.

ALTER INDEX {{.Name | sql}} {{.IndexAlteration | sql}}

func (*AlterIndex) End

func (a *AlterIndex) End() token.Pos

func (*AlterIndex) Pos

func (a *AlterIndex) Pos() token.Pos

func (*AlterIndex) SQL

func (a *AlterIndex) SQL() string

type AlterTable

type AlterTable struct {
	Alter token.Pos // position of "ALTER" keyword

	Name            *Ident
	TableAlteration TableAlteration
}

AlterTable is ALTER TABLE statement node.

ALTER TABLE {{.Name | sql}} {{.TableAlteration | sql}}

func (*AlterTable) End

func (a *AlterTable) End() token.Pos

func (*AlterTable) Pos

func (a *AlterTable) Pos() token.Pos

func (*AlterTable) SQL

func (a *AlterTable) SQL() string

type Arg

type Arg interface {
	Node
	// contains filtered or unexported methods
}

Arg represents argument of function call.

type ArrayLiteral

type ArrayLiteral struct {
	Array          token.Pos // position of "ARRAY" keyword
	Lbrack, Rbrack token.Pos // position of "[" and "]"

	Type   Type // optional
	Values []Expr
}

AraryLiteral is array literal node.

ARRAY{{if .Type}}<{{.Type | sql}}>{{end}}[{{.Values | sqlJoin ","}}]

func (*ArrayLiteral) End

func (a *ArrayLiteral) End() token.Pos

func (*ArrayLiteral) Pos

func (a *ArrayLiteral) Pos() token.Pos

func (*ArrayLiteral) SQL

func (a *ArrayLiteral) SQL() string

type ArraySchemaType

type ArraySchemaType struct {
	Array token.Pos // position of "ARRAY" keyword
	Gt    token.Pos // position of ">"

	Item SchemaType // ScalarSchemaType or SizedSchemaType
}

ArraySchemaType is array type node in schema.

ARRAY<{{.Item | sql}}>

func (*ArraySchemaType) End

func (a *ArraySchemaType) End() token.Pos

func (*ArraySchemaType) Pos

func (a *ArraySchemaType) Pos() token.Pos

func (*ArraySchemaType) SQL

func (a *ArraySchemaType) SQL() string

type ArraySubQuery

type ArraySubQuery struct {
	Array  token.Pos // position of "ARRAY" keyword
	Rparen token.Pos // position of ")"

	Query QueryExpr
}

ArraySubQuery is subquery in ARRAY call.

ARRAY({{.Query | sql}})

func (*ArraySubQuery) End

func (a *ArraySubQuery) End() token.Pos

func (*ArraySubQuery) Pos

func (a *ArraySubQuery) Pos() token.Pos

func (*ArraySubQuery) SQL

func (a *ArraySubQuery) SQL() string

type ArrayType

type ArrayType struct {
	Array token.Pos // position of "ARRAY" keyword
	Gt    token.Pos // position of ">"

	Item Type
}

ArrayType is array type node.

ARRAY<{{.Item | sql}}>

func (*ArrayType) End

func (a *ArrayType) End() token.Pos

func (*ArrayType) Pos

func (a *ArrayType) Pos() token.Pos

func (*ArrayType) SQL

func (a *ArrayType) SQL() string

type AsAlias

type AsAlias struct {
	As token.Pos // position of "AS" keyword

	Alias *Ident
}

AsAlias is AS clause node for general purpose.

It is used in Alias node and some JoinExpr nodes.

NOTE: Sometime keyword AS can be omited.

  In this case, it.token.Pos() == it.Alias.token.Pos(), so we can detect this.

AS {{.Alias | sql}}

func (*AsAlias) End

func (a *AsAlias) End() token.Pos

func (*AsAlias) Pos

func (a *AsAlias) Pos() token.Pos

func (*AsAlias) SQL

func (a *AsAlias) SQL() string

type AtTimeZone

type AtTimeZone struct {
	At token.Pos // position of "AT" keyword

	Expr Expr
}

AtTimeZone is AT TIME ZONE clause in EXTRACT call.

AT TIME ZONE {{.Expr | sql}}

func (*AtTimeZone) End

func (a *AtTimeZone) End() token.Pos

func (*AtTimeZone) Pos

func (a *AtTimeZone) Pos() token.Pos

func (*AtTimeZone) SQL

func (a *AtTimeZone) SQL() string

type BetweenExpr

type BetweenExpr struct {
	Not                        bool
	Left, RightStart, RightEnd Expr
}

BetweenExpr is BETWEEN expression node.

{{.Left | sql}} {{if .Not}}NOT{{end}} BETWEEN {{.RightStart | sql}} AND {{.RightEnd | sql}}

func (*BetweenExpr) End

func (b *BetweenExpr) End() token.Pos

func (*BetweenExpr) Pos

func (b *BetweenExpr) Pos() token.Pos

func (*BetweenExpr) SQL

func (b *BetweenExpr) SQL() string

type BinaryExpr

type BinaryExpr struct {
	Op BinaryOp

	Left, Right Expr
}

BinaryExpr is binary operator expression node.

{{.Left | sql}} {{.Op}} {{.Right | sql}}

func (*BinaryExpr) End

func (b *BinaryExpr) End() token.Pos

func (*BinaryExpr) Pos

func (b *BinaryExpr) Pos() token.Pos

func (*BinaryExpr) SQL

func (b *BinaryExpr) SQL() string

type BinaryOp

type BinaryOp string
const (
	OpOr            BinaryOp = "OR"
	OpAnd           BinaryOp = "AND"
	OpEqual         BinaryOp = "="
	OpNotEqual      BinaryOp = "!="
	OpLess          BinaryOp = "<"
	OpGreater       BinaryOp = ">"
	OpLessEqual     BinaryOp = "<="
	OpGreaterEqual  BinaryOp = ">="
	OpLike          BinaryOp = "LIKE"
	OpNotLike       BinaryOp = "NOT LIKE"
	OpBitOr         BinaryOp = "|"
	OpBitXor        BinaryOp = "^"
	OpBitAnd        BinaryOp = "&"
	OpBitLeftShift  BinaryOp = "<<"
	OpBitRightShift BinaryOp = ">>"
	OpAdd           BinaryOp = "+"
	OpSub           BinaryOp = "-"
	OpMul           BinaryOp = "*"
	OpDiv           BinaryOp = "/"
	OpConcat        BinaryOp = "||"
)

type BoolLiteral

type BoolLiteral struct {
	ValuePos token.Pos // position of this value

	Value bool
}

BoolLiteral is boolean literal node.

{{if .Value}}TRUE{{else}}FALSE{{end}}

func (*BoolLiteral) End

func (b *BoolLiteral) End() token.Pos

func (*BoolLiteral) Pos

func (b *BoolLiteral) Pos() token.Pos

func (*BoolLiteral) SQL

func (b *BoolLiteral) SQL() string

type BytesLiteral

type BytesLiteral struct {
	ValuePos, ValueEnd token.Pos // position of this value

	Value []byte
}

BytesLiteral is bytes literal node.

B{{.Value | sqlBytesQuote}}

func (*BytesLiteral) End

func (b *BytesLiteral) End() token.Pos

func (*BytesLiteral) Pos

func (b *BytesLiteral) Pos() token.Pos

func (*BytesLiteral) SQL

func (b *BytesLiteral) SQL() string

type CTE

type CTE struct {
	Rparen token.Pos // position of ")"

	Name      *Ident
	QueryExpr QueryExpr
}

CTE is common table expression node.

{{.Name}} AS ({{.QueryExpr}})

func (*CTE) End

func (c *CTE) End() token.Pos

func (*CTE) Pos

func (c *CTE) Pos() token.Pos

func (*CTE) SQL

func (c *CTE) SQL() string

type CallExpr

type CallExpr struct {
	Rparen token.Pos // position of ")"

	Func     *Ident
	Distinct bool
	Args     []Arg
}

CallExpr is function call expression node.

{{.Func | sql}}({{if .Distinct}}DISTINCT{{end}} {{.Args | sql}})

func (*CallExpr) End

func (c *CallExpr) End() token.Pos

func (*CallExpr) Pos

func (c *CallExpr) Pos() token.Pos

func (*CallExpr) SQL

func (c *CallExpr) SQL() string

type CaseElse

type CaseElse struct {
	Else token.Pos // position of "ELSE" keyword

	Expr Expr
}

CaseElse is ELSE clause in CASE expression.

ELSE {{.Expr | sql}}

func (*CaseElse) End

func (c *CaseElse) End() token.Pos

func (*CaseElse) Pos

func (c *CaseElse) Pos() token.Pos

func (*CaseElse) SQL

func (c *CaseElse) SQL() string

type CaseExpr

type CaseExpr struct {
	Case, EndPos token.Pos // position of "CASE" and "END" keywords

	Expr  Expr        // optional
	Whens []*CaseWhen // len(Whens) > 0
	Else  *CaseElse   // optional
}

CaseExpr is CASE expression node.

CASE {{.Expr | sqlOpt}}
  {{.Whens | sqlJoin "\n"}}
  {{.Else | sqlOpt}}
END

func (*CaseExpr) End

func (c *CaseExpr) End() token.Pos

func (*CaseExpr) Pos

func (c *CaseExpr) Pos() token.Pos

func (*CaseExpr) SQL

func (c *CaseExpr) SQL() string

type CaseWhen

type CaseWhen struct {
	When token.Pos // position of "WHEN" keyword

	Cond, Then Expr
}

CaseWhen is WHEN clause in CASE expression.

WHEN {{.Cond | sql}} THEN {{.Then | sql}}

func (*CaseWhen) End

func (c *CaseWhen) End() token.Pos

func (*CaseWhen) Pos

func (c *CaseWhen) Pos() token.Pos

func (*CaseWhen) SQL

func (c *CaseWhen) SQL() string

type CastExpr

type CastExpr struct {
	Cast   token.Pos // position of "CAST" keyword
	Rparen token.Pos // position of ")"

	Expr Expr
	Type Type
}

CastExpr is CAST call expression node.

CAST({{.Expr | sql}} AS {{.Type | sql}})

func (*CastExpr) End

func (c *CastExpr) End() token.Pos

func (*CastExpr) Pos

func (c *CastExpr) Pos() token.Pos

func (*CastExpr) SQL

func (c *CastExpr) SQL() string

type CastIntValue

type CastIntValue struct {
	Cast   token.Pos // position of "CAST" keyword
	Rparen token.Pos // position of ")"

	Expr IntValue // IntLit or Param
}

CastIntValue is cast call in integer value context.

CAST({{.Expr | sql}} AS INT64)

func (*CastIntValue) End

func (c *CastIntValue) End() token.Pos

func (*CastIntValue) Pos

func (c *CastIntValue) Pos() token.Pos

func (*CastIntValue) SQL

func (c *CastIntValue) SQL() string

type CastNumValue

type CastNumValue struct {
	Cast   token.Pos // position of "CAST" keyword
	Rparen token.Pos // position of ")"

	Expr NumValue       // IntLit, FloatLit or Param
	Type ScalarTypeName // Int64Type or Float64Type
}

CasrNumValue is cast call in number value context.

CAST({{.Expr | sql}} AS {{.Type}})

func (*CastNumValue) End

func (c *CastNumValue) End() token.Pos

func (*CastNumValue) Pos

func (c *CastNumValue) Pos() token.Pos

func (*CastNumValue) SQL

func (c *CastNumValue) SQL() string

type ChangeStreamAlteration

type ChangeStreamAlteration interface {
	Node
	// contains filtered or unexported methods
}

ChangeStreamAlteration represents ALTER CHANGE STREAM action.

type ChangeStreamDropForAll

type ChangeStreamDropForAll struct {
	Drop token.Pos // position of "DROP" keyword
	All  token.Pos // position of "ALL" keyword
}

ChangeStreamDropForAll is DROP FOR ALL node in ALTER CHANGE STREAM

DROP FOR ALL

func (*ChangeStreamDropForAll) End

func (a *ChangeStreamDropForAll) End() token.Pos

func (*ChangeStreamDropForAll) Pos

func (a *ChangeStreamDropForAll) Pos() token.Pos

func (ChangeStreamDropForAll) SQL

type ChangeStreamFor

type ChangeStreamFor interface {
	Node
	// contains filtered or unexported methods
}

ChangeStreamFor represents FOR clause in CREATE/ALTER CHANGE STREAM statement.

type ChangeStreamForAll

type ChangeStreamForAll struct {
	For token.Pos // position of "FOR" keyword
	All token.Pos // position of "ALL" keyword
}

ChangeStreamForAll is FOR ALL node in CREATE CHANGE STREAM

FOR ALL

func (*ChangeStreamForAll) End

func (c *ChangeStreamForAll) End() token.Pos

func (*ChangeStreamForAll) Pos

func (c *ChangeStreamForAll) Pos() token.Pos

func (*ChangeStreamForAll) SQL

func (c *ChangeStreamForAll) SQL() string

type ChangeStreamForTable

type ChangeStreamForTable struct {
	Rparen token.Pos // position of ")"

	TableName *Ident
	Columns   []*Ident
}

ChangeStreamForTable table node in CREATE CHANGE STREAM SET FOR

{{.TableName | sql}}{{if .Columns}}({{.Columns | sqlJoin ","}}){{end}}

func (*ChangeStreamForTable) End

func (c *ChangeStreamForTable) End() token.Pos

func (*ChangeStreamForTable) SQL

func (c *ChangeStreamForTable) SQL() string

type ChangeStreamForTables

type ChangeStreamForTables struct {
	For token.Pos // position of "FOR" keyword

	Tables []*ChangeStreamForTable
}

ChangeStreamForTables is FOR tables node in CREATE CHANGE STREAM

FOR {{.Tables | sqlJoin ","}}

func (*ChangeStreamForTables) End

func (c *ChangeStreamForTables) End() token.Pos

func (*ChangeStreamForTables) Pos

func (c *ChangeStreamForTables) Pos() token.Pos

func (*ChangeStreamForTables) SQL

func (c *ChangeStreamForTables) SQL() string

type ChangeStreamOptions

type ChangeStreamOptions struct {
	Options token.Pos // position of "OPTIONS" keyword
	Rparen  token.Pos // position of ")"

	Records []*ChangeStreamOptionsRecord // len(Records) > 0
}

ChangeStreamOptions is OPTIONS clause node in CREATE CHANGE STREAM.

OPTIONS ({{.Records | sqlJoin ","}})

func (*ChangeStreamOptions) End

func (c *ChangeStreamOptions) End() token.Pos

func (*ChangeStreamOptions) Pos

func (c *ChangeStreamOptions) Pos() token.Pos

func (*ChangeStreamOptions) SQL

func (c *ChangeStreamOptions) SQL() string

type ChangeStreamOptionsRecord

type ChangeStreamOptionsRecord struct {
	Key   *Ident
	Value Expr
}

ChangeStreamOptionsRecord is OPTIONS record node.

{{.Key | sql}}={{.Expr | sql}}

type ChangeStreamSetFor

type ChangeStreamSetFor struct {
	Set token.Pos // position of "SET" keyword

	For ChangeStreamFor
}

ChangeStreamSetFor is SET FOR tables node in ALTER CHANGE STREAM

SET FOR {{.For | sql}}

func (*ChangeStreamSetFor) End

func (a *ChangeStreamSetFor) End() token.Pos

func (*ChangeStreamSetFor) Pos

func (a *ChangeStreamSetFor) Pos() token.Pos

func (ChangeStreamSetFor) SQL

func (a ChangeStreamSetFor) SQL() string

type ChangeStreamSetOptions

type ChangeStreamSetOptions struct {
	Set token.Pos // position of "SET" keyword

	Options *ChangeStreamOptions
}

ChangeStreamSetOptions is SET OPTIONS node in ALTER CHANGE STREAM

SET {{.Options | sql}}

func (*ChangeStreamSetOptions) End

func (a *ChangeStreamSetOptions) End() token.Pos

func (*ChangeStreamSetOptions) Pos

func (a *ChangeStreamSetOptions) Pos() token.Pos

func (ChangeStreamSetOptions) SQL

type Check

type Check struct {
	Check  token.Pos // position of "CHECK" keyword
	Rparen token.Pos // position of ")" after Expr

	Expr Expr
}

Check is check constraint in CREATE TABLE and ALTER TABLE.

Check ({{.Expr}})

func (*Check) End

func (c *Check) End() token.Pos

func (*Check) Pos

func (c *Check) Pos() token.Pos

func (*Check) SQL

func (c *Check) SQL() string

type Cluster

type Cluster struct {
	Comma       token.Pos // position of ","
	OnDeleteEnd token.Pos // end position of ON DELETE clause

	TableName *Ident
	OnDelete  OnDeleteAction // optional
}

Cluster is INTERLEAVE IN PARENT clause in CREATE TABLE.

, INTERLEAVE IN PARENT {{.TableName | sql}} {{.OnDelete}}

func (*Cluster) End

func (c *Cluster) End() token.Pos

func (*Cluster) Pos

func (c *Cluster) Pos() token.Pos

func (*Cluster) SQL

func (c *Cluster) SQL() string

type Collate

type Collate struct {
	Collate token.Pos // position of "COLLATE" keyword

	Value StringValue
}

Collate is COLLATE clause node in ORDER BY item.

COLLATE {{.Value | sql}}

func (*Collate) End

func (c *Collate) End() token.Pos

func (*Collate) Pos

func (c *Collate) Pos() token.Pos

func (*Collate) SQL

func (c *Collate) SQL() string

type ColumnDef

type ColumnDef struct {
	Null token.Pos // position of "NULL"

	Name          *Ident
	Type          SchemaType
	NotNull       bool
	DefaultExpr   *ColumnDefaultExpr   // optional
	GeneratedExpr *GeneratedColumnExpr // optional
	Options       *ColumnDefOptions    // optional
}

ColumnDef is column definition in CREATE TABLE.

{{.Name | sql}}
{{.Type | sql}} {{if .NotNull}}NOT NULL{{end}}
{{.DefaultExpr | sqlOpt}}
{{.GeneratedExpr | sqlOpt}}
{{.Options | sqlOpt}}

func (*ColumnDef) End

func (c *ColumnDef) End() token.Pos

func (*ColumnDef) Pos

func (c *ColumnDef) Pos() token.Pos

func (*ColumnDef) SQL

func (c *ColumnDef) SQL() string

type ColumnDefOptions

type ColumnDefOptions struct {
	Options token.Pos // position of "OPTIONS" keyword
	Rparen  token.Pos // position of ")"

	AllowCommitTimestamp bool
}

ColumnDefOption is options for column definition.

OPTIONS(allow_commit_timestamp = {{if .AllowCommitTimestamp}}true{{else}null{{end}}})

func (*ColumnDefOptions) End

func (c *ColumnDefOptions) End() token.Pos

func (*ColumnDefOptions) Pos

func (c *ColumnDefOptions) Pos() token.Pos

func (*ColumnDefOptions) SQL

func (c *ColumnDefOptions) SQL() string

type ColumnDefaultExpr

type ColumnDefaultExpr struct {
	Default token.Pos // position of "DEFAULT" keyword
	Rparen  token.Pos // position of ")"

	Expr Expr
}

ColumnDefaultExpr is a default value expression for the column.

DEFAULT ({{.Expr | sql}})

func (*ColumnDefaultExpr) End

func (g *ColumnDefaultExpr) End() token.Pos

func (*ColumnDefaultExpr) Pos

func (g *ColumnDefaultExpr) Pos() token.Pos

func (*ColumnDefaultExpr) SQL

func (c *ColumnDefaultExpr) SQL() string

type CompoundQuery

type CompoundQuery struct {
	Op       SetOp
	Distinct bool
	Queries  []QueryExpr // len(List) >= 2
	OrderBy  *OrderBy    // optional
	Limit    *Limit      // optional
}

CompoundQuery is query statement node compounded by set operators.

{{.Queries | sqlJoin (printf "%s %s" .Op or(and(.Distinct, "DISTINCT"), "ALL"))}}
  {{.OrderBy | sqlOpt}}
  {{.Limit | sqlOpt}}

func (*CompoundQuery) End

func (c *CompoundQuery) End() token.Pos

func (*CompoundQuery) Pos

func (c *CompoundQuery) Pos() token.Pos

func (*CompoundQuery) SQL

func (c *CompoundQuery) SQL() string

type Constraint

type Constraint interface {
	Node
	// contains filtered or unexported methods
}

Constraint represents table constraint of CONSTARINT clause.

type CountStarExpr

type CountStarExpr struct {
	Count  token.Pos // position of "COUNT"
	Rparen token.Pos // position of ")"
}

CountStarExpr is node just for COUNT(*).

COUNT(*)

func (*CountStarExpr) End

func (c *CountStarExpr) End() token.Pos

func (*CountStarExpr) Pos

func (c *CountStarExpr) Pos() token.Pos

func (*CountStarExpr) SQL

func (*CountStarExpr) SQL() string

type CreateChangeStream

type CreateChangeStream struct {
	Create token.Pos // position of "CREATE" keyword

	Name    *Ident
	For     ChangeStreamFor      // optional
	Options *ChangeStreamOptions // optional
}

CreateChangeStream is CREATE CHANGE STREAM statement node.

CREATE CHANGE STREAM {{.Name | sql}} {{.For | sqlOpt}} {{.Options | sqlOpt}}

func (*CreateChangeStream) End

func (c *CreateChangeStream) End() token.Pos

func (*CreateChangeStream) Pos

func (c *CreateChangeStream) Pos() token.Pos

func (*CreateChangeStream) SQL

func (c *CreateChangeStream) SQL() string

type CreateDatabase

type CreateDatabase struct {
	Create token.Pos // position of "CREATE" keyword

	Name *Ident
}

CreateDatabase is CREATE DATABASE statement node.

CREATE DATABASE {{.Name | sql}}

func (*CreateDatabase) End

func (c *CreateDatabase) End() token.Pos

func (*CreateDatabase) Pos

func (c *CreateDatabase) Pos() token.Pos

func (*CreateDatabase) SQL

func (c *CreateDatabase) SQL() string

type CreateIndex

type CreateIndex struct {
	Create token.Pos // position of "CREATE" keyword
	Rparen token.Pos // position of ")"

	Unique       bool
	NullFiltered bool
	IfNotExists  bool
	Name         *Ident
	TableName    *Ident
	Keys         []*IndexKey
	Storing      *Storing      // optional
	InterleaveIn *InterleaveIn // optional
}

CreateIndex is CREATE INDEX statement node.

CREATE
  {{if .Unique}}UNIQUE{{end}}
  {{if .NullFiltered}}NULL_FILTERED{{end}}
INDEX {{if .IfExists}}IF NOT EXISTS{{end}} {{.Name | sql}} ON {{.TableName | sql}} (
  {{.Keys | sqlJoin ","}}
)
{{.Storing | sqlOpt}}
{{.InterleaveIn | sqlOpt}}

func (*CreateIndex) End

func (c *CreateIndex) End() token.Pos

func (*CreateIndex) Pos

func (c *CreateIndex) Pos() token.Pos

func (*CreateIndex) SQL

func (c *CreateIndex) SQL() string

type CreateRole

type CreateRole struct {
	Create token.Pos // position of "CREATE" keyword

	Name *Ident
}

CreateRole is CREATE ROLE statement node.

CREATE ROLE {{.Name | sql}}

func (*CreateRole) End

func (c *CreateRole) End() token.Pos

func (*CreateRole) Pos

func (c *CreateRole) Pos() token.Pos

func (*CreateRole) SQL

func (c *CreateRole) SQL() string

type CreateRowDeletionPolicy

type CreateRowDeletionPolicy struct {
	Comma token.Pos // position of ","

	RowDeletionPolicy *RowDeletionPolicy
}

CreateRowDeletionPolicy is ROW DELETION POLICY clause in CREATE TABLE.

, {{.RowDeletionPolicy}}

func (*CreateRowDeletionPolicy) End

func (*CreateRowDeletionPolicy) Pos

func (*CreateRowDeletionPolicy) SQL

type CreateSequence

type CreateSequence struct {
	Create token.Pos // position of "CREATE" keyword
	Rparen token.Pos // position of ")" of OPTIONS clause

	Name        *Ident
	IfNotExists bool
	Options     []*SequenceOption // len(Options) > 0
}

CreateSequence is CREATE SEQUENCE statement node.

CREATE SEQUENCE {{if .IfNotExists}}IF NOT EXISTS{{end}} {{.Name | sql}} }} OPTIONS ({{.Options | sqlJoin ","}})

func (*CreateSequence) End

func (c *CreateSequence) End() token.Pos

func (*CreateSequence) Pos

func (c *CreateSequence) Pos() token.Pos

func (*CreateSequence) SQL

func (c *CreateSequence) SQL() string

type CreateTable

type CreateTable struct {
	Create token.Pos // position of "CREATE" keyword
	Rparen token.Pos // position of ")" of PRIMARY KEY clause

	IfNotExists       bool
	Name              *Ident
	Columns           []*ColumnDef
	TableConstraints  []*TableConstraint
	PrimaryKeys       []*IndexKey
	Cluster           *Cluster                 // optional
	RowDeletionPolicy *CreateRowDeletionPolicy // optional
}

CreateTable is CREATE TABLE statement node.

CREATE TABLE {{if .IfNotExists}}IF NOT EXISTS{{end}} {{.Name | sql}} (
  {{.Columns | sqlJoin ","}}
  {{if and .Columns .TableConstrains}},{{end}}{{.TableConstraints | sqlJoin ","}}
)
PRIMARY KEY ({{.PrimaryKeys | sqlJoin ","}})
{{.Cluster | sqlOpt}}
{{.CreateRowDeletionPolicy | sqlOpt}}

Spanner SQL allows to mix `Columns` and `TableConstraints`, however they are separated in AST definition for historical reasons. If you want to get the original order of them, please sort them by their `Pos()`.

func (*CreateTable) End

func (c *CreateTable) End() token.Pos

func (*CreateTable) Pos

func (c *CreateTable) Pos() token.Pos

func (*CreateTable) SQL

func (c *CreateTable) SQL() string

type CreateView

type CreateView struct {
	Create token.Pos

	Name         *Ident
	OrReplace    bool
	SecurityType SecurityType
	Query        QueryExpr
}

CreateView is CREATE VIEW statement node.

CREATE {{if .OrReplace}}OR REPLACE{{end}} VIEW {{.Name | sql}}
SQL SECURITY {{.SecurityType}} AS
{{.Query | sql}}

func (*CreateView) End

func (c *CreateView) End() token.Pos

func (*CreateView) Pos

func (c *CreateView) Pos() token.Pos

func (*CreateView) SQL

func (c *CreateView) SQL() string

type DDL

type DDL interface {
	Statement
	// contains filtered or unexported methods
}

DDL represents data definition language in SQL.

https://cloud.google.com/spanner/docs/data-definition-language

type DML

type DML interface {
	Statement
	// contains filtered or unexported methods
}

DML represents data manipulation language in SQL.

https://cloud.google.com/spanner/docs/data-definition-language

type DateLiteral

type DateLiteral struct {
	Date token.Pos // position of "DATE"

	Value *StringLiteral
}

DateLiteral is date literal node.

DATE {{.Value | sql}}

func (*DateLiteral) End

func (d *DateLiteral) End() token.Pos

func (*DateLiteral) Pos

func (d *DateLiteral) Pos() token.Pos

func (*DateLiteral) SQL

func (d *DateLiteral) SQL() string

type DefaultExpr

type DefaultExpr struct {
	DefaultPos token.Pos // position of "DEFAULT"

	Default bool
	Expr    Expr
}

DefaultExpr is DEFAULT or Expr.

{{if .Default}}DEFAULT{{else}}{{.Expr | sql}}{{end}}

func (*DefaultExpr) End

func (d *DefaultExpr) End() token.Pos

func (*DefaultExpr) Pos

func (d *DefaultExpr) Pos() token.Pos

func (*DefaultExpr) SQL

func (d *DefaultExpr) SQL() string

type Delete

type Delete struct {
	Delete token.Pos // position of "DELETE" keyword

	TableName *Ident
	As        *AsAlias // optional
	Where     *Where
}

Delete is DELETE statement.

DELETE FROM {{.TableName | sql}} {{.As | sqlOpt}} {{.Where | sql}}

func (*Delete) End

func (d *Delete) End() token.Pos

func (*Delete) Pos

func (d *Delete) Pos() token.Pos

func (*Delete) SQL

func (d *Delete) SQL() string

type DeletePrivilege

type DeletePrivilege struct {
	Delete token.Pos // position of "DELETE" keyword
}

DeletePrivilege is DELETE ON TABLE privilege node in GRANT and REVOKE.

DELETE

func (*DeletePrivilege) End

func (d *DeletePrivilege) End() token.Pos

func (*DeletePrivilege) Pos

func (d *DeletePrivilege) Pos() token.Pos

func (*DeletePrivilege) SQL

func (d *DeletePrivilege) SQL() string

type Direction

type Direction string
const (
	DirectionAsc  Direction = "ASC"
	DirectionDesc Direction = "DESC"
)

type DotStar

type DotStar struct {
	Star token.Pos // position of "*"

	Expr Expr
}

DotStar is expression with * in SELECT result columns list.

{{.Expr | sql}}.*

func (*DotStar) End

func (s *DotStar) End() token.Pos

func (*DotStar) Pos

func (s *DotStar) Pos() token.Pos

func (*DotStar) SQL

func (s *DotStar) SQL() string

type DropChangeStream

type DropChangeStream struct {
	Drop token.Pos // position of "DROP" keyword

	Name *Ident
}

DropChangeStream is DROP CHANGE STREAM statement node.

DROP CHANGE STREAM {{.Name | sql}}

func (*DropChangeStream) End

func (d *DropChangeStream) End() token.Pos

func (*DropChangeStream) Pos

func (d *DropChangeStream) Pos() token.Pos

func (*DropChangeStream) SQL

func (d *DropChangeStream) SQL() string

type DropColumn

type DropColumn struct {
	Drop token.Pos // position of  "DROP" keyword

	Name *Ident
}

DropColumn is DROP COLUMN clause in ALTER TABLE.

DROP COLUMN {{.Name | sql}}

func (*DropColumn) End

func (d *DropColumn) End() token.Pos

func (*DropColumn) Pos

func (d *DropColumn) Pos() token.Pos

func (*DropColumn) SQL

func (d *DropColumn) SQL() string

type DropConstraint

type DropConstraint struct {
	Drop token.Pos // position of  "DROP" keyword

	Name *Ident
}

DropConstraint is DROP CONSTRAINT clause in ALTER TABLE.

DROP CONSTRAINT {{.Name | sql}}

func (*DropConstraint) End

func (d *DropConstraint) End() token.Pos

func (*DropConstraint) Pos

func (d *DropConstraint) Pos() token.Pos

func (*DropConstraint) SQL

func (d *DropConstraint) SQL() string

type DropIndex

type DropIndex struct {
	Drop token.Pos // position of "DROP" keyword

	IfExists bool
	Name     *Ident
}

DropIndex is DROP INDEX statement node.

DROP INDEX {{if .IfExists}}IF EXISTS{{end}} {{.Name | sql}}

func (*DropIndex) End

func (d *DropIndex) End() token.Pos

func (*DropIndex) Pos

func (d *DropIndex) Pos() token.Pos

func (*DropIndex) SQL

func (d *DropIndex) SQL() string

type DropRole

type DropRole struct {
	Drop token.Pos // position of "DROP" keyword

	Name *Ident
}

DropRole is DROP ROLE statement node.

DROP ROLE {{.Name | sql}}

func (*DropRole) End

func (d *DropRole) End() token.Pos

func (*DropRole) Pos

func (d *DropRole) Pos() token.Pos

func (*DropRole) SQL

func (d *DropRole) SQL() string

type DropRowDeletionPolicy

type DropRowDeletionPolicy struct {
	Drop   token.Pos // position of  "DROP" keyword
	Policy token.Pos // position of  "POLICY" keyword
}

DropRowDeletionPolicy is DROP ROW DELETION POLICY clause in ALTER TABLE.

DROP ROW DELETION POLICY

func (*DropRowDeletionPolicy) End

func (d *DropRowDeletionPolicy) End() token.Pos

func (*DropRowDeletionPolicy) Pos

func (d *DropRowDeletionPolicy) Pos() token.Pos

func (*DropRowDeletionPolicy) SQL

func (d *DropRowDeletionPolicy) SQL() string

type DropStoredColumn

type DropStoredColumn struct {
	Drop token.Pos // position of "DROP" keyword

	Name *Ident
}

DropStoredColumn is DROP STORED COLUMN clause in ALTER INDEX.

DROP STORED COLUMN {{.Name | sql}}

func (*DropStoredColumn) End

func (a *DropStoredColumn) End() token.Pos

func (*DropStoredColumn) Pos

func (a *DropStoredColumn) Pos() token.Pos

func (*DropStoredColumn) SQL

func (a *DropStoredColumn) SQL() string

type DropTable

type DropTable struct {
	Drop token.Pos // position of "DROP" keyword

	IfExists bool
	Name     *Ident
}

DropTable is DROP TABLE statement node.

DROP TABLE {{if .IfExists}}IF NOT EXISTS{{end}} {{.Name | sql}}

func (*DropTable) End

func (d *DropTable) End() token.Pos

func (*DropTable) Pos

func (d *DropTable) Pos() token.Pos

func (*DropTable) SQL

func (d *DropTable) SQL() string

type ExecutePrivilegeOnTableFunction

type ExecutePrivilegeOnTableFunction struct {
	Execute token.Pos

	Names []*Ident // len(Names) > 0
}

ExecutePrivilegeOnTableFunction is EXECUTE ON TABLE FUNCTION privilege node in GRANT and REVOKE.

EXECUTE ON TABLE FUNCTION {{.Names | sqlJoin ","}}

func (*ExecutePrivilegeOnTableFunction) End

func (*ExecutePrivilegeOnTableFunction) Pos

func (*ExecutePrivilegeOnTableFunction) SQL

type ExistsSubQuery

type ExistsSubQuery struct {
	Exists token.Pos // position of "EXISTS" keyword
	Rparen token.Pos // position of ")"

	Hint  *Hint
	Query QueryExpr
}

ExistsSubQuery is subquery in EXISTS call.

EXISTS {{.Hint | sqlOpt}} ({{.Query | sql}})

func (*ExistsSubQuery) End

func (e *ExistsSubQuery) End() token.Pos

func (*ExistsSubQuery) Pos

func (e *ExistsSubQuery) Pos() token.Pos

func (*ExistsSubQuery) SQL

func (e *ExistsSubQuery) SQL() string

type Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

Expr repersents an expression in SQL.

type ExprArg

type ExprArg struct {
	Expr Expr
}

ExprArg is argument of the generic function call.

{{.Expr | sql}}

func (*ExprArg) End

func (e *ExprArg) End() token.Pos

func (*ExprArg) Pos

func (e *ExprArg) Pos() token.Pos

func (*ExprArg) SQL

func (s *ExprArg) SQL() string

type ExprSelectItem

type ExprSelectItem struct {
	Expr Expr
}

ExprSelectItem is Expr wrapper for SelectItem.

{{.Expr | sql}}

func (*ExprSelectItem) End

func (e *ExprSelectItem) End() token.Pos

func (*ExprSelectItem) Pos

func (e *ExprSelectItem) Pos() token.Pos

func (*ExprSelectItem) SQL

func (e *ExprSelectItem) SQL() string

type ExtractExpr

type ExtractExpr struct {
	Extract token.Pos // position of "EXTRACT" keyword
	Rparen  token.Pos // position of ")"

	Part       *Ident
	Expr       Expr
	AtTimeZone *AtTimeZone // optional
}

ExtractExpr is EXTRACT call expression node.

EXTRACT({{.Part | sql}} FROM {{.Expr | sql}} {{.AtTimeZone | sqlOpt}})

func (*ExtractExpr) End

func (e *ExtractExpr) End() token.Pos

func (*ExtractExpr) Pos

func (e *ExtractExpr) Pos() token.Pos

func (*ExtractExpr) SQL

func (e *ExtractExpr) SQL() string

type FloatLiteral

type FloatLiteral struct {
	ValuePos, ValueEnd token.Pos // position of this value

	Value string
}

FloatLiteral is floating point number literal node.

{{.Value}}

func (*FloatLiteral) End

func (f *FloatLiteral) End() token.Pos

func (*FloatLiteral) Pos

func (f *FloatLiteral) Pos() token.Pos

func (*FloatLiteral) SQL

func (f *FloatLiteral) SQL() string

type ForeignKey

type ForeignKey struct {
	Foreign     token.Pos // position of "FOREIGN" keyword
	Rparen      token.Pos // position of ")" after reference columns
	OnDeleteEnd token.Pos // end position of ON DELETE clause

	Columns          []*Ident
	ReferenceTable   *Ident
	ReferenceColumns []*Ident       // len(ReferenceColumns) > 0
	OnDelete         OnDeleteAction // optional
}

ForeignKey is foreign key specifier in CREATE TABLE and ALTER TABLE.

FOREIGN KEY ({{.ColumnNames | sqlJoin ","}}) REFERENCES {{.ReferenceTable}} ({{.ReferenceColumns | sqlJoin ","}}) {{.OnDelete}}

func (*ForeignKey) End

func (f *ForeignKey) End() token.Pos

func (*ForeignKey) Pos

func (f *ForeignKey) Pos() token.Pos

func (*ForeignKey) SQL

func (f *ForeignKey) SQL() string

type From

type From struct {
	From token.Pos // position of "FROM" keyword

	Source TableExpr
}

From is FROM clause node.

FROM {{.Source | sql}}

func (*From) End

func (f *From) End() token.Pos

func (*From) Pos

func (f *From) Pos() token.Pos

func (*From) SQL

func (f *From) SQL() string

type GeneratedColumnExpr

type GeneratedColumnExpr struct {
	As     token.Pos // position of "AS" keyword
	Stored token.Pos // position of "STORED" keyword

	Expr Expr
}

GeneratedColumnExpr is generated column expression.

AS ({{.Expr | sql}}) STORED

func (*GeneratedColumnExpr) End

func (g *GeneratedColumnExpr) End() token.Pos

func (*GeneratedColumnExpr) Pos

func (g *GeneratedColumnExpr) Pos() token.Pos

func (*GeneratedColumnExpr) SQL

func (g *GeneratedColumnExpr) SQL() string

type Grant

type Grant struct {
	Grant token.Pos // position of "GRANT" keyword

	Privilege Privilege
	Roles     []*Ident
}

Grant is GRANT statement node.

GRANT {{.Privilege | sql}} TO ROLE {{.Roles | sqlJoin ","}}

func (*Grant) End

func (g *Grant) End() token.Pos

func (*Grant) Pos

func (g *Grant) Pos() token.Pos

func (*Grant) SQL

func (g *Grant) SQL() string

type GroupBy

type GroupBy struct {
	Group token.Pos // position of "GROUP" keyword

	Exprs []Expr // len(Exprs) > 0
}

GroupBy is GROUP BY clause node.

GROUP BY {{.Exprs | sqlJoin ","}}

func (*GroupBy) End

func (g *GroupBy) End() token.Pos

func (*GroupBy) Pos

func (g *GroupBy) Pos() token.Pos

func (*GroupBy) SQL

func (g *GroupBy) SQL() string

type Having

type Having struct {
	Having token.Pos // position of "HAVING" keyword

	Expr Expr
}

Having is HAVING clause node.

HAVING {{.Expr | sql}}

func (*Having) End

func (h *Having) End() token.Pos

func (*Having) Pos

func (h *Having) Pos() token.Pos

func (*Having) SQL

func (h *Having) SQL() string

type Hint

type Hint struct {
	Atmark token.Pos // position of "@"
	Rbrace token.Pos // position of "}"

	Records []*HintRecord // len(Records) > 0
}

Hint is hint node.

@{{"{"}}{{.Records | sqlJoin ","}}{{"}"}}

func (*Hint) End

func (h *Hint) End() token.Pos

func (*Hint) Pos

func (h *Hint) Pos() token.Pos

func (*Hint) SQL

func (h *Hint) SQL() string

type HintRecord

type HintRecord struct {
	Key   *Ident
	Value Expr
}

HintRecord is hint record node.

{{.Key | sql}}={{.Value | sql}}

func (*HintRecord) End

func (h *HintRecord) End() token.Pos

func (*HintRecord) Pos

func (h *HintRecord) Pos() token.Pos

func (*HintRecord) SQL

func (h *HintRecord) SQL() string

type Ident

type Ident struct {
	NamePos, NameEnd token.Pos // position of this name

	Name string
}

Ident is identifier node.

{{.Name | sqlIdentQuote}}

func (*Ident) End

func (i *Ident) End() token.Pos

func (*Ident) Pos

func (i *Ident) Pos() token.Pos

func (*Ident) SQL

func (i *Ident) SQL() string

type InCondition

type InCondition interface {
	Node
	// contains filtered or unexported methods
}

InCondition is right-side value of IN operator.

type InExpr

type InExpr struct {
	Not   bool
	Left  Expr
	Right InCondition
}

InExpr is IN expression node.

{{.Left | sql}} {{if .Not}}NOT{{end}} IN {{.Right | sql}}

func (*InExpr) End

func (i *InExpr) End() token.Pos

func (*InExpr) Pos

func (i *InExpr) Pos() token.Pos

func (*InExpr) SQL

func (i *InExpr) SQL() string

type IndexAlteration

type IndexAlteration interface {
	Node
	// contains filtered or unexported methods
}

IndexAlteration represents ALTER INDEX action.

type IndexExpr

type IndexExpr struct {
	Rbrack token.Pos // position of "]"

	Ordinal     bool
	Expr, Index Expr
}

IndexExpr is array item access expression node.

{{.Expr | sql}}[{{if .Ordinal}}ORDINAL{{else}}OFFSET{{end}}({{.Index | sql}})]

func (*IndexExpr) End

func (i *IndexExpr) End() token.Pos

func (*IndexExpr) Pos

func (i *IndexExpr) Pos() token.Pos

func (*IndexExpr) SQL

func (i *IndexExpr) SQL() string

type IndexKey

type IndexKey struct {
	DirPos token.Pos // position of Dir

	Name *Ident
	Dir  Direction // optional
}

IndexKey is index key specifier in CREATE TABLE and CREATE INDEX.

{{.Name | sql}} {{.Dir}}

func (*IndexKey) End

func (i *IndexKey) End() token.Pos

func (*IndexKey) Pos

func (i *IndexKey) Pos() token.Pos

func (*IndexKey) SQL

func (i *IndexKey) SQL() string

type Insert

type Insert struct {
	Insert token.Pos // position of "INSERT" keyword

	InsertOrType InsertOrType

	TableName *Ident
	Columns   []*Ident
	Input     InsertInput
}

Insert is INSERT statement node.

INSERT {{if .InsertOrType}}OR .InsertOrType{{end}}INTO {{.TableName | sql}} ({{.Columns | sqlJoin ","}}) {{.Input | sql}}

func (*Insert) End

func (i *Insert) End() token.Pos

func (*Insert) Pos

func (i *Insert) Pos() token.Pos

func (*Insert) SQL

func (i *Insert) SQL() string

type InsertInput

type InsertInput interface {
	Node
	// contains filtered or unexported methods
}

InsertInput represents input values of INSERT statement.

type InsertOrType

type InsertOrType string
const (
	InsertOrTypeUpdate InsertOrType = "UPDATE"
	InsertOrTypeIgnore InsertOrType = "IGNORE"
)

type InsertPrivilege

type InsertPrivilege struct {
	Insert token.Pos // position of "INSERT" keyword
	Rparen token.Pos // position of ")" when len(Columns) > 0

	Columns []*Ident
}

InsertPrivilege is INSERT ON TABLE privilege node in GRANT and REVOKE.

INSERT{{if .Columns}}({{.Columns | sqlJoin ","}}){{end}}

func (*InsertPrivilege) End

func (i *InsertPrivilege) End() token.Pos

func (*InsertPrivilege) Pos

func (i *InsertPrivilege) Pos() token.Pos

func (*InsertPrivilege) SQL

func (i *InsertPrivilege) SQL() string

type IntLiteral

type IntLiteral struct {
	ValuePos, ValueEnd token.Pos // position of this value

	Base  int // 10 or 16
	Value string
}

IntLiteral is integer literal node.

{{.Value}}

func (*IntLiteral) End

func (i *IntLiteral) End() token.Pos

func (*IntLiteral) Pos

func (i *IntLiteral) Pos() token.Pos

func (*IntLiteral) SQL

func (i *IntLiteral) SQL() string

type IntValue

type IntValue interface {
	Node
	// contains filtered or unexported methods
}

IntValue represents integer values in SQL.

type InterleaveIn

type InterleaveIn struct {
	Comma token.Pos // position of ","

	TableName *Ident
}

InterleaveIn is INTERLEAVE IN clause in CREATE INDEX.

, INTERLEAVE IN {{.TableName | sql}}

func (*InterleaveIn) End

func (i *InterleaveIn) End() token.Pos

func (*InterleaveIn) Pos

func (i *InterleaveIn) Pos() token.Pos

func (*InterleaveIn) SQL

func (i *InterleaveIn) SQL() string

type IntervalArg

type IntervalArg struct {
	Interval token.Pos // position of "INTERVAL" keyword

	Expr Expr
	Unit *Ident // optional
}

IntervalArg is argument of date function call.

INTERVAL {{.Expr | sql}} {{.Unit | sqlOpt}}

func (*IntervalArg) End

func (i *IntervalArg) End() token.Pos

func (*IntervalArg) Pos

func (i *IntervalArg) Pos() token.Pos

func (*IntervalArg) SQL

func (i *IntervalArg) SQL() string

type IsBoolExpr

type IsBoolExpr struct {
	RightPos token.Pos // position of Right

	Not   bool
	Left  Expr
	Right bool
}

IsBoolExpr is IS TRUE/FALSE expression node.

{{.Left | sql}} IS {{if .Not}}NOT{{end}} {{if .Right}}TRUE{{else}}FALSE{{end}}

func (*IsBoolExpr) End

func (i *IsBoolExpr) End() token.Pos

func (*IsBoolExpr) Pos

func (i *IsBoolExpr) Pos() token.Pos

func (*IsBoolExpr) SQL

func (i *IsBoolExpr) SQL() string

type IsNullExpr

type IsNullExpr struct {
	Null token.Pos // position of "NULL"

	Not  bool
	Left Expr
}

IsNullExpr is IS NULL expression node.

{{.Left | sql}} IS {{if .Not}}NOT{{end}} NULL

func (*IsNullExpr) End

func (i *IsNullExpr) End() token.Pos

func (*IsNullExpr) Pos

func (i *IsNullExpr) Pos() token.Pos

func (*IsNullExpr) SQL

func (i *IsNullExpr) SQL() string

type Join

type Join struct {
	Op          JoinOp
	Method      JoinMethod
	Hint        *Hint // optional
	Left, Right TableExpr
	Cond        JoinCondition // nil when Op is CrossJoin, otherwise it must be set.
}

Join is JOIN expression.

{{.Left | sql}}
  {{.Op}} {{.Method}} {{.Hint | sqlOpt}}
  {{.Right | sql}}
{{.Cond | sqlOpt}}

func (*Join) End

func (j *Join) End() token.Pos

func (*Join) Pos

func (j *Join) Pos() token.Pos

func (*Join) SQL

func (j *Join) SQL() string

type JoinCondition

type JoinCondition interface {
	Node
	// contains filtered or unexported methods
}

JoinCondition represents condition part of JOIN expression.

type JoinHintKey

type JoinHintKey string
const (
	ForceJoinOrderJoinHint JoinHintKey = "FORCE_JOIN_ORDER"
	JoinTypeJoinHint       JoinHintKey = "JOIN_TYPE"
)

type JoinMethod

type JoinMethod string
const (
	HashJoinMethod  JoinMethod = "HASH"
	ApplyJoinMethod JoinMethod = "APPLY"
	LoopJoinMethod  JoinMethod = "LOOP" // Undocumented, but the Spanner accept this value at least.
)

type JoinOp

type JoinOp string
const (
	CommaJoin      JoinOp = ","
	CrossJoin      JoinOp = "CROSS JOIN"
	InnerJoin      JoinOp = "INNER JOIN"
	FullOuterJoin  JoinOp = "FULL OUTER JOIN"
	LeftOuterJoin  JoinOp = "LEFT OUTER JOIN"
	RightOuterJoin JoinOp = "RIGHT OUTER JOIN"
)

type Limit

type Limit struct {
	Limit token.Pos // position of "LIMIT" keyword

	Count  IntValue
	Offset *Offset // optional
}

Limit is LIMIT clause node.

LIMIT {{.Count | sql}} {{.Offset | sqlOpt}}

func (*Limit) End

func (l *Limit) End() token.Pos

func (*Limit) Pos

func (l *Limit) Pos() token.Pos

func (*Limit) SQL

func (l *Limit) SQL() string

type Node

type Node interface {
	Pos() token.Pos
	End() token.Pos

	// Convert AST node into SQL source string (a.k.a. Unparse).
	SQL() string
}

Node is base interface of Spanner SQL AST nodes.

type NullLiteral

type NullLiteral struct {
	Null token.Pos // position of "NULL"
}

NullLiteral is just NULL literal.

NULL

func (*NullLiteral) End

func (n *NullLiteral) End() token.Pos

func (*NullLiteral) Pos

func (n *NullLiteral) Pos() token.Pos

func (*NullLiteral) SQL

func (*NullLiteral) SQL() string

type NumValue

type NumValue interface {
	Node
	// contains filtered or unexported methods
}

NumValue represents number values in SQL.

type NumericLiteral

type NumericLiteral struct {
	Numeric token.Pos // position of "NUMERIC"

	Value *StringLiteral
}

NumericLiteral is numeric literal node.

NUMERIC {{.Value | sql}}

func (*NumericLiteral) End

func (t *NumericLiteral) End() token.Pos

func (*NumericLiteral) Pos

func (t *NumericLiteral) Pos() token.Pos

func (*NumericLiteral) SQL

func (t *NumericLiteral) SQL() string

type Offset

type Offset struct {
	Offset token.Pos // position of "OFFSET" keyword

	Value IntValue
}

Offset is OFFSET clause node in LIMIT clause.

OFFSET {{.Value | sql}}

func (*Offset) End

func (o *Offset) End() token.Pos

func (*Offset) Pos

func (o *Offset) Pos() token.Pos

func (*Offset) SQL

func (o *Offset) SQL() string

type On

type On struct {
	On token.Pos // position of "ON" keyword

	Expr Expr
}

On is ON condition of JOIN expression.

ON {{.Expr | sql}}

func (*On) End

func (o *On) End() token.Pos

func (*On) Pos

func (o *On) Pos() token.Pos

func (*On) SQL

func (o *On) SQL() string

type OnDeleteAction

type OnDeleteAction string
const (
	OnDeleteCascade  OnDeleteAction = "ON DELETE CASCADE"
	OnDeleteNoAction OnDeleteAction = "ON DELETE NO ACTION"
)

type OrderBy

type OrderBy struct {
	Order token.Pos // position of "ORDER" keyword

	Items []*OrderByItem // len(Items) > 0
}

OrderBy is ORDER BY clause node.

ORDER BY {{.Items | sqlJoin ","}}

func (*OrderBy) End

func (o *OrderBy) End() token.Pos

func (*OrderBy) Pos

func (o *OrderBy) Pos() token.Pos

func (*OrderBy) SQL

func (o *OrderBy) SQL() string

type OrderByItem

type OrderByItem struct {
	DirPos token.Pos // position of Dir

	Expr    Expr
	Collate *Collate  // optional
	Dir     Direction // optional
}

OrderByItem is expression node in ORDER BY clause list.

{{.Expr | sql}} {{.Collate | sqlOpt}} {{.Direction}}

func (*OrderByItem) End

func (o *OrderByItem) End() token.Pos

func (*OrderByItem) Pos

func (o *OrderByItem) Pos() token.Pos

func (*OrderByItem) SQL

func (o *OrderByItem) SQL() string

type Param

type Param struct {
	Atmark token.Pos

	Name string
}

Param is Query parameter node.

@{{.Name}}

func (*Param) End

func (p *Param) End() token.Pos

func (*Param) Pos

func (p *Param) Pos() token.Pos

func (*Param) SQL

func (p *Param) SQL() string

type ParenExpr

type ParenExpr struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Expr Expr
}

ParenExpr is parenthesized expression node.

({{. | sql}})

func (*ParenExpr) End

func (p *ParenExpr) End() token.Pos

func (*ParenExpr) Pos

func (p *ParenExpr) Pos() token.Pos

func (*ParenExpr) SQL

func (p *ParenExpr) SQL() string

type ParenTableExpr

type ParenTableExpr struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Source TableExpr    // SubQueryJoinExpr (without As) or Join
	Sample *TableSample // optional
}

ParenTableExpr is parenthesized JOIN expression.

({{.Source | sql}}) {{.Sample | sqlOpt}}

func (*ParenTableExpr) End

func (p *ParenTableExpr) End() token.Pos

func (*ParenTableExpr) Pos

func (p *ParenTableExpr) Pos() token.Pos

func (*ParenTableExpr) SQL

func (p *ParenTableExpr) SQL() string

type Path

type Path struct {
	Idents []*Ident // len(Idents) >= 2
}

Path is dot-chained identifier list.

{{.Idents | sqlJoin "."}}

func (*Path) End

func (p *Path) End() token.Pos

func (*Path) Pos

func (p *Path) Pos() token.Pos

func (*Path) SQL

func (p *Path) SQL() string

type Privilege

type Privilege interface {
	Node
	// contains filtered or unexported methods
}

Privilege represents privileges specified by GRANT and REVOKE.

type PrivilegeOnTable

type PrivilegeOnTable struct {
	Privileges []TablePrivilege // len(Privileges) > 0
	Names      []*Ident         // len(Names) > 0
}

PrivilegeOnTable is ON TABLE privilege node in GRANT and REVOKE.

{{.Privileges | sqlJoin ","}} ON TABLE {{.Names | sqlJoin ","}}

func (*PrivilegeOnTable) End

func (p *PrivilegeOnTable) End() token.Pos

func (*PrivilegeOnTable) Pos

func (p *PrivilegeOnTable) Pos() token.Pos

func (*PrivilegeOnTable) SQL

func (p *PrivilegeOnTable) SQL() string

type QueryExpr

type QueryExpr interface {
	Node
	// contains filtered or unexported methods
}

QueryExpr represents set operator operands.

type QueryStatement

type QueryStatement struct {
	Hint  *Hint // optional
	With  *With // optional
	Query QueryExpr
}

QueryStatement is query statement node.

{{if .Hint}}{{.Hint | sql}}{{end}}
{{.Expr | sql}}

https://cloud.google.com/spanner/docs/query-syntax

func (*QueryStatement) End

func (q *QueryStatement) End() token.Pos

func (*QueryStatement) Pos

func (q *QueryStatement) Pos() token.Pos

func (*QueryStatement) SQL

func (q *QueryStatement) SQL() string

type ReplaceRowDeletionPolicy

type ReplaceRowDeletionPolicy struct {
	Replace token.Pos // position of  "REPLACE" keyword

	RowDeletionPolicy *RowDeletionPolicy
}

ReplaceRowDeletionPolicy is REPLACE ROW DELETION POLICY clause in ALTER TABLE.

REPLACE {{.RowDeletionPolicy}}

func (*ReplaceRowDeletionPolicy) End

func (*ReplaceRowDeletionPolicy) Pos

func (*ReplaceRowDeletionPolicy) SQL

type Revoke

type Revoke struct {
	Revoke token.Pos // position of "REVOKE" keyword

	Privilege Privilege // len(Privileges) > 0
	Roles     []*Ident  // len(Roles) > 0
}

Revoke is REVOKE statement node.

REVOKE {{.Privilege | sql}} FROM ROLE {{.Roles | sqlJoin ","}}

func (*Revoke) End

func (r *Revoke) End() token.Pos

func (*Revoke) Pos

func (r *Revoke) Pos() token.Pos

func (*Revoke) SQL

func (r *Revoke) SQL() string

type RolePrivilege

type RolePrivilege struct {
	Role token.Pos

	Names []*Ident // len(Names) > 0
}

RolePrivilege is ROLE privilege node in GRANT and REVOKE.

ROLE {{.Names | sqlJoin ","}}

func (*RolePrivilege) End

func (r *RolePrivilege) End() token.Pos

func (*RolePrivilege) Pos

func (r *RolePrivilege) Pos() token.Pos

func (*RolePrivilege) SQL

func (r *RolePrivilege) SQL() string

type RowDeletionPolicy

type RowDeletionPolicy struct {
	Row    token.Pos // position of "ROW"
	Rparen token.Pos // position of ")"

	ColumnName *Ident
	NumDays    *IntLiteral
}

RowDeletionPolicy is ROW DELETION POLICY clause.

ROW DELETION POLICY (OLDER_THAN({{.ColymnName | sql}}, INTERVAL {{.NumDays}} DAY))

func (*RowDeletionPolicy) End

func (r *RowDeletionPolicy) End() token.Pos

func (*RowDeletionPolicy) Pos

func (r *RowDeletionPolicy) Pos() token.Pos

func (*RowDeletionPolicy) SQL

func (r *RowDeletionPolicy) SQL() string

type ScalarSchemaType

type ScalarSchemaType struct {
	NamePos token.Pos // position of this name

	Name ScalarTypeName // except for StringTypeName and BytesTypeName
}

ScalarSchemaType is scalar type node in schema.

{{.Name}}

func (*ScalarSchemaType) End

func (s *ScalarSchemaType) End() token.Pos

func (*ScalarSchemaType) Pos

func (s *ScalarSchemaType) Pos() token.Pos

func (*ScalarSchemaType) SQL

func (s *ScalarSchemaType) SQL() string

type ScalarSubQuery

type ScalarSubQuery struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Query QueryExpr
}

ScalarSubQuery is subquery in expression.

({{.Query | sql}})

func (*ScalarSubQuery) End

func (s *ScalarSubQuery) End() token.Pos

func (*ScalarSubQuery) Pos

func (s *ScalarSubQuery) Pos() token.Pos

func (*ScalarSubQuery) SQL

func (s *ScalarSubQuery) SQL() string

type ScalarTypeName

type ScalarTypeName string
const (
	BoolTypeName      ScalarTypeName = "BOOL"
	Int64TypeName     ScalarTypeName = "INT64"
	Float64TypeName   ScalarTypeName = "FLOAT64"
	StringTypeName    ScalarTypeName = "STRING"
	BytesTypeName     ScalarTypeName = "BYTES"
	DateTypeName      ScalarTypeName = "DATE"
	TimestampTypeName ScalarTypeName = "TIMESTAMP"
	NumericTypeName   ScalarTypeName = "NUMERIC"
)

type SchemaType

type SchemaType interface {
	Node
	// contains filtered or unexported methods
}

SchemaType represents types for schema.

type SecurityType

type SecurityType string
const (
	SecurityTypeInvoker SecurityType = "INVOKER"
	SecurityTypeDefiner SecurityType = "DEFINER"
)

type Select

type Select struct {
	Select token.Pos // position of "select" keyword

	Distinct bool
	AsStruct bool
	Results  []SelectItem // len(Results) > 0
	From     *From        // optional
	Where    *Where       // optional
	GroupBy  *GroupBy     // optional
	Having   *Having      // optional
	OrderBy  *OrderBy     // optional
	Limit    *Limit       // optional
}

Select is SELECT statement node.

SELECT
  {{if .Distinct}}DISTINCT{{end}}
  {{if .AsStruct}}AS STRUCT{{end}}
  {{.Results | sqlJoin ","}}
  {{.From | sqlOpt}}
  {{.Where | sqlOpt}}
  {{.GroupBy | sqlOpt}}
  {{.Having | sqlOpt}}
  {{.OrderBy | sqlOpt}}
  {{.Limit | sqlOpt}}

func (*Select) End

func (s *Select) End() token.Pos

func (*Select) Pos

func (s *Select) Pos() token.Pos

func (*Select) SQL

func (s *Select) SQL() string

type SelectItem

type SelectItem interface {
	Node
	// contains filtered or unexported methods
}

SelectItem represents expression in SELECT clause result columns list.

type SelectPrivilege

type SelectPrivilege struct {
	Select token.Pos // position of "SELECT" keyword
	Rparen token.Pos // position of ")" when len(Columns) > 0

	Columns []*Ident
}

SelectPrivilege is SELECT ON TABLE privilege node in GRANT and REVOKE.

SELECT{{if .Columns}}({{.Columns | sqlJoin ","}}){{end}}

func (*SelectPrivilege) End

func (s *SelectPrivilege) End() token.Pos

func (*SelectPrivilege) Pos

func (s *SelectPrivilege) Pos() token.Pos

func (*SelectPrivilege) SQL

func (s *SelectPrivilege) SQL() string

type SelectPrivilegeOnView

type SelectPrivilegeOnView struct {
	Select token.Pos

	Names []*Ident // len(Names) > 0
}

SelectPrivilegeOnView is SELECT ON VIEW privilege node in GRANT and REVOKE.

SELECT ON VIEW {{.Names | sqlJoin ","}}

func (*SelectPrivilegeOnView) End

func (s *SelectPrivilegeOnView) End() token.Pos

func (*SelectPrivilegeOnView) Pos

func (s *SelectPrivilegeOnView) Pos() token.Pos

func (*SelectPrivilegeOnView) SQL

func (s *SelectPrivilegeOnView) SQL() string

type SelectorExpr

type SelectorExpr struct {
	Expr  Expr
	Ident *Ident
}

SelectorExpr is struct field access expression node.

{{.Expr | sql}}.{{.Ident | sql}}

func (*SelectorExpr) End

func (b *SelectorExpr) End() token.Pos

func (*SelectorExpr) Pos

func (b *SelectorExpr) Pos() token.Pos

func (*SelectorExpr) SQL

func (s *SelectorExpr) SQL() string

type SequenceArg

type SequenceArg struct {
	Sequence token.Pos // position of "SEQUENCE" keyword

	Expr Expr
}

SequenceArg is argument of sequence function call.

SEQUENCE {{.Expr | sql}}

func (*SequenceArg) End

func (s *SequenceArg) End() token.Pos

func (*SequenceArg) Pos

func (s *SequenceArg) Pos() token.Pos

func (*SequenceArg) SQL

func (s *SequenceArg) SQL() string

type SequenceOption

type SequenceOption struct {
	Name  *Ident
	Value Expr
}

SequenceOption is option for CREATE SEQUENCE.

{{.Name | sql}} = {{.Value | sql}}

func (*SequenceOption) End

func (o *SequenceOption) End() token.Pos

func (*SequenceOption) Pos

func (o *SequenceOption) Pos() token.Pos

func (*SequenceOption) SQL

func (o *SequenceOption) SQL() string

type SetOnDelete

type SetOnDelete struct {
	Set         token.Pos // position of "SET" keyword
	OnDeleteEnd token.Pos // end position of ON DELETE clause

	OnDelete OnDeleteAction
}

SetOnDelete is SET ON DELETE clause in ALTER TABLE.

SET ON DELETE {{.OnDelete}}

func (*SetOnDelete) End

func (s *SetOnDelete) End() token.Pos

func (*SetOnDelete) Pos

func (s *SetOnDelete) Pos() token.Pos

func (*SetOnDelete) SQL

func (s *SetOnDelete) SQL() string

type SetOp

type SetOp string
const (
	SetOpUnion     SetOp = "UNION"
	SetOpIntersect SetOp = "INTERSECT"
	SetOpExcept    SetOp = "EXCEPT"
)

type SimpleType

type SimpleType struct {
	NamePos token.Pos // position of this name

	Name ScalarTypeName
}

SimpleType is type node having no parameter like INT64, STRING.

{{.Name}}

func (*SimpleType) End

func (s *SimpleType) End() token.Pos

func (*SimpleType) Pos

func (s *SimpleType) Pos() token.Pos

func (*SimpleType) SQL

func (s *SimpleType) SQL() string

type SizedSchemaType

type SizedSchemaType struct {
	NamePos token.Pos // position of this name
	Rparen  token.Pos // position of ")"

	Name ScalarTypeName // StringTypeName or BytesTypeName
	// either Max or Size must be set
	Max  bool
	Size IntValue
}

SizedSchemaType is sized type node in schema.

{{.Name}}({{if .Max}}MAX{{else}}{{.Size | sql}}{{end}})

func (*SizedSchemaType) End

func (s *SizedSchemaType) End() token.Pos

func (*SizedSchemaType) Pos

func (s *SizedSchemaType) Pos() token.Pos

func (*SizedSchemaType) SQL

func (s *SizedSchemaType) SQL() string

type Star

type Star struct {
	Star token.Pos // position of "*"
}

Star is a single * in SELECT result columns list.

*

func (*Star) End

func (s *Star) End() token.Pos

func (*Star) Pos

func (s *Star) Pos() token.Pos

func (*Star) SQL

func (s *Star) SQL() string

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

Statement represents toplevel statement node of Spanner SQL.

type Storing

type Storing struct {
	Storing token.Pos // position of "STORING" keyword
	Rparen  token.Pos // position of ")"

	Columns []*Ident
}

Storing is STORING clause in CREATE INDEX.

STORING ({{.Columns | sqlJoin ","}})

func (*Storing) End

func (s *Storing) End() token.Pos

func (*Storing) Pos

func (s *Storing) Pos() token.Pos

func (*Storing) SQL

func (s *Storing) SQL() string

type StringLiteral

type StringLiteral struct {
	ValuePos, ValueEnd token.Pos // position of this value

	Value string
}

StringLiteral is string literal node.

{{.Value | sqlStringQuote}}

func (*StringLiteral) End

func (s *StringLiteral) End() token.Pos

func (*StringLiteral) Pos

func (s *StringLiteral) Pos() token.Pos

func (*StringLiteral) SQL

func (s *StringLiteral) SQL() string

type StringValue

type StringValue interface {
	Node
	// contains filtered or unexported methods
}

StringValue represents string value in SQL.

type StructField

type StructField struct {
	Ident *Ident
	Type  Type
}

StructField is field in struct type node.

{{if .Ident}}{{.Ident | sql}}{{end}} {{.Type | sql}}

func (*StructField) End

func (f *StructField) End() token.Pos

func (*StructField) Pos

func (f *StructField) Pos() token.Pos

func (*StructField) SQL

func (f *StructField) SQL() string

type StructLiteral

type StructLiteral struct {
	Struct         token.Pos // position of "STRUCT"
	Lparen, Rparen token.Pos // position of "(" and ")"

	// NOTE: Distinguish nil from len(Fields) == 0 case.
	//       nil means type is not specified, or empty slice means this struct has 0 fields.
	Fields []*StructField
	Values []Expr
}

StructLiteral is struct literal node.

STRUCT{{if not (isnil .Fields)}}<{{.Fields | sqlJoin ","}}>{{end}}({{.Values | sqlJoin ","}})

func (*StructLiteral) End

func (s *StructLiteral) End() token.Pos

func (*StructLiteral) Pos

func (s *StructLiteral) Pos() token.Pos

func (*StructLiteral) SQL

func (s *StructLiteral) SQL() string

type StructType

type StructType struct {
	Struct token.Pos // position of "STRUCT"
	Gt     token.Pos // position of ">"

	Fields []*StructField
}

StructType is struct type node.

STRUCT<{{.Fields | sqlJoin ","}}>

func (*StructType) End

func (s *StructType) End() token.Pos

func (*StructType) Pos

func (s *StructType) Pos() token.Pos

func (*StructType) SQL

func (s *StructType) SQL() string

type SubQuery

type SubQuery struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Query   QueryExpr
	OrderBy *OrderBy // optional
	Limit   *Limit   // optional
}

SubQuery is subquery statement node.

({{.Expr | sql}} {{.OrderBy | sqlOpt}} {{.Limit | sqlOpt}})

func (*SubQuery) End

func (s *SubQuery) End() token.Pos

func (*SubQuery) Pos

func (s *SubQuery) Pos() token.Pos

func (*SubQuery) SQL

func (s *SubQuery) SQL() string

type SubQueryInCondition

type SubQueryInCondition struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Query QueryExpr
}

SubQueryInCondition is subquery at IN condition.

({{.Query | sql}})

func (*SubQueryInCondition) End

func (s *SubQueryInCondition) End() token.Pos

func (*SubQueryInCondition) Pos

func (s *SubQueryInCondition) Pos() token.Pos

func (*SubQueryInCondition) SQL

func (s *SubQueryInCondition) SQL() string

type SubQueryInput

type SubQueryInput struct {
	Query QueryExpr
}

SubQueryInput is query clause in INSERT.

{{.Query | sql}}

func (*SubQueryInput) End

func (s *SubQueryInput) End() token.Pos

func (*SubQueryInput) Pos

func (s *SubQueryInput) Pos() token.Pos

func (*SubQueryInput) SQL

func (s *SubQueryInput) SQL() string

type SubQueryTableExpr

type SubQueryTableExpr struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Query  QueryExpr
	As     *AsAlias     // optional
	Sample *TableSample // optional
}

SubQueryTableExpr is subquery inside JOIN expression.

({{.Query | sql}}) {{.As | sqlOpt}} {{.Sample | sqlOpt}}

func (*SubQueryTableExpr) End

func (s *SubQueryTableExpr) End() token.Pos

func (*SubQueryTableExpr) Pos

func (s *SubQueryTableExpr) Pos() token.Pos

func (*SubQueryTableExpr) SQL

func (s *SubQueryTableExpr) SQL() string

type TableAlteration

type TableAlteration interface {
	Node
	// contains filtered or unexported methods
}

TableAlteration represents ALTER TABLE action.

type TableConstraint

type TableConstraint struct {
	ConstraintPos token.Pos // position of "CONSTRAINT" keyword when Name presents

	Name       *Ident // optional
	Constraint Constraint
}

TableConstraint is table constraint in CREATE TABLE and ALTER TABLE.

{{if .Name}}CONSTRAINT {{.Name}}{{end}}{{.Constraint | sql}}

func (*TableConstraint) End

func (c *TableConstraint) End() token.Pos

func (*TableConstraint) Pos

func (c *TableConstraint) Pos() token.Pos

func (*TableConstraint) SQL

func (c *TableConstraint) SQL() string

type TableExpr

type TableExpr interface {
	Node
	// contains filtered or unexported methods
}

TableExpr represents JOIN operands.

type TableHintKey

type TableHintKey string
const (
	ForceIndexTableHint     TableHintKey = "FORCE_INDEX"
	GroupScanByOptimization TableHintKey = "GROUPBY_SCAN_OPTIMIZATION"
)

type TableName

type TableName struct {
	Table  *Ident
	Hint   *Hint        // optional
	As     *AsAlias     // optional
	Sample *TableSample // optional
}

TableName is table name node in FROM clause.

{{.Table | sql}} {{.Hint | sqlOpt}} {{.As | sqlOpt}} {{.Sample | sqlOpt}}

func (*TableName) End

func (t *TableName) End() token.Pos

func (*TableName) Pos

func (t *TableName) Pos() token.Pos

func (*TableName) SQL

func (t *TableName) SQL() string

type TablePrivilege

type TablePrivilege interface {
	Node
	// contains filtered or unexported methods
}

TablePrivilege represents privileges on table.

type TableSample

type TableSample struct {
	TableSample token.Pos // position of "TABLESAMPLE" keyword

	Method TableSampleMethod
	Size   *TableSampleSize
}

TableSample is TABLESAMPLE clause node.

TABLESAMPLE {{.Method}} {{.Size | sql}}

func (*TableSample) End

func (t *TableSample) End() token.Pos

func (*TableSample) Pos

func (t *TableSample) Pos() token.Pos

func (*TableSample) SQL

func (t *TableSample) SQL() string

type TableSampleMethod

type TableSampleMethod string
const (
	BernoulliSampleMethod TableSampleMethod = "BERNOULLI"
	ReservoirSampleMethod TableSampleMethod = "RESERVOIR"
)

type TableSampleSize

type TableSampleSize struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Value NumValue
	Unit  TableSampleUnit
}

TableSampleSize is size part of TABLESAMPLE clause.

({{.Value | sql}} {{.Unit}})

func (*TableSampleSize) End

func (t *TableSampleSize) End() token.Pos

func (*TableSampleSize) Pos

func (t *TableSampleSize) Pos() token.Pos

func (*TableSampleSize) SQL

func (t *TableSampleSize) SQL() string

type TableSampleUnit

type TableSampleUnit string
const (
	PercentTableSampleUnit TableSampleUnit = "PERCENT"
	RowsTableSampleUnit    TableSampleUnit = "ROWS"
)

type TimestampLiteral

type TimestampLiteral struct {
	Timestamp token.Pos // position of "TIMESTAMP"

	Value *StringLiteral
}

TimestampLiteral is timestamp literal node.

TIMESTAMP {{.Value | sql}}

func (*TimestampLiteral) End

func (t *TimestampLiteral) End() token.Pos

func (*TimestampLiteral) Pos

func (t *TimestampLiteral) Pos() token.Pos

func (*TimestampLiteral) SQL

func (t *TimestampLiteral) SQL() string

type Type

type Type interface {
	Node
	// contains filtered or unexported methods
}

Type represents type node.

type UnaryExpr

type UnaryExpr struct {
	OpPos token.Pos // position of Op

	Op   UnaryOp
	Expr Expr
}

UnaryExpr is unary operator expression node.

{{.Op}} {{.Expr | sql}}

func (*UnaryExpr) End

func (u *UnaryExpr) End() token.Pos

func (*UnaryExpr) Pos

func (u *UnaryExpr) Pos() token.Pos

func (*UnaryExpr) SQL

func (u *UnaryExpr) SQL() string

type UnaryOp

type UnaryOp string
const (
	OpNot    UnaryOp = "NOT"
	OpPlus   UnaryOp = "+"
	OpMinus  UnaryOp = "-"
	OpBitNot UnaryOp = "~"
)

type Unnest

type Unnest struct {
	Unnest token.Pos // position of "UNNEST"
	Rparen token.Pos // position of ")"

	Implicit   bool
	Expr       Expr         // Path or Ident when Implicit is true
	Hint       *Hint        // optional
	As         *AsAlias     // optional
	WithOffset *WithOffset  // optional
	Sample     *TableSample // optional
}

Unnest is UNNEST call in FROM clause.

{{if .Implicit}}{{.Expr | sql}}{{else}}UNNEST({{.Expr | sql}}){{end}}
  {{.Hint | sqlOpt}}
  {{.As | sqlOpt}}
  {{.WithOffset | sqlOpt}}
  {{.Sample | sqlOpt}}

func (*Unnest) End

func (u *Unnest) End() token.Pos

func (*Unnest) Pos

func (u *Unnest) Pos() token.Pos

func (*Unnest) SQL

func (u *Unnest) SQL() string

type UnnestInCondition

type UnnestInCondition struct {
	Unnest token.Pos
	Rparen token.Pos

	Expr Expr
}

UnnestInCondition is UNNEST call at IN condition.

UNNEST({{.Expr | sql}})

func (*UnnestInCondition) End

func (u *UnnestInCondition) End() token.Pos

func (*UnnestInCondition) Pos

func (u *UnnestInCondition) Pos() token.Pos

func (*UnnestInCondition) SQL

func (u *UnnestInCondition) SQL() string

type Update

type Update struct {
	Update token.Pos // position of "UPDATE" keyword

	TableName *Ident
	As        *AsAlias      // optional
	Updates   []*UpdateItem // len(Updates) > 0
	Where     *Where
}

Update is UPDATE statement.

UPDATE {{.TableName | sql}} {{.As | sqlOpt}}
SET {{.Updates | sqlJoin ","}} {{.Where | sql}}

func (*Update) End

func (u *Update) End() token.Pos

func (*Update) Pos

func (u *Update) Pos() token.Pos

func (*Update) SQL

func (u *Update) SQL() string

type UpdateItem

type UpdateItem struct {
	Path []*Ident // len(Path) > 0
	Expr Expr
}

UpdateItem is SET clause items in UPDATE.

{{.Path | sqlJoin "."}} = {{.Expr | sql}}

func (*UpdateItem) End

func (u *UpdateItem) End() token.Pos

func (*UpdateItem) Pos

func (u *UpdateItem) Pos() token.Pos

func (*UpdateItem) SQL

func (u *UpdateItem) SQL() string

type UpdatePrivilege

type UpdatePrivilege struct {
	Update token.Pos // position of "UPDATE" keyword
	Rparen token.Pos // position of ")" when len(Columns) > 0

	Columns []*Ident
}

UpdatePrivilege is UPDATE ON TABLE privilege node in GRANT and REVOKE.

UPDATE{{if .Columns}}({{.Columns | sqlJoin ","}}){{end}}

func (*UpdatePrivilege) End

func (u *UpdatePrivilege) End() token.Pos

func (*UpdatePrivilege) Pos

func (u *UpdatePrivilege) Pos() token.Pos

func (*UpdatePrivilege) SQL

func (u *UpdatePrivilege) SQL() string

type Using

type Using struct {
	Using  token.Pos // position of "USING" keyword
	Rparen token.Pos // position of ")"

	Idents []*Ident // len(Idents) > 0
}

Using is Using condition of JOIN expression.

USING ({{Idents | sqlJoin ","}})

func (*Using) End

func (u *Using) End() token.Pos

func (*Using) Pos

func (u *Using) Pos() token.Pos

func (*Using) SQL

func (u *Using) SQL() string

type ValuesInCondition

type ValuesInCondition struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Exprs []Expr // len(Exprs) > 0
}

ValuesInCondition is parenthesized values at IN condition.

({{.Exprs | sqlJoin ","}})

func (*ValuesInCondition) End

func (v *ValuesInCondition) End() token.Pos

func (*ValuesInCondition) Pos

func (v *ValuesInCondition) Pos() token.Pos

func (*ValuesInCondition) SQL

func (v *ValuesInCondition) SQL() string

type ValuesInput

type ValuesInput struct {
	Values token.Pos // position of "VALUES" keyword

	Rows []*ValuesRow
}

ValuesInput is VALUES clause in INSERT.

VALUES {{.Rows | sqlJoin ","}}

func (*ValuesInput) End

func (v *ValuesInput) End() token.Pos

func (*ValuesInput) Pos

func (v *ValuesInput) Pos() token.Pos

func (*ValuesInput) SQL

func (v *ValuesInput) SQL() string

type ValuesRow

type ValuesRow struct {
	Lparen, Rparen token.Pos // position of "(" and ")"

	Exprs []*DefaultExpr
}

ValuesRow is row values of VALUES clause.

({{.Exprs | sqlJoin ","}})

func (*ValuesRow) End

func (v *ValuesRow) End() token.Pos

func (*ValuesRow) Pos

func (v *ValuesRow) Pos() token.Pos

func (*ValuesRow) SQL

func (v *ValuesRow) SQL() string

type Where

type Where struct {
	Where token.Pos // position of "WHERE" keyword

	Expr Expr
}

Where is WHERE clause node.

WHERE {{.Expr | sql}}

func (*Where) End

func (w *Where) End() token.Pos

func (*Where) Pos

func (w *Where) Pos() token.Pos

func (*Where) SQL

func (w *Where) SQL() string

type With

type With struct {
	With token.Pos // position of "WITH" keyword

	CTEs []*CTE
}

With is with clause node.

WITH {{.CTEs | sqlJoin ","}}

func (*With) End

func (w *With) End() token.Pos

func (*With) Pos

func (w *With) Pos() token.Pos

func (*With) SQL

func (w *With) SQL() string

type WithOffset

type WithOffset struct {
	With, Offset token.Pos // position of "WITH" and "OFFSET" keywords

	As *AsAlias // optional
}

WithOffset is WITH OFFSET clause node after UNNEST call.

WITH OFFSET {{.As | sqlOpt}}

func (*WithOffset) End

func (w *WithOffset) End() token.Pos

func (*WithOffset) Pos

func (w *WithOffset) Pos() token.Pos

func (*WithOffset) SQL

func (w *WithOffset) SQL() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL