MCPcopy Create free account
hub / github.com/rilldata/rill / SQLForExpression

Method SQLForExpression

runtime/metricsview/astexpr.go:15–30  ·  view source on GitHub ↗

SQLForExpression generates a SQL expression for a query expression. pseudoHaving is true if the expression is allowed to reference measure expressions. visible is true if the expression is only allowed to reference dimensions and measures that are exposed by the security policy.

(e *Expression, n *SelectNode, pseudoHaving, visible bool)

Source from the content-addressed store, hash-verified

13// pseudoHaving is true if the expression is allowed to reference measure expressions.
14// visible is true if the expression is only allowed to reference dimensions and measures that are exposed by the security policy.
15func (ast *AST) SQLForExpression(e *Expression, n *SelectNode, pseudoHaving, visible bool) (string, []any, error) {
16 b := &sqlExprBuilder{
17 ast: ast,
18 node: n,
19 pseudoHaving: pseudoHaving,
20 visible: visible,
21 out: &strings.Builder{},
22 }
23
24 err := b.writeExpression(e)
25 if err != nil {
26 return "", nil, err
27 }
28
29 return b.out.String(), b.args, nil
30}
31
32type sqlExprBuilder struct {
33 ast *AST

Callers 4

NewASTFunction · 0.95

Calls 2

writeExpressionMethod · 0.95
StringMethod · 0.65

Tested by 1