translator

package
v0.0.0-...-c3ef3ee Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ANDNode

type ANDNode struct {
	Lexpr ExpressionNode
	Rexpr ExpressionNode
}

ANDNode is expression of AND

func (ANDNode) Eval

func (andn ANDNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates ANDNode

type BinOpNode

type BinOpNode struct {
	Op    MathOp
	Lexpr ExpressionNode
	Rexpr ExpressionNode
}

BinOpNode is expression of BinOpNode

func (BinOpNode) Eval

func (e BinOpNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates BinOpNode

type BoolConstNode

type BoolConstNode struct {
	Bool core.BoolType
}

BoolConstNode is expression of boolean const

func (BoolConstNode) Eval

func (b BoolConstNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates BoolConstNode

type CaseNode

type CaseNode struct {
	CaseWhenExprs   []ExpressionNode
	CaseResultExprs []ExpressionNode
	DefaultResult   ExpressionNode
}

CaseNode is expression of CaseNode

func (*CaseNode) Eval

func (c *CaseNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates CaseNode

type ColRefNode

type ColRefNode struct {
	ColName core.ColumnName
}

ColRefNode is expression of integer

func (ColRefNode) Eval

func (n ColRefNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates ColRefNode

type ColWildcardNode

type ColWildcardNode struct{}

ColWildcardNode is expression of integer

func (ColWildcardNode) Eval

func (n ColWildcardNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates ColWildcardNode

type CreateTableNode

type CreateTableNode struct {
	TableName  string
	ColumnDefs core.Cols
}

CreateTableNode is a node of create statement

func (*CreateTableNode) Eval

func (c *CreateTableNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates CreateTableNode

type CrossJoinNode

type CrossJoinNode struct {
	RANodes []RelationalAlgebraNode
}

CrossJoinNode is a node of cross join.

func (*CrossJoinNode) Eval

func (c *CrossJoinNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates CrossJoinNode

type DeleteNode

type DeleteNode struct {
	Condition ExpressionNode
	TableName string
}

DeleteNode is a node of update statement

func (*DeleteNode) Eval

func (d *DeleteNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates DeleteNode

type DropTableNode

type DropTableNode struct {
	TableNames []string
}

DropTableNode is a node of drop statement

func (*DropTableNode) Eval

func (d *DropTableNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates DropTableNode

type EmptyTable

type EmptyTable struct {
	ColNames core.ColumnNames
	Rows     []*EmptyTableRow
}

func (*EmptyTable) Copy

func (t *EmptyTable) Copy() backend.Table

func (*EmptyTable) CrossJoin

func (t *EmptyTable) CrossJoin(backend.Table) (backend.Table, error)

func (*EmptyTable) Delete

func (t *EmptyTable) Delete(func(backend.Row) (core.Value, error)) (backend.Table, error)

func (*EmptyTable) GetColNames

func (t *EmptyTable) GetColNames() core.ColumnNames

func (*EmptyTable) GetCols

func (t *EmptyTable) GetCols() core.Cols

func (*EmptyTable) GetName

func (t *EmptyTable) GetName() string

func (*EmptyTable) GetRows

func (t *EmptyTable) GetRows() []backend.Row

func (*EmptyTable) InsertValues

func (t *EmptyTable) InsertValues(cs core.ColumnNames, vs core.ValuesList) error

func (*EmptyTable) Limit

func (t *EmptyTable) Limit(n int) (backend.Table, error)

func (*EmptyTable) OrderBy

func (t *EmptyTable) OrderBy(ns core.ColumnNames, dirs []int) (backend.Table, error)

func (*EmptyTable) Project

func (t *EmptyTable) Project(cs core.ColumnNames, fns []func(backend.Row) (core.Value, error)) (backend.Table, error)

func (*EmptyTable) RenameTableName

func (t *EmptyTable) RenameTableName(name string)

func (*EmptyTable) Update

func (t *EmptyTable) Update(colNames core.ColumnNames, condFn func(backend.Row) (core.Value, error), assignValFns []func(backend.Row) (core.Value, error)) (backend.Table, error)

func (*EmptyTable) Where

func (t *EmptyTable) Where(fn func(backend.Row) (core.Value, error)) (backend.Table, error)

type EmptyTableRow

type EmptyTableRow struct {
	ColNames core.ColumnNames
	Values   core.Values
}

func (*EmptyTableRow) GetColNames

func (r *EmptyTableRow) GetColNames() core.ColumnNames

func (*EmptyTableRow) GetValueByColName

func (r *EmptyTableRow) GetValueByColName(core.ColumnName) (core.Value, error)

func (*EmptyTableRow) GetValues

func (r *EmptyTableRow) GetValues() core.Values

func (*EmptyTableRow) UpdateValue

func (r *EmptyTableRow) UpdateValue(name core.ColumnName, val core.Value)

type ExpressionNode

type ExpressionNode interface {
	Eval() func(row backend.Row) (core.Value, error)
}

ExpressionNode is interface of boolean expression

type FloatNode

type FloatNode struct {
	Val float64
}

FloatNode is expression of integer

func (FloatNode) Eval

func (f FloatNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates FloatNode

type InsertNode

type InsertNode struct {
	TableName   string
	ColumnNames core.ColumnNames
	ValuesList  core.ValuesList
}

InsertNode is a node of create statement

func (*InsertNode) Eval

func (c *InsertNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates CreateTableNode

type IntegerNode

type IntegerNode struct {
	Val int
}

IntegerNode is expression of integer

func (IntegerNode) Eval

func (i IntegerNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates IntegerNode

type LimitNode

type LimitNode struct {
	Count  int
	RANode RelationalAlgebraNode
}

LimitNode is a Node for limit clause

func (*LimitNode) Eval

func (l *LimitNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates LimitNode

type MathOp

type MathOp int

MathOp express SQL mathemathical operators

const (
	// EqualOp is equal operator
	EqualOp MathOp = iota

	// NotEqualOp is not equal operator
	NotEqualOp
	Plus
	Minus
	Multiply
	Divide
	GT
	LT
	GEQ
	LEQ
	CONCAT
)

ref: translator/expression.go: func (e BinOpNode) Eval() ref: translator/postgres.go: func mathOperator()

type NotNode

type NotNode struct {
	Expr ExpressionNode
}

NotNode is expression of Not

func (NotNode) Eval

func (nn NotNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates NotNode

type NullTestNode

type NullTestNode struct {
	TestType NullTestType
	Expr     ExpressionNode
}

NullTestNode is expression of `IS (NOT) NULL`

func (NullTestNode) Eval

func (n NullTestNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates NullTestNode

type NullTestType

type NullTestType int

NullTestType is Null test type

const (
	// EqualNull corresponds to `IS NULL` operation
	EqualNull NullTestType = iota

	// NotEqualNull corresponds to `IS NOT NULL` operation
	NotEqualNull
)

type ORNode

type ORNode struct {
	Lexpr ExpressionNode
	Rexpr ExpressionNode
}

ORNode is expression of OR

func (ORNode) Eval

func (orn ORNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates ORNode

type OrderByNode

type OrderByNode struct {
	SortKeys core.ColumnNames
	SortDirs []int
	RANode   RelationalAlgebraNode
}

OrderByNode is a Node for order by clause

func (*OrderByNode) Eval

func (o *OrderByNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates OrderByNode

type PGTranlator

type PGTranlator struct {
	// contains filtered or unexported fields
}

PGTranlator is translator for PostgreSQL syntax

func NewPGTranslator

func NewPGTranslator(query string) *PGTranlator

NewPGTranslator is a constructor of PGTranlator

func (*PGTranlator) Translate

func (pg *PGTranlator) Translate() (Statement, error)

Translate translates a postgres parse tree into RelationalAlgebraNode

func (*PGTranlator) TranslateCreateTable

func (pg *PGTranlator) TranslateCreateTable(stmt *pg_query.CreateStmt) (RelationalAlgebraNode, error)

TranslateCreateTable translates sql parse tree into CreateTableNode

func (*PGTranlator) TranslateDelete

func (pg *PGTranlator) TranslateDelete(node *pg_query.DeleteStmt) (RelationalAlgebraNode, error)

TranslateDelete translates sql parse tree into DeleteNode

func (*PGTranlator) TranslateDropTable

func (pg *PGTranlator) TranslateDropTable(node *pg_query.DropStmt) (RelationalAlgebraNode, error)

TranslateDropTable translates sql parse tree into DropTableNode

func (*PGTranlator) TranslateInsert

func (pg *PGTranlator) TranslateInsert(stmt *pg_query.InsertStmt) (RelationalAlgebraNode, error)

TranslateInsert translates sql parse tree into InsertNode

func (*PGTranlator) TranslateSelect

func (pg *PGTranlator) TranslateSelect(pgtree *pg_query.SelectStmt) (RelationalAlgebraNode, error)

TranslateSelect translates postgres a select statement into ProjectionNode

func (*PGTranlator) TranslateUpdate

func (pg *PGTranlator) TranslateUpdate(node *pg_query.UpdateStmt) (RelationalAlgebraNode, error)

TranslateUpdate translates sql parse tree into UpdateNode

type ProjectionNode

type ProjectionNode struct {
	ResTargets     []ExpressionNode
	TargetColNames core.ColumnNames
	RANode         RelationalAlgebraNode
}

ProjectionNode is Node of projection operation

func (*ProjectionNode) Eval

func (p *ProjectionNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates ProjectionNode

type QueryResult

type QueryResult struct {
	Columns []string
	Records core.ValuesList
}

QueryResult is result of query

func (*QueryResult) GetColumns

func (qr *QueryResult) GetColumns() []string

GetColumns gets column name of records

func (*QueryResult) GetRecords

func (qr *QueryResult) GetRecords() core.ValuesList

GetRecords gets records from query result

type QueryStatement

type QueryStatement struct {
	RANode RelationalAlgebraNode
}

QueryStatement is statement of query

func (*QueryStatement) Eval

func (qs *QueryStatement) Eval(db backend.DB) (Result, error)

Eval evaluates QueryStatement

type RelationalAlgebraNode

type RelationalAlgebraNode interface {
	Eval(backend.DB) (backend.Table, error)
}

RelationalAlgebraNode is interface of RelationalAlgebraNode

type RenameTableNode

type RenameTableNode struct {
	Alias string
	Table RelationalAlgebraNode
}

RenameTableNode is Node for renaming tabel

func (*RenameTableNode) Eval

func (rt *RenameTableNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates RenameTableNode

type Result

type Result interface {
	GetRecords() core.ValuesList
	GetColumns() []string
}

Result is interface of query result

type Statement

type Statement interface {
	Eval(backend.DB) (Result, error)
}

Statement is interface of query statement

type StringNode

type StringNode struct {
	Val string
}

StringNode is expression of integer

func (StringNode) Eval

func (s StringNode) Eval() func(backend.Row) (core.Value, error)

Eval evaluates StringNode

type TableNode

type TableNode struct {
	TableName string
}

TableNode is Node of table

func (*TableNode) Eval

func (t *TableNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates TableNode

type Translator

type Translator interface {
	Translate() RelationalAlgebraNode
}

Translator is an interface for translator of SQL parse

type UpdateNode

type UpdateNode struct {
	Condition  ExpressionNode
	ColNames   core.ColumnNames
	AssignExpr []ExpressionNode
	TableName  string
}

UpdateNode is a node of update statement

func (*UpdateNode) Eval

func (u *UpdateNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluates UpdateNode

type WhereNode

type WhereNode struct {
	Condition ExpressionNode
	Table     RelationalAlgebraNode
}

WhereNode is Node of where clause

func (*WhereNode) Eval

func (wn *WhereNode) Eval(db backend.DB) (backend.Table, error)

Eval evaluate WhereNode

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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