Documentation
¶
Overview ¶
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
Index ¶
- Constants
- type AddColumn
- type AlterTable
- type BoolExpr
- type BoolLiteral
- type ColumnDef
- type ComparisonOp
- type ComparisonOperator
- type CreateIndex
- type CreateTable
- type DDL
- type DDLStmt
- type DropColumn
- type DropIndex
- type DropTable
- type Expr
- type FloatLiteral
- type Func
- type ID
- type IntegerLiteral
- type Interleave
- type IsExpr
- type IsOp
- type KeyPart
- type Limit
- type LogicalOp
- type LogicalOperator
- type NullLiteral
- type OnDelete
- type Order
- type Param
- type Paren
- type Query
- type Select
- type SelectFrom
- type SetOnDelete
- type StarExpr
- type StringLiteral
- type TableAlteration
- type TableSample
- type TableSampleMethod
- type TableSampleSizeType
- type Type
- type TypeBase
Constants ¶
const ( True = BoolLiteral(true) False = BoolLiteral(false) )
const MaxLen = math.MaxInt64
MaxLen is a sentinel for Type's Len field, representing the MAX value.
const Null = NullLiteral(0)
const Star = StarExpr(0)
Star represents a "*" in an expression.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlterTable ¶
type AlterTable struct {
Name string
Alteration TableAlteration
}
AlterTable represents an ALTER TABLE statement. https://cloud.google.com/spanner/docs/data-definition-language#alter_table
func (AlterTable) SQL ¶
func (at AlterTable) SQL() string
type ColumnDef ¶
ColumnDef represents a column definition as part of a CREATE TABLE or ALTER TABLE statement.
type ComparisonOp ¶
type ComparisonOp struct {
LHS, RHS Expr
Op ComparisonOperator
// RHS2 is the third operand for BETWEEN.
// "<LHS> BETWEEN <RHS> AND <RHS2>".
RHS2 Expr
}
func (ComparisonOp) SQL ¶
func (co ComparisonOp) SQL() string
type ComparisonOperator ¶
type ComparisonOperator int
const ( Lt ComparisonOperator = iota Le Gt Ge Eq Ne // both "!=" and "<>" Like NotLike Between NotBetween )
type CreateIndex ¶
type CreateIndex struct {
Name string
Table string
Columns []KeyPart
Unique bool
NullFiltered bool
Storing []string
Interleave string
}
CreateIndex represents a CREATE INDEX statement. https://cloud.google.com/spanner/docs/data-definition-language#create-index
func (CreateIndex) SQL ¶
func (ci CreateIndex) SQL() string
type CreateTable ¶
type CreateTable struct {
Name string
Columns []ColumnDef
PrimaryKey []KeyPart
Interleave *Interleave
}
CreateTable represents a CREATE TABLE statement. https://cloud.google.com/spanner/docs/data-definition-language#create_table
func (CreateTable) SQL ¶
func (ct CreateTable) SQL() string
type DDLStmt ¶
type DDLStmt interface {
SQL() string
// contains filtered or unexported methods
}
DDLStmt is satisfied by a type that can appear in a DDL.
func ParseDDLStmt ¶
ParseDDLStmt parses a single DDL statement.
type DropColumn ¶
type DropColumn struct{ Name string }
func (DropColumn) SQL ¶
func (dc DropColumn) SQL() string
type DropIndex ¶
type DropIndex struct{ Name string }
DropIndex represents a DROP INDEX statement. https://cloud.google.com/spanner/docs/data-definition-language#drop-index
type DropTable ¶
type DropTable struct{ Name string }
DropTable represents a DROP TABLE statement. https://cloud.google.com/spanner/docs/data-definition-language#drop_table
type FloatLiteral ¶
type FloatLiteral float64
FloatLiteral represents a floating point literal. https://cloud.google.com/spanner/docs/lexical#floating-point-literals
func (FloatLiteral) SQL ¶
func (fl FloatLiteral) SQL() string
type IntegerLiteral ¶
type IntegerLiteral int64
IntegerLiteral represents an integer literal. https://cloud.google.com/spanner/docs/lexical#integer-literals
func (IntegerLiteral) SQL ¶
func (il IntegerLiteral) SQL() string
type Interleave ¶
Interleave represents an interleave clause of a CREATE TABLE statement.
type KeyPart ¶
KeyPart represents a column specification as part of a primary key or index definition.
type LogicalOp ¶
type LogicalOp struct {
Op LogicalOperator
LHS, RHS BoolExpr // only RHS is set for Not
}
type Query ¶
Query represents a query statement. https://cloud.google.com/spanner/docs/query-syntax#sql-syntax
type Select ¶
type Select struct {
List []Expr
From []SelectFrom
Where BoolExpr
}
Select represents a SELECT statement. https://cloud.google.com/spanner/docs/query-syntax#select-list
type SelectFrom ¶
type SelectFrom struct {
// This only supports a FROM clause directly from a table.
Table string
TableSample *TableSample
}
type SetOnDelete ¶
type SetOnDelete struct{ Action OnDelete }
func (SetOnDelete) SQL ¶
func (sod SetOnDelete) SQL() string
type StringLiteral ¶
type StringLiteral string
StringLiteral represents a string literal. https://cloud.google.com/spanner/docs/lexical#string-and-bytes-literals
func (StringLiteral) SQL ¶
func (sl StringLiteral) SQL() string
type TableAlteration ¶
type TableAlteration interface {
SQL() string
// contains filtered or unexported methods
}
TableAlteration is satisfied by AddColumn, DropColumn and SetOnDelete.
type TableSample ¶
type TableSample struct {
Method TableSampleMethod
Size Expr
SizeType TableSampleSizeType
}
type TableSampleMethod ¶
type TableSampleMethod int
const ( Bernoulli TableSampleMethod = iota Reservoir )
type TableSampleSizeType ¶
type TableSampleSizeType int
const ( PercentTableSample TableSampleSizeType = iota RowsTableSample )