Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evalengine: More functions! #9673

Merged
merged 9 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 59 additions & 34 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,11 @@ type (
SQLNode
}

Callable interface {
iCallable()
Expr
}

// AndExpr represents an AND expression.
AndExpr struct {
Left, Right Expr
Expand Down Expand Up @@ -1946,6 +1951,12 @@ type (
Collation string
}

// WeightStringFuncExpr represents the function and arguments for WEIGHT_STRING('string' AS [CHAR|BINARY](n))
WeightStringFuncExpr struct {
Expr Expr
As *ConvertType
}

// FuncExpr represents a function call.
FuncExpr struct {
Qualifier TableIdent
Expand Down Expand Up @@ -2044,40 +2055,54 @@ type (
)

// iExpr ensures that only expressions nodes can be assigned to a Expr
func (*AndExpr) iExpr() {}
func (*OrExpr) iExpr() {}
func (*XorExpr) iExpr() {}
func (*NotExpr) iExpr() {}
func (*ComparisonExpr) iExpr() {}
func (*BetweenExpr) iExpr() {}
func (*IsExpr) iExpr() {}
func (*ExistsExpr) iExpr() {}
func (*Literal) iExpr() {}
func (Argument) iExpr() {}
func (*NullVal) iExpr() {}
func (BoolVal) iExpr() {}
func (*ColName) iExpr() {}
func (ValTuple) iExpr() {}
func (*Subquery) iExpr() {}
func (ListArg) iExpr() {}
func (*BinaryExpr) iExpr() {}
func (*UnaryExpr) iExpr() {}
func (*IntroducerExpr) iExpr() {}
func (*IntervalExpr) iExpr() {}
func (*CollateExpr) iExpr() {}
func (*FuncExpr) iExpr() {}
func (*TimestampFuncExpr) iExpr() {}
func (*ExtractFuncExpr) iExpr() {}
func (*CurTimeFuncExpr) iExpr() {}
func (*CaseExpr) iExpr() {}
func (*ValuesFuncExpr) iExpr() {}
func (*ConvertExpr) iExpr() {}
func (*SubstrExpr) iExpr() {}
func (*ConvertUsingExpr) iExpr() {}
func (*MatchExpr) iExpr() {}
func (*GroupConcatExpr) iExpr() {}
func (*Default) iExpr() {}
func (*ExtractedSubquery) iExpr() {}
func (*AndExpr) iExpr() {}
func (*OrExpr) iExpr() {}
func (*XorExpr) iExpr() {}
func (*NotExpr) iExpr() {}
func (*ComparisonExpr) iExpr() {}
func (*BetweenExpr) iExpr() {}
func (*IsExpr) iExpr() {}
func (*ExistsExpr) iExpr() {}
func (*Literal) iExpr() {}
func (Argument) iExpr() {}
func (*NullVal) iExpr() {}
func (BoolVal) iExpr() {}
func (*ColName) iExpr() {}
func (ValTuple) iExpr() {}
func (*Subquery) iExpr() {}
func (ListArg) iExpr() {}
func (*BinaryExpr) iExpr() {}
func (*UnaryExpr) iExpr() {}
func (*IntroducerExpr) iExpr() {}
func (*IntervalExpr) iExpr() {}
func (*CollateExpr) iExpr() {}
func (*FuncExpr) iExpr() {}
func (*TimestampFuncExpr) iExpr() {}
func (*ExtractFuncExpr) iExpr() {}
func (*WeightStringFuncExpr) iExpr() {}
func (*CurTimeFuncExpr) iExpr() {}
func (*CaseExpr) iExpr() {}
func (*ValuesFuncExpr) iExpr() {}
func (*ConvertExpr) iExpr() {}
func (*SubstrExpr) iExpr() {}
func (*ConvertUsingExpr) iExpr() {}
func (*MatchExpr) iExpr() {}
func (*GroupConcatExpr) iExpr() {}
func (*Default) iExpr() {}
func (*ExtractedSubquery) iExpr() {}

// iCallable marks all expressions that represent function calls
func (*FuncExpr) iCallable() {}
func (*TimestampFuncExpr) iCallable() {}
func (*ExtractFuncExpr) iCallable() {}
func (*WeightStringFuncExpr) iCallable() {}
func (*CurTimeFuncExpr) iCallable() {}
func (*ValuesFuncExpr) iCallable() {}
func (*ConvertExpr) iCallable() {}
func (*SubstrExpr) iCallable() {}
func (*ConvertUsingExpr) iCallable() {}
func (*MatchExpr) iCallable() {}
func (*GroupConcatExpr) iCallable() {}

// Exprs represents a list of value expressions.
// It's not a valid expression because it's not parenthesized.
Expand Down
49 changes: 49 additions & 0 deletions go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 105 additions & 0 deletions go/vt/sqlparser/ast_equals.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,15 @@ func (node *ExtractFuncExpr) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "extract(%s from %v)", node.IntervalTypes.ToString(), node.Expr)
}

// Format formats the node.
func (node *WeightStringFuncExpr) Format(buf *TrackedBuffer) {
if node.As != nil {
buf.astPrintf(node, "weight_string(%v as %v)", node.Expr, node.As)
} else {
buf.astPrintf(node, "weight_string(%v)", node.Expr)
}
}

// Format formats the node.
func (node *CurTimeFuncExpr) Format(buf *TrackedBuffer) {
if node.Fsp != nil {
Expand Down
15 changes: 15 additions & 0 deletions go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading