parser

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package parser contains the command parser.

Index

Constants

View Source
const DefaultFSP = 0

DefaultFSP is the default fractional seconds precision for a TIMESTAMP field.

Variables

This section is empty.

Functions

This section is empty.

Types

type AST

type AST struct {
	Select           string            // Unaltered SELECT statement, if any.
	Use              string            `(  "USE" @Ident`
	Drop             *Drop             ` | "DROP" @@ `
	Create           *Create           ` | "CREATE" @@ `
	Show             *Show             ` | "SHOW" @@ `
	Describe         string            ` | "DESCRIBE" @Ident `
	SourceSetMaxRate *SourceSetMaxRate ` | "SOURCE" "SET" "MAX" "RATE" @@ `
	ResetDdl         string            ` | "RESET" "DDL" @Ident ) ';'?`
}

AST root.

func Parse

func Parse(sql string) (*AST, error)

Parse an SQL statement.

type Boolean added in v0.1.6

type Boolean bool

func (*Boolean) Capture added in v0.1.6

func (b *Boolean) Capture(values []string) error

type ColSelector

type ColSelector struct {
	Selector string `@String`
}

type ColumnDef

type ColumnDef struct {
	Pos lexer.Position

	Name string `@Ident`

	Type       common.Type `@(("VARCHAR"|"TINYINT"|"INT"|"BIGINT"|"TIMESTAMP"|"DOUBLE"|"DECIMAL"))` // Conversion done by common.Type.Capture()
	Parameters []int       `("(" @Number ("," @Number)* ")")?`                                      // Optional parameters to the type(x [, x, ...])
}

func (*ColumnDef) ToColumnType

func (c *ColumnDef) ToColumnType() (common.ColumnType, error)

type ColumnName

type ColumnName struct {
	Name string `@Ident`
}

type Create

type Create struct {
	MaterializedView *CreateMaterializedView `  "MATERIALIZED" "VIEW" @@`
	Source           *CreateSource           `| "SOURCE" @@`
	Index            *CreateIndex            `| "INDEX" @@`
}

Create statement.

type CreateIndex

type CreateIndex struct {
	Name        string        `@Ident "ON"`
	TableName   string        `@Ident`
	ColumnNames []*ColumnName `"(" @@ ("," @@)* ")"`
}

type CreateMaterializedView

type CreateMaterializedView struct {
	Name              *Ref                                 `@@`
	OriginInformation []*MaterializedViewOriginInformation `("WITH" "(" @@ ("," @@)* ")")?`
	Query             *RawQuery                            `"AS" @@`
}

CreateMaterializedView statement.

type CreateSource

type CreateSource struct {
	Name              string                     `@Ident`
	Options           []*TableOption             `"(" @@ ("," @@)* ")"` // Table options.
	OriginInformation []*SourceOriginInformation `"WITH" "(" @@ ("," @@)* ")"`
}

type Drop

type Drop struct {
	MaterializedView bool   `(   @"MATERIALIZED" "VIEW"`
	Source           bool   `  | @"SOURCE"`
	Index            bool   `  | @"INDEX" )`
	Name             string `@Ident `
	TableName        string `("ON" @Ident)?`
}

Drop statement

type MaterializedViewOriginInformation added in v0.1.1

type MaterializedViewOriginInformation struct {
	InitialState string `"InitialState" "=" @String`
}

type RawQuery

type RawQuery struct {
	Tokens []lexer.Token
	Query  []string `(!";")+`
}

RawQuery represents raw SQL that can be passed through directly.

func (*RawQuery) String

func (r *RawQuery) String() string

type Ref

type Ref struct {
	Path []string `@Ident ("." @Ident)*`
}

A Ref to a view, table, column, etc.

func (*Ref) String

func (r *Ref) String() string

type Show

type Show struct {
	Tables    bool   `(  @"TABLES"`
	Schemas   bool   `| @"SCHEMAS"`
	Indexes   bool   `| @"INDEXES" )`
	TableName string `("ON" @Ident)?`
}

Show statement

type SourceOriginInformation added in v0.1.1

type SourceOriginInformation struct {
	BrokerName     string                        `"BrokerName" "=" @String`
	TopicName      string                        `|"TopicName" "=" @String`
	HeaderEncoding string                        `|"HeaderEncoding" "=" @String`
	KeyEncoding    string                        `|"KeyEncoding" "=" @String`
	ValueEncoding  string                        `|"ValueEncoding" "=" @String`
	IngestFilter   string                        `|"IngestFilter" "=" @String`
	InitialState   string                        `|"InitialState" "=" @String`
	Transient      *Boolean                      `|"Transient" "=" @Ident`
	ColSelectors   []*selector.ColumnSelectorAST `|"ColumnSelectors" "=" "(" (@@ ("," @@)*)? ")"`
	Properties     []*TopicInfoProperty          `|"Properties" "=" "(" (@@ ("," @@)*)? ")"`
}

type SourceSetMaxRate added in v0.1.6

type SourceSetMaxRate struct {
	SourceName string `@Ident`
	Rate       int64  `@Number`
}

type TableOption

type TableOption struct {
	PrimaryKey []string   `  "PRIMARY" "KEY" "(" @Ident ( "," @Ident )* ")"`
	Column     *ColumnDef `| @@`
}

type TopicInfoProperty

type TopicInfoProperty struct {
	Key   string `@String "="`
	Value string `@String`
}

Directories

Path Synopsis
Package selector contains a selector library for JSON and Protobuf.
Package selector contains a selector library for JSON and Protobuf.

Jump to

Keyboard shortcuts

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