expr

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOWEST      int
	BOOL_AND_OR // TODO(next): is it really that AND and OR have the same precedence?
	EQUALS      // ==, !=
	LESSGREATER // >, <, <=, >=
	ADDITION    // +
	PRODUCT     // *
	PREFIX      // -X or NOT X
	NAMESPACE   // foo.bar
	CALL        // myFunction(X)
)

Variables

This section is empty.

Functions

func ColumnsUsed

func ColumnsUsed(expr Expression, schema column.TableSchema) (cols []string)

ARCH: this panics when a given column is not in the schema, but since we already validated this schema during the ReturnType call, we should be fine. It's still a bit worrying that we might panic though. TODO(next)/TODO(joins): all the columnsUsed functions need to support multiple schemas and namespaces perhaps we should return []*Identifier, that would solve a few other issues as well

func ColumnsUsedMultiple

func ColumnsUsedMultiple(schema column.TableSchema, exprs ...Expression) []string

func Evaluate

func Evaluate(expr Expression, chunkLength int, columnData map[string]column.Chunk, filter *bitmap.Bitmap) (column.Chunk, error)

OPTIM: we're doing a lot of type shenanigans at runtime - when we evaluate a function on each stripe, we do the same tree of operations - this applies not just here, but in projections.go as well - e.g. we know that if we have `intA - intB`, we'll run a function for ints - we don't need to decide that for each stripe

func HasIdentifiers

func HasIdentifiers(expr Expression) bool

func InitAggregator

func InitAggregator(fun *Function, schema column.TableSchema) error

func PruneFunctionCalls

func PruneFunctionCalls(ex Expression)

func UpdateAggregator

func UpdateAggregator(fun *Function, buckets []uint64, ndistinct int, columnData map[string]column.Chunk, filter *bitmap.Bitmap) error

Types

type Bool

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

func (*Bool) Children

func (ex *Bool) Children() []Expression

func (*Bool) ReturnType

func (ex *Bool) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Bool) String

func (ex *Bool) String() string

type Dataset added in v0.1.3

type Dataset struct {
	Name    string
	Version string
	Latest  bool
	// contains filtered or unexported fields
}

func (*Dataset) String added in v0.1.3

func (ex *Dataset) String() string

type Expression

type Expression interface {
	ReturnType(ts column.TableSchema) (column.Schema, error)
	String() string
	Children() []Expression
}

func ParseStringExpr

func ParseStringExpr(s string) (Expression, error)

func ParseStringExprs

func ParseStringExprs(s string) ([]Expression, error)

type Float

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

func (*Float) Children

func (ex *Float) Children() []Expression

func (*Float) ReturnType

func (ex *Float) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Float) String

func (ex *Float) String() string

type Function

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

func AggExpr

func AggExpr(expr Expression) ([]*Function, error)

func NewFunction

func NewFunction(name string, distinct bool) (*Function, error)

NewFunction is one of the very few constructors as we have to do some fiddling here

func (*Function) Children

func (ex *Function) Children() []Expression

func (*Function) ReturnType

func (ex *Function) ReturnType(ts column.TableSchema) (column.Schema, error)

now, all function return types are centralised here, but it should probably be embedded in individual functions' definitions - we'll need to have some structs in place (for state management in aggregating funcs), so those could have methods like `ReturnType(args)` and `IsValid(args)`, `IsAggregating` etc. also, should we make multiplication, inequality etc. just functions like nullif or coalesce? That would allow us to fold all the functionality of eval() into a (recursive) function call TODO: make sure that these return types are honoured in aggregators' resolvers

func (*Function) String

func (ex *Function) String() string

type Identifier

type Identifier struct {
	Namespace *Identifier

	Name string
	// contains filtered or unexported fields
}

func NewIdentifier

func NewIdentifier(name string) *Identifier

TODO(quoting): rules are quite non-transparent - unify and document somehow

func (*Identifier) Children

func (ex *Identifier) Children() []Expression

func (*Identifier) ReturnType

func (ex *Identifier) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Identifier) String

func (ex *Identifier) String() string

type Infix

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

func (*Infix) Children

func (ex *Infix) Children() []Expression

func (*Infix) ReturnType

func (ex *Infix) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Infix) String

func (ex *Infix) String() string

type Integer

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

func (*Integer) Children

func (ex *Integer) Children() []Expression

func (*Integer) ReturnType

func (ex *Integer) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Integer) String

func (ex *Integer) String() string

func (*Integer) Value added in v0.1.3

func (ex *Integer) Value() int64

TODO/ARCH: doing this to avoid too many changes across the codebase, consider exporting the field

type Null

type Null struct{}

func (*Null) Children

func (ex *Null) Children() []Expression

func (*Null) ReturnType

func (ex *Null) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Null) String

func (ex *Null) String() string

type Ordering

type Ordering struct {
	Asc, NullsFirst bool // ARCH: consider *bool for better stringers (and better roundtrip tests)
	// contains filtered or unexported fields
}

func (*Ordering) Children

func (ex *Ordering) Children() []Expression

func (*Ordering) ReturnType

func (ex *Ordering) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Ordering) String

func (ex *Ordering) String() string

type Parentheses

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

func (*Parentheses) Children

func (ex *Parentheses) Children() []Expression

func (*Parentheses) ReturnType

func (ex *Parentheses) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Parentheses) String

func (ex *Parentheses) String() string

type Parser

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

func NewParser

func NewParser(s string) (*Parser, error)

func (*Parser) Err

func (p *Parser) Err() error

type Prefix

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

func (*Prefix) Children

func (ex *Prefix) Children() []Expression

func (*Prefix) ReturnType

func (ex *Prefix) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Prefix) String

func (ex *Prefix) String() string

type Query

type Query struct {
	Select    []Expression
	Dataset   *Dataset
	Filter    Expression
	Aggregate []Expression
	Order     []Expression
	Limit     *int
}

Query describes what we want to retrieve from a given dataset There are basically four places you need to edit (and test!) in order to extend this:

  1. The engine itself needs to support this functionality (usually a method on Dataset or column.Chunk)
  2. The query method has to be able to translate query parameters to the engine
  3. The query endpoint handler needs to be able to process the incoming body to the Query struct (the Unmarshaler should mostly take care of this)
  4. The HTML/JS frontend needs to incorporate this in some way

func ParseQuerySQL

func ParseQuerySQL(s string) (Query, error)

func (Query) String

func (q Query) String() string

this stringer is tested in the parser

type Relabel

type Relabel struct {
	Label string // exporting it, because there's no other way of getting to it
	// contains filtered or unexported fields
}

func (*Relabel) Children

func (ex *Relabel) Children() []Expression

func (*Relabel) ReturnType

func (ex *Relabel) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*Relabel) String

func (ex *Relabel) String() string

type String

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

func (*String) Children

func (ex *String) Children() []Expression

func (*String) ReturnType

func (ex *String) ReturnType(ts column.TableSchema) (column.Schema, error)

func (*String) String

func (ex *String) String() string

type Tuple

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

func (*Tuple) Children

func (ex *Tuple) Children() []Expression

func (*Tuple) ReturnType

func (ex *Tuple) ReturnType(ts column.TableSchema) (column.Schema, error)

this is a bit weird, because a Tuple is a container, it doesn't "return" anything, so we'll just return the homogenous type it contains so (1, 2, 3) -> int, (1, 2.0, 3) -> float, (1, 'foo', 3) -> err TODO/ARCH: we don't worry if these are all literals... should we? Or should we leave that to eval?

func (*Tuple) String

func (ex *Tuple) String() string

Jump to

Keyboard shortcuts

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