- 1.86.1 (latest)
- 1.86.0
- 1.85.1
- 1.84.1
- 1.83.0
- 1.82.0
- 1.81.1
- 1.80.0
- 1.79.0
- 1.78.0
- 1.77.0
- 1.76.1
- 1.75.0
- 1.74.0
- 1.73.0
- 1.72.0
- 1.71.0
- 1.70.0
- 1.69.0
- 1.68.0
- 1.67.0
- 1.66.0
- 1.65.0
- 1.64.0
- 1.63.0
- 1.62.0
- 1.61.0
- 1.60.0
- 1.59.0
- 1.58.0
- 1.57.0
- 1.56.0
- 1.55.0
- 1.54.0
- 1.53.1
- 1.52.0
- 1.49.0
- 1.48.0
- 1.47.0
- 1.46.0
- 1.45.1
- 1.44.0
- 1.43.0
- 1.42.0
- 1.41.0
- 1.40.0
- 1.39.0
- 1.38.0
- 1.37.0
- 1.36.0
- 1.35.0
- 1.34.1
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.1
- 1.29.0
- 1.28.0
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.1
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.1
- 1.13.0
Package spansql contains types and a parser for the Cloud Spanner SQL dialect.
To parse, use one of the Parse functions (ParseDDL, ParseDDLStmt, ParseQuery, etc.).
Sources:
https://cloud.google.com/spanner/docs/lexical https://cloud.google.com/spanner/docs/query-syntax https://cloud.google.com/spanner/docs/data-definition-language
Constants
True, False
const (
True = BoolLiteral(true)
False = BoolLiteral(false)
)MaxLen
MaxLen is a sentinel for Type's Len field, representing the MAX value.
Null
const Null = NullLiteral(0)Star
const Star = StarExpr(0)Star represents a "*" in an expression.
Functions
func IsKeyword
IsKeyword reports whether the identifier is a reserved keyword.
AddColumn
func (AddColumn) SQL
AddConstraint
type AddConstraint struct{ Constraint TableConstraint }func (AddConstraint) SQL
func (ac AddConstraint) SQL() stringAddRowDeletionPolicy
type AddRowDeletionPolicy struct{ RowDeletionPolicy RowDeletionPolicy }func (AddRowDeletionPolicy) SQL
func (ardp AddRowDeletionPolicy) SQL() stringAddStoredColumn
type AddStoredColumn struct{ Name ID }func (AddStoredColumn) SQL
func (asc AddStoredColumn) SQL() stringAddSynonym
type AddSynonym struct{ Name ID }func (AddSynonym) SQL
func (as AddSynonym) SQL() stringAggregateHaving
type AggregateHaving struct {
Condition AggregateHavingCondition
Expr Expr
}AggregateHaving represents the HAVING clause specific to aggregate functions, restricting rows based on a maximal or minimal value.
AggregateHavingCondition
type AggregateHavingCondition intAggregateHavingCondition represents the condition (MAX or MIN) for the AggregateHaving clause.
HavingMax, HavingMin
const (
HavingMax AggregateHavingCondition = iota
HavingMin
)AlterChangeStream
type AlterChangeStream struct {
Name ID
Alteration ChangeStreamAlteration
Position Position
}AlterChangeStream represents a ALTER CHANGE STREAM statement.
func (*AlterChangeStream) Pos
func (acs *AlterChangeStream) Pos() Positionfunc (AlterChangeStream) SQL
func (acs AlterChangeStream) SQL() stringfunc (*AlterChangeStream) String
func (acs *AlterChangeStream) String() stringAlterChangeStreamOptions
type AlterChangeStreamOptions struct{ Options ChangeStreamOptions }func (AlterChangeStreamOptions) SQL
func (ao AlterChangeStreamOptions) SQL() stringAlterColumn
type AlterColumn struct {
Name ID
Alteration ColumnAlteration
}func (AlterColumn) SQL
func (ac AlterColumn) SQL() stringAlterDatabase
type AlterDatabase struct {
Name ID
Alteration DatabaseAlteration
Position Position // position of the "ALTER" token
}AlterDatabase represents an ALTER DATABASE statement. https://cloud.google.com/spanner/docs/data-definition-language#alter-database
func (*AlterDatabase) Pos
func (ad *AlterDatabase) Pos() Positionfunc (AlterDatabase) SQL
func (ad AlterDatabase) SQL() stringfunc (*AlterDatabase) String
func (ad *AlterDatabase) String() stringAlterIndex
type AlterIndex struct {
Name ID
Alteration IndexAlteration
Position Position // position of the "ALTER" token
}func (*AlterIndex) Pos
func (as *AlterIndex) Pos() Positionfunc (AlterIndex) SQL
func (ai AlterIndex) SQL() stringfunc (*AlterIndex) String
func (as *AlterIndex) String() stringAlterProtoBundle
AlterProtoBundle represents a ALTER PROTO BUNDLE statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#alter-proto-bundle
func (*AlterProtoBundle) Pos
func (ap *AlterProtoBundle) Pos() Positionfunc (AlterProtoBundle) SQL
func (ap AlterProtoBundle) SQL() stringfunc (*AlterProtoBundle) String
func (ap *AlterProtoBundle) String() stringAlterSequence
type AlterSequence struct {
Name ID
Alteration SequenceAlteration
Position Position
}AlterSequence represents an ALTER SEQUENCE statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#alter-sequence
func (*AlterSequence) Pos
func (as *AlterSequence) Pos() Positionfunc (AlterSequence) SQL
func (as AlterSequence) SQL() stringfunc (*AlterSequence) String
func (as *AlterSequence) String() stringAlterStatistics
type AlterStatistics struct {
Name ID
Alteration StatisticsAlteration
Position Position // position of the "ALTER" token
}AlterStatistics represents an ALTER STATISTICS statement. https://cloud.google.com/spanner/docs/data-definition-language#alter-statistics
func (*AlterStatistics) Pos
func (as *AlterStatistics) Pos() Positionfunc (AlterStatistics) SQL
func (as AlterStatistics) SQL() stringfunc (*AlterStatistics) String
func (as *AlterStatistics) String() stringAlterTable
type AlterTable struct {
Name ID
Alteration TableAlteration
Position Position // position of the "ALTER" token
}AlterTable represents an ALTER TABLE statement. https://cloud.google.com/spanner/docs/data-definition-language#alter_table
func (*AlterTable) Pos
func (at *AlterTable) Pos() Positionfunc (AlterTable) SQL
func (at AlterTable) SQL() stringfunc (*AlterTable) String
func (at *AlterTable) String() stringAlterWatch
func (AlterWatch) SQL
func (scsw AlterWatch) SQL() stringArithOp
type ArithOp struct {
Op ArithOperator
LHS, RHS Expr // only RHS is set for Neg, Plus, BitNot
}func (ArithOp) SQL
ArithOperator
type ArithOperator intNeg, Plus, BitNot, Mul, Div, Concat, Add, Sub, BitShl, BitShr, BitAnd, BitXor, BitOr
const (
Neg ArithOperator = iota // unary -
Plus // unary +
BitNot // unary ~
Mul // *
Div // /
Concat // ||
Add // +
Sub // -
BitShl // < bitshr="">>
BitAnd // &
BitXor // ^
BitOr // |
)Array
type Array []ExprArray represents an array literal.
func (Array) SQL
AtTimeZoneExpr
func (AtTimeZoneExpr) SQL
func (aze AtTimeZoneExpr) SQL() stringBoolExpr
type BoolExpr interface {
Expr
// contains filtered or unexported methods
}BoolLiteral
type BoolLiteral boolfunc (BoolLiteral) SQL
func (b BoolLiteral) SQL() stringBytesLiteral
type BytesLiteral stringBytesLiteral represents a bytes literal. https://cloud.google.com/spanner/docs/lexical#string-and-bytes-literals
func (BytesLiteral) SQL
func (bl BytesLiteral) SQL() stringCase
type Case struct {
Expr Expr
WhenClauses []WhenClause
ElseResult Expr
}func (Case) SQL
ChangeStreamAlteration
type ChangeStreamAlteration interface {
SQL() string
// contains filtered or unexported methods
}ChangeStreamOptions
func (ChangeStreamOptions) SQL
func (cso ChangeStreamOptions) SQL() stringCheck
Check represents a check constraint as part of a CREATE TABLE or ALTER TABLE statement.
func (Check) Pos
func (Check) SQL
Coalesce
type Coalesce struct {
ExprList []Expr
}func (Coalesce) SQL
ColumnAlteration
type ColumnAlteration interface {
SQL() string
// contains filtered or unexported methods
}ColumnAlteration is satisfied by SetColumnType and SetColumnOptions.
ColumnDef
type ColumnDef struct {
Name ID
Type Type
NotNull bool
Default Expr // set if this column has a default value
Generated Expr // set of this is a generated column
Options ColumnOptions
Position Position // position of the column name
}ColumnDef represents a column definition as part of a CREATE TABLE or ALTER TABLE statement.
func (ColumnDef) Pos
func (ColumnDef) SQL
ColumnOptions
type ColumnOptions struct {
// AllowCommitTimestamp represents a column OPTIONS.
// `true` if query is `OPTIONS (allow_commit_timestamp = true)`
// `false` if query is `OPTIONS (allow_commit_timestamp = null)`
// `nil` if there are no OPTIONS
AllowCommitTimestamp *bool
}ColumnOptions represents options on a column as part of a CREATE TABLE or ALTER TABLE statement.
func (ColumnOptions) SQL
func (co ColumnOptions) SQL() stringComment
type Comment struct {
Marker string // Opening marker; one of "#", "--", "/*".
Isolated bool // Whether this comment is on its own line.
// Start and End are the position of the opening and terminating marker.
Start, End Position
Text []string
}Comment represents a comment.
func (*Comment) Pos
func (*Comment) String
ComparisonOp
type ComparisonOp struct {
Op ComparisonOperator
LHS, RHS Expr
// RHS2 is the third operand for BETWEEN.
// "func (ComparisonOp) SQL
func (co ComparisonOp) SQL() stringComparisonOperator
type ComparisonOperator intLt, Le, Gt, Ge, Eq, Ne, Like, NotLike, Between, NotBetween
const (
Lt ComparisonOperator = iota
Le
Gt
Ge
Eq
Ne // both "!=" and "<>"
Like
NotLike
Between
NotBetween
)Constraint
CreateChangeStream
type CreateChangeStream struct {
Name ID
Watch []WatchDef
WatchAllTables bool
Options ChangeStreamOptions
Position Position
}CreateChangeStream represents a CREATE CHANGE STREAM statement. https://cloud.google.com/spanner/docs/change-streams/manage
func (*CreateChangeStream) Pos
func (cs *CreateChangeStream) Pos() Positionfunc (CreateChangeStream) SQL
func (cs CreateChangeStream) SQL() stringfunc (*CreateChangeStream) String
func (cs *CreateChangeStream) String() stringCreateIndex
type CreateIndex struct {
Name ID
Table ID
Columns []KeyPart
Unique bool
NullFiltered bool
IfNotExists bool
Storing []ID
Interleave ID
Position Position // position of the "CREATE" token
}CreateIndex represents a CREATE INDEX statement. https://cloud.google.com/spanner/docs/data-definition-language#create-index
func (*CreateIndex) Pos
func (ci *CreateIndex) Pos() Positionfunc (CreateIndex) SQL
func (ci CreateIndex) SQL() stringfunc (*CreateIndex) String
func (ci *CreateIndex) String() stringCreateProtoBundle
CreateProtoBundle represents a CREATE PROTO BUNDLE statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#create-proto-bundle
func (*CreateProtoBundle) Pos
func (cp *CreateProtoBundle) Pos() Positionfunc (CreateProtoBundle) SQL
func (cp CreateProtoBundle) SQL() stringfunc (*CreateProtoBundle) String
func (cp *CreateProtoBundle) String() stringCreateRole
CreateRole represents a CREATE Role statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#create_role
func (*CreateRole) Pos
func (cr *CreateRole) Pos() Positionfunc (CreateRole) SQL
func (cr CreateRole) SQL() stringfunc (*CreateRole) String
func (cr *CreateRole) String() stringCreateSequence
type CreateSequence struct {
Name ID
IfNotExists bool
Options SequenceOptions
Position Position
}CreateSequence represents an ALTER SEQUENCE statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#create-sequence
func (*CreateSequence) Pos
func (cs *CreateSequence) Pos() Positionfunc (CreateSequence) SQL
func (cs CreateSequence) SQL() stringfunc (*CreateSequence) String
func (cs *CreateSequence) String() stringCreateTable
type CreateTable struct {
Name ID
IfNotExists bool
Columns []ColumnDef
Constraints []TableConstraint
PrimaryKey []KeyPart
Interleave *Interleave
RowDeletionPolicy *RowDeletionPolicy
Synonym ID // may be empty
Position Position // position of the "CREATE" token
}CreateTable represents a CREATE TABLE statement. https://cloud.google.com/spanner/docs/data-definition-language#create_table
func (*CreateTable) Pos
func (ct *CreateTable) Pos() Positionfunc (CreateTable) SQL
func (ct CreateTable) SQL() stringfunc (*CreateTable) String
func (ct *CreateTable) String() stringCreateView
type CreateView struct {
Name ID
OrReplace bool
SecurityType SecurityType
Query Query
Position Position // position of the "CREATE" token
}CreateView represents a CREATE [OR REPLACE] VIEW statement. https://cloud.google.com/spanner/docs/data-definition-language#view_statements
func (*CreateView) Pos
func (cv *CreateView) Pos() Positionfunc (CreateView) SQL
func (cv CreateView) SQL() stringfunc (*CreateView) String
func (cv *CreateView) String() stringDDL
type DDL struct {
List []DDLStmt
Filename string // if known at parse time
Comments []*Comment // all comments, sorted by position
}DDL represents a Data Definition Language (DDL) file.
func ParseDDL
ParseDDL parses a DDL file.
The provided filename is used for error reporting and will appear in the returned structure.
func (*DDL) InlineComment
InlineComment returns the comment on the same line as a node, or nil if there's no inline comment. The returned comment is guaranteed to be a single line.
func (*DDL) LeadingComment
LeadingComment returns the comment that immediately precedes a node, or nil if there's no such comment.
DDLStmt
DDLStmt is satisfied by a type that can appear in a DDL.
func ParseDDLStmt
ParseDDLStmt parses a single DDL statement.
DML
type DML struct {
List []DMLStmt
Filename string // if known at parse time
Comments []*Comment // all comments, sorted by position
}DML represents a Data Manipulation Language (DML) file.
func ParseDML
ParseDML parses a DML file.
The provided filename is used for error reporting and will appear in the returned structure.
func (*DML) InlineComment
InlineComment returns the comment on the same line as a node, or nil if there's no inline comment. The returned comment is guaranteed to be a single line.
func (*DML) LeadingComment
LeadingComment returns the comment that immediately precedes a node, or nil if there's no such comment.
DMLStmt
type DMLStmt interface {
SQL() string
// contains filtered or unexported methods
}DMLStmt is satisfied by a type that is a DML statement.
func ParseDMLStmt
ParseDMLStmt parses a single DML statement.
DatabaseAlteration
type DatabaseAlteration interface {
SQL() string
// contains filtered or unexported methods
}DatabaseOptions
type DatabaseOptions struct {
OptimizerVersion *int
OptimizerStatisticsPackage *string
VersionRetentionPeriod *string
EnableKeyVisualizer *bool
DefaultLeader *string
}DatabaseOptions represents options on a database as part of a ALTER DATABASE statement.
func (DatabaseOptions) SQL
func (do DatabaseOptions) SQL() stringDateLiteral
DateLiteral represents a date literal. https://cloud.google.com/spanner/docs/lexical#date_literals
func (DateLiteral) SQL
func (dl DateLiteral) SQL() stringDelete
Delete represents a DELETE statement. https://cloud.google.com/spanner/docs/dml-syntax#delete-statement
func (*Delete) SQL
func (*Delete) String
DropChangeStream
DropChangeStream represents a DROP CHANGE STREAM statement.
func (*DropChangeStream) Pos
func (dc *DropChangeStream) Pos() Positionfunc (DropChangeStream) SQL
func (dc DropChangeStream) SQL() stringfunc (*DropChangeStream) String
func (dc *DropChangeStream) String() stringDropChangeStreamWatch
type DropChangeStreamWatch struct{}func (DropChangeStreamWatch) SQL
func (dcsw DropChangeStreamWatch) SQL() stringDropColumn
type DropColumn struct{ Name ID }func (DropColumn) SQL
func (dc DropColumn) SQL() stringDropConstraint
type DropConstraint struct{ Name ID }func (DropConstraint) SQL
func (dc DropConstraint) SQL() stringDropDefault
type DropDefault struct{}func (DropDefault) SQL
func (dp DropDefault) SQL() stringDropIndex
DropIndex represents a DROP INDEX statement. https://cloud.google.com/spanner/docs/data-definition-language#drop-index
func (*DropIndex) Pos
func (DropIndex) SQL
func (*DropIndex) String
DropProtoBundle
type DropProtoBundle struct {
Position Position
}DropProtoBundle represents a DROP PROTO BUNDLE statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#drop-proto-bundle
func (*DropProtoBundle) Pos
func (dp *DropProtoBundle) Pos() Positionfunc (DropProtoBundle) SQL
func (do DropProtoBundle) SQL() stringfunc (*DropProtoBundle) String
func (dp *DropProtoBundle) String() stringDropRole
DropRole represents a DROP ROLE statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#drop_role
func (*DropRole) Pos
func (DropRole) SQL
func (*DropRole) String
DropRowDeletionPolicy
type DropRowDeletionPolicy struct{}func (DropRowDeletionPolicy) SQL
func (drdp DropRowDeletionPolicy) SQL() stringDropSequence
DropSequence represents a DROP SEQUENCE statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#drop-sequence
func (*DropSequence) Pos
func (ds *DropSequence) Pos() Positionfunc (DropSequence) SQL
func (do DropSequence) SQL() stringfunc (*DropSequence) String
func (ds *DropSequence) String() stringDropStoredColumn
type DropStoredColumn struct{ Name ID }func (DropStoredColumn) SQL
func (dsc DropStoredColumn) SQL() stringDropSynonym
type DropSynonym struct{ Name ID }func (DropSynonym) SQL
func (ds DropSynonym) SQL() stringDropTable
DropTable represents a DROP TABLE statement. https://cloud.google.com/spanner/docs/data-definition-language#drop_table
func (*DropTable) Pos
func (DropTable) SQL
func (*DropTable) String
DropView
DropView represents a DROP VIEW statement. https://cloud.google.com/spanner/docs/data-definition-language#drop-view
func (*DropView) Pos
func (DropView) SQL
func (*DropView) String
Expr
type Expr interface {
SQL() string
// contains filtered or unexported methods
}ExtractExpr
func (ExtractExpr) SQL
func (ee ExtractExpr) SQL() stringFloatLiteral
type FloatLiteral float64FloatLiteral represents a floating point literal. https://cloud.google.com/spanner/docs/lexical#floating-point-literals
func (FloatLiteral) SQL
func (fl FloatLiteral) SQL() stringForeignKey
type ForeignKey struct {
Columns []ID
RefTable ID
RefColumns []ID
OnDelete OnDelete
Position Position // position of the "FOREIGN" token
}ForeignKey represents a foreign key definition as part of a CREATE TABLE or ALTER TABLE statement.
func (ForeignKey) Pos
func (fk ForeignKey) Pos() Positionfunc (ForeignKey) SQL
func (fk ForeignKey) SQL() stringFunc
type Func struct {
Name string // not ID
Args []Expr
Distinct bool
NullsHandling NullsHandling
Having *AggregateHaving
}Func represents a function call.
func (Func) SQL
GrantRole
type GrantRole struct {
ToRoleNames []ID
GrantRoleNames []ID
Privileges []Privilege
TableNames []ID
TvfNames []ID
ViewNames []ID
ChangeStreamNames []ID
Position Position // position of the "GRANT" token
}GrantRole represents a GRANT statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#grant_statement
func (*GrantRole) Pos
func (GrantRole) SQL
func (*GrantRole) String
ID
type ID stringID represents an identifier. https://cloud.google.com/spanner/docs/lexical#identifiers
func (ID) SQL
If
func (If) SQL
IfNull
func (IfNull) SQL
InOp
func (InOp) SQL
IndexAlteration
type IndexAlteration interface {
SQL() string
// contains filtered or unexported methods
}Insert
type Insert struct {
Table ID
Columns []ID
Input ValuesOrSelect
}Insert represents an INSERT statement. https://cloud.google.com/spanner/docs/dml-syntax#insert-statement
func (*Insert) SQL
func (*Insert) String
IntegerLiteral
type IntegerLiteral int64IntegerLiteral represents an integer literal. https://cloud.google.com/spanner/docs/lexical#integer-literals
func (IntegerLiteral) SQL
func (il IntegerLiteral) SQL() stringInterleave
Interleave represents an interleave clause of a CREATE TABLE statement.
IntervalExpr
func (IntervalExpr) SQL
func (ie IntervalExpr) SQL() stringIsExpr
type IsExpr interface {
Expr
// contains filtered or unexported methods
}IsOp
func (IsOp) SQL
JSONLiteral
type JSONLiteral []byteJSONLiteral represents a JSON literal https://cloud.google.com/spanner/docs/reference/standard-sql/lexical#json_literals
func (JSONLiteral) SQL
func (jl JSONLiteral) SQL() stringJoinType
type JoinType intInnerJoin, CrossJoin, FullJoin, LeftJoin, RightJoin
KeyPart
KeyPart represents a column specification as part of a primary key or index definition.
func (KeyPart) SQL
LiteralOrParam
type LiteralOrParam interface {
SQL() string
// contains filtered or unexported methods
}LiteralOrParam is implemented by integer literal and parameter values.
LogicalOp
type LogicalOp struct {
Op LogicalOperator
LHS, RHS BoolExpr // only RHS is set for Not
}func (LogicalOp) SQL
LogicalOperator
type LogicalOperator intAnd, Or, Not
const (
And LogicalOperator = iota
Or
Not
)Node
type Node interface {
Pos() Position
}Node is implemented by concrete types in this package that represent things appearing in a DDL file.
NullIf
func (NullIf) SQL
NullLiteral
type NullLiteral intfunc (NullLiteral) SQL
func (NullLiteral) SQL() stringNullsHandling
type NullsHandling intNullsHandling represents the method of dealing with NULL values in aggregate functions.
NullsHandlingUnspecified, RespectNulls, IgnoreNulls
const (
NullsHandlingUnspecified NullsHandling = iota
RespectNulls
IgnoreNulls
)OnDelete
type OnDelete intNoActionOnDelete, CascadeOnDelete
func (OnDelete) SQL
Order
func (Order) SQL
Param
type Param stringParam represents a query parameter.
func (Param) SQL
Paren
type Paren struct {
Expr Expr
}Paren represents a parenthesised expression.
func (Paren) SQL
PathExp
type PathExp []IDPathExp represents a path expression.
The grammar for path expressions is not defined (see b/169017423 internally), so this captures the most common form only, namely a dotted sequence of identifiers.
func (PathExp) SQL
Position
Position describes a source position in an input DDL file. It is only valid if the line number is positive.
func (Position) IsValid
func (Position) String
Privilege
type Privilege struct {
Type PrivilegeType
Columns []ID
}Privilege represents privilege to grant or revoke.
PrivilegeType
type PrivilegeType intPrivilegeTypeSelect, PrivilegeTypeInsert, PrivilegeTypeUpdate, PrivilegeTypeDelete
const (
PrivilegeTypeSelect PrivilegeType = iota
PrivilegeTypeInsert
PrivilegeTypeUpdate
PrivilegeTypeDelete
)func (PrivilegeType) SQL
func (pt PrivilegeType) SQL() stringQuery
type Query struct {
Select Select
Order []Order
Limit, Offset LiteralOrParam
}Query represents a query statement. https://cloud.google.com/spanner/docs/query-syntax#sql-syntax
func ParseQuery
ParseQuery parses a query string.
func (Query) SQL
RenameTable
type RenameTable struct {
TableRenameOps []TableRenameOp
Position Position // position of the "RENAME" token
}RenameTable represents a RENAME TABLE statement.
func (*RenameTable) Pos
func (rt *RenameTable) Pos() Positionfunc (RenameTable) SQL
func (rt RenameTable) SQL() stringfunc (*RenameTable) String
func (rt *RenameTable) String() stringRenameTo
func (RenameTo) SQL
ReplaceRowDeletionPolicy
type ReplaceRowDeletionPolicy struct{ RowDeletionPolicy RowDeletionPolicy }func (ReplaceRowDeletionPolicy) SQL
func (rrdp ReplaceRowDeletionPolicy) SQL() stringRevokeRole
type RevokeRole struct {
FromRoleNames []ID
RevokeRoleNames []ID
Privileges []Privilege
TableNames []ID
TvfNames []ID
ViewNames []ID
ChangeStreamNames []ID
Position Position // position of the "REVOKE" token
}RevokeRole represents a REVOKE statement. https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#revoke_statement
func (*RevokeRole) Pos
func (rr *RevokeRole) Pos() Positionfunc (RevokeRole) SQL
func (rr RevokeRole) SQL() stringfunc (*RevokeRole) String
func (rr *RevokeRole) String() stringRowDeletionPolicy
RowDeletionPolicy represents an row deletion policy clause of a CREATE, ALTER TABLE statement.
func (RowDeletionPolicy) SQL
func (rdp RowDeletionPolicy) SQL() stringSecurityType
type SecurityType intInvoker, Definer
const (
Invoker SecurityType = iota
Definer
)func (SecurityType) SQL
func (st SecurityType) SQL() stringSelect
type Select struct {
Distinct bool
List []Expr
From []SelectFrom
Where BoolExpr
GroupBy []Expr
// When the FROM clause has TABLESAMPLE operators,
// TableSamples will be populated 1:1 with From;
// FROM clauses without will have a nil value.
TableSamples []*TableSample
// If the SELECT list has explicit aliases ("AS alias"),
// ListAliases will be populated 1:1 with List;
// aliases that are present will be non-empty.
ListAliases []ID
}Select represents a SELECT statement. https://cloud.google.com/spanner/docs/query-syntax#select-list
func (Select) SQL
SelectFrom
type SelectFrom interface {
SQL() string
// contains filtered or unexported methods
}SelectFrom represents the FROM clause of a SELECT. https://cloud.google.com/spanner/docs/query-syntax#from_clause
SelectFromJoin
type SelectFromJoin struct {
Type JoinType
LHS, RHS SelectFrom
// Join condition.
// At most one of {On,Using} may be set.
On BoolExpr
Using []ID
// Hints are suggestions for how to evaluate a join.
// https://cloud.google.com/spanner/docs/query-syntax#join-hints
Hints map[string]string
}SelectFromJoin is a SelectFrom that joins two other SelectFroms. https://cloud.google.com/spanner/docs/query-syntax#join_types
func (SelectFromJoin) SQL
func (sfj SelectFromJoin) SQL() stringSelectFromTable
SelectFromTable is a SelectFrom that specifies a table to read from.
func (SelectFromTable) SQL
func (sft SelectFromTable) SQL() stringSelectFromUnnest
SelectFromUnnest is a SelectFrom that yields a virtual table from an array. https://cloud.google.com/spanner/docs/query-syntax#unnest
func (SelectFromUnnest) SQL
func (sfu SelectFromUnnest) SQL() stringSequenceAlteration
type SequenceAlteration interface {
SQL() string
// contains filtered or unexported methods
}SequenceExpr
type SequenceExpr struct {
Name ID
}func (SequenceExpr) SQL
func (se SequenceExpr) SQL() stringSequenceOptions
type SequenceOptions struct {
SequenceKind *string
SkipRangeMin *int
SkipRangeMax *int
StartWithCounter *int
}SequenceOptions represents options on a sequence as part of a CREATE SEQUENCE and ALTER SEQUENCE statement.
func (SequenceOptions) SQL
func (so SequenceOptions) SQL() stringSetColumnOptions
type SetColumnOptions struct{ Options ColumnOptions }func (SetColumnOptions) SQL
func (sco SetColumnOptions) SQL() stringSetColumnType
func (SetColumnType) SQL
func (sct SetColumnType) SQL() stringSetDatabaseOptions
type SetDatabaseOptions struct{ Options DatabaseOptions }func (SetDatabaseOptions) SQL
func (sdo SetDatabaseOptions) SQL() stringSetDefault
type SetDefault struct {
Default Expr
}func (SetDefault) SQL
func (sd SetDefault) SQL() stringSetOnDelete
type SetOnDelete struct{ Action OnDelete }func (SetOnDelete) SQL
func (sod SetOnDelete) SQL() stringSetSequenceOptions
type SetSequenceOptions struct{ Options SequenceOptions }func (SetSequenceOptions) SQL
func (sa SetSequenceOptions) SQL() stringSetStatisticsOptions
type SetStatisticsOptions struct{ Options StatisticsOptions }func (SetStatisticsOptions) SQL
func (sso SetStatisticsOptions) SQL() stringStarExpr
type StarExpr intfunc (StarExpr) SQL
StatisticsAlteration
type StatisticsAlteration interface {
SQL() string
// contains filtered or unexported methods
}StatisticsOptions
type StatisticsOptions struct {
AllowGC *bool
}StatisticsOptions represents options on a statistics as part of a ALTER STATISTICS statement.
func (StatisticsOptions) SQL
func (sa StatisticsOptions) SQL() stringStringLiteral
type StringLiteral stringStringLiteral represents a string literal. https://cloud.google.com/spanner/docs/lexical#string-and-bytes-literals
func (StringLiteral) SQL
func (sl StringLiteral) SQL() stringTableAlteration
type TableAlteration interface {
SQL() string
// contains filtered or unexported methods
}TableAlteration is satisfied by AddColumn, DropColumn, AddConstraint, DropConstraint, SetOnDelete, AlterColumn, AddRowDeletionPolicy, ReplaceRowDeletionPolicy, DropRowDeletionPolicy, RenameTo, AddSynonym, and DropSynonym.
TableConstraint
type TableConstraint struct {
Name ID // may be empty
Constraint Constraint
Position Position // position of the "CONSTRAINT" token, or Constraint.Pos()
}TableConstraint represents a constraint on a table.
func (TableConstraint) Pos
func (tc TableConstraint) Pos() Positionfunc (TableConstraint) SQL
func (tc TableConstraint) SQL() stringTableRenameOp
TableSample
type TableSample struct {
Method TableSampleMethod
Size Expr
SizeType TableSampleSizeType
}TableSampleMethod
type TableSampleMethod intBernoulli, Reservoir
const (
Bernoulli TableSampleMethod = iota
Reservoir
)TableSampleSizeType
type TableSampleSizeType intPercentTableSample, RowsTableSample
const (
PercentTableSample TableSampleSizeType = iota
RowsTableSample
)TimestampLiteral
TimestampLiteral represents a timestamp literal. https://cloud.google.com/spanner/docs/lexical#timestamp_literals
func (TimestampLiteral) SQL
func (tl TimestampLiteral) SQL() stringType
type Type struct {
Array bool
Base TypeBase // Bool, Int64, Float64, Numeric, String, Bytes, Date, Timestamp
Len int64 // if Base is String or Bytes; may be MaxLen
// fully-qualified Protocol Buffer Message or Enum type-name (including
// leading dot-separated namespace)
// non-empty if Base is ProtoMessage or ProtoEnum
ProtoRef string
}Type represents a column type.
func (Type) SQL
TypeBase
type TypeBase intBool, Int64, Float64, Numeric, String, Bytes, Date, Timestamp, JSON, Proto, Enum
const (
Bool TypeBase = iota
Int64
Float64
Numeric
String
Bytes
Date
Timestamp
JSON
Proto
Enum // Enum used in CAST expressions
)func (TypeBase) SQL
TypedExpr
TypedExpr represents a typed expression in the form expr AS type_name, e.g. '17' AS INT64.
func (TypedExpr) SQL
Update
type Update struct {
Table ID
Items []UpdateItem
Where BoolExpr
}Update represents an UPDATE statement. https://cloud.google.com/spanner/docs/dml-syntax#update-statement
func (*Update) SQL
func (*Update) String
UpdateItem
Values
type Values [][]ExprValues represents one or more lists of expressions passed to an INSERT statement.
func (Values) SQL
func (Values) String
ValuesOrSelect
type ValuesOrSelect interface {
SQL() string
// contains filtered or unexported methods
}