MCPcopy
hub / github.com/pingcap/tidb / evalAstExpr

Function evalAstExpr

pkg/planner/core/expression_rewriter.go:71–80  ·  view source on GitHub ↗

evalAstExpr evaluates ast expression directly.

(ctx expression.BuildContext, expr ast.ExprNode)

Source from the content-addressed store, hash-verified

69
70// evalAstExpr evaluates ast expression directly.
71func evalAstExpr(ctx expression.BuildContext, expr ast.ExprNode) (types.Datum, error) {
72 if val, ok := expr.(*driver.ValueExpr); ok {
73 return val.Datum, nil
74 }
75 newExpr, err := buildSimpleExpr(ctx, expr)
76 if err != nil {
77 return types.Datum{}, err
78 }
79 return newExpr.Eval(ctx.GetEvalCtx(), chunk.Row{})
80}
81
82// rewriteAstExprWithPlanCtx rewrites ast expression directly.
83// Different with expression.BuildSimpleExpr, it uses planner context and is more powerful to build some special expressions

Callers 4

runTestsFunction · 0.85
TestCaseWhenFunction · 0.85
TestCastFunction · 0.85

Calls 3

buildSimpleExprFunction · 0.85
EvalMethod · 0.65
GetEvalCtxMethod · 0.65

Tested by 3

runTestsFunction · 0.68
TestCaseWhenFunction · 0.68
TestCastFunction · 0.68