sql

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2017 License: MIT Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BigInteger = bigIntegerType{}
View Source
var ErrInvalidType = errors.New("invalid type")
View Source
var Integer = integerType{}
View Source
var Null = nullType{}
View Source
var String = stringType{}
View Source
var TimestampWithTimezone = timestampWithTimeZoneType{}

TimestampWithTimezone is a timestamp with timezone.

Functions

This section is empty.

Types

type Aggregation

type Aggregation interface {
	Update(Row) (Row, error)
	Merge(Row)
	Eval() interface{}
}

type AggregationExpression

type AggregationExpression interface {
	Expression
	// NewBuffer creates a new aggregation buffer and returns it as a Row.
	NewBuffer() Row
	// Update updates the given buffer with the given row.
	Update(buffer, row Row)
	// Merge merges a partial buffer into a global one.
	Merge(buffer, partial Row)
}

AggregationExpression implements an aggregation expression, where an aggregation buffer is created for each grouping (NewBuffer) and rows in the grouping are fed to the buffer (Update). Multiple buffers can be merged (Merge), making partial aggregations possible. Note that Eval must be called with the final aggregation buffer in order to get the final result.

type Catalog

type Catalog struct {
	Databases
	FunctionRegistry
}

Catalog holds databases, tables and functions.

func NewCatalog

func NewCatalog() *Catalog

NewCatalog returns a new empty Catalog.

type Column

type Column struct {
	// Name is the name of the column.
	Name string
	// Type is the data type of the column.
	Type Type
	// Default contains the default value of the column or nil if it is NULL.
	Default interface{}
	// Nullable is true if the column can contain NULL values, or false
	// otherwise.
	Nullable bool
}

Column is the definition of a table column. As SQL:2016 puts it:

A column is a named component of a table. It has a data type, a default,
and a nullability characteristic.

func (*Column) Check added in v0.7.0

func (c *Column) Check(v interface{}) bool

type Database

type Database interface {
	Nameable
	Tables() map[string]Table
}

type Databases

type Databases []Database

Databases is a collection of Database.

func (Databases) Database

func (d Databases) Database(name string) (Database, error)

Database returns the Database with the given name if it exists.

func (Databases) Table

func (d Databases) Table(dbName string, tableName string) (Table, error)

Table returns the Table with the given name if it exists.

type Expression

type Expression interface {
	Resolvable
	Type() Type
	Name() string
	IsNullable() bool
	Eval(Row) interface{}
	TransformUp(func(Expression) Expression) Expression
}

type ExpressionBuilder

type ExpressionBuilder interface {
	Build(...Expression) (Expression, error)
}

ExpressionBuilder can build an Expression out of a given list of expressions.

type FunctionRegistry

type FunctionRegistry map[string]ExpressionBuilder

FunctionRegistry is used to register functions. It is used both for builtin and User-Defined Functions.

func NewFunctionRegistry

func NewFunctionRegistry() FunctionRegistry

NewFunctionRegistry creates a new FunctionRegistry.

func (FunctionRegistry) Function

func (r FunctionRegistry) Function(name string) (ExpressionBuilder, error)

Function returns an ExpressionBuilder for the given function name.

func (FunctionRegistry) RegisterFunction

func (r FunctionRegistry) RegisterFunction(name string, f interface{}) error

RegisterFunction registers a function with the given name.

type Inserter added in v0.7.0

type Inserter interface {
	Insert(row Row) error
}

type Nameable

type Nameable interface {
	Name() string
}

type Node

type Node interface {
	Resolvable
	Transformable
	Schema() Schema
	Children() []Node
	RowIter() (RowIter, error)
}

type Resolvable

type Resolvable interface {
	Resolved() bool
}

type Row

type Row []interface{}

func NewRow

func NewRow(values ...interface{}) Row

func NodeToRows

func NodeToRows(n Node) ([]Row, error)

func RowIterToRows

func RowIterToRows(i RowIter) ([]Row, error)

func (Row) Copy

func (r Row) Copy() Row

type RowIter

type RowIter interface {
	Next() (Row, error)
	Close() error
}

func RowsToRowIter added in v0.7.0

func RowsToRowIter(rows ...Row) RowIter

RowsToRowIter creates a RowIter that iterates over the given rows.

type Schema

type Schema []*Column

func (Schema) CheckRow

func (s Schema) CheckRow(row Row) error

type Table

type Table interface {
	Nameable
	Node
}

type Transformable

type Transformable interface {
	TransformUp(func(Node) Node) Node
	TransformExpressionsUp(func(Expression) Expression) Node
}

type Type

type Type interface {
	Name() string
	InternalType() reflect.Kind
	Check(interface{}) bool
	Convert(interface{}) (interface{}, error)
	Compare(interface{}, interface{}) int
	Native(interface{}) driver.Value
	Default() interface{}
}
var Boolean Type = booleanType{}
var Float Type = floatType{}

type UnresolvedDatabase

type UnresolvedDatabase struct{}

func (*UnresolvedDatabase) Name

func (d *UnresolvedDatabase) Name() string

func (*UnresolvedDatabase) Tables

func (d *UnresolvedDatabase) Tables() map[string]Table

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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