Package dev.frostlake.executor.expressions


package dev.frostlake.executor.expressions
  • Class
    Description
    Parses an expression string into an Expression AST using the ANTLR grammar and ExpressionAstBuilder.
    Represents array element access (e.g., arr[0], data[index])
    Renders an Expression AST into a compact, canonical S-expression string.
    Represents a BETWEEN expression (e.g., x BETWEEN 1 AND 10)
    A hex BINARY literal's text, X'..', read the way live reads it: SPACES inside the quotes are dropped wherever they fall (X'00 11' is two bytes, X'0 0' one), and what remains must be pairs of hexadecimal digits.
    Represents a binary operation (e.g., a + b, x > 5, name = 'Alice')
    The type an arithmetic or concatenation expression is statically KNOWN to produce.
    The operator of a BinaryOperationExpression — arithmetic, comparison, logical, and string operators.
    A :name bind-variable reference — inside a Snowflake Scripting block, SQL statements refer to the block's variables (and a procedure's parameters) as :name.
    Represents a CASE expression
    Represents a type cast (e.g., CAST(x AS INTEGER), x::VARCHAR).
    The optional field modifier of CAST(expr AS <structured type> [RENAME FIELDS | ADD FIELDS]).
    A sorting, grouping or DISTINCT key that carries the collation it compares under.
    How strongly an expression holds its collation when two meet in one comparison — the three levels live ranks them by, lowest first.
    A collation specification — the text COLLATE names in a column definition or an expression — parsed into the rules a string comparison runs by.
    Represents a column reference (e.g., "name", "users.id", "u.name")
    CONNECT_BY_ROOT <column>: the column's value on the ROOT row of the hierarchy branch that produced the current row.
    The bare word DEFAULT where a DML value is expected — INSERT … VALUES (DEFAULT), UPDATE t SET c = DEFAULT, and the same two inside MERGE.
    EXECUTE IMMEDIATE <sql-expr> [USING (v1, v2, …)] used as an expression: the SQL string (itself an expression — a literal, bind variable, concatenation, …) is evaluated, any USING values are bound to its ? placeholders, the dynamic statement is executed, and its first column of the first row is returned (scalar), like a scalar subquery.
    Base interface for all expression nodes in the AST
    Pure arithmetic, temporal and comparison helpers extracted from ExpressionEvaluatorVisitor: numeric/date add/subtract/multiply/divide/negate, three-valued truthiness, value equality/ordering and INTERVAL application.
    Builds Expression AST nodes directly from the ANTLR parse tree.
    The collation an expression carries into a comparison, with the level it holds it at — see CollationLevel.
    Evaluates expression AST using the visitor pattern
    Where the expression currently being evaluated started inside its statement — the missing half of a reported position.
    Visitor interface for expression AST traversal
    A value PRESENTED at the type a conditional fold declares — the conversion the account plans as a CAST on every branch, so the branch handed back reads at the fold whatever it was written as:
    Represents a function call (e.g., UPPER(name), COUNT(*), SUM(salary))
    How a TEXT reads as a number in exact arithmetic — t + 0, t * n, MOD(t, 2), ROUND(t, 1) — live-verified over VARCHAR columns of every declared length and over literals: a text COLUMN or expression reads as NUMBER(18,5): t + 0 declares NUMBER(19,5) and answers 5.00000, t / 1 NUMBER(24,11), t % 2 NUMBER(18,5); the value is rounded HALF_UP to five decimals before the operation ('1.123456' + 0 is 1.12346); a text LITERAL reads as NUMBER(18, s) with ITS OWN scale: '5' + 1 declares NUMBER(19,0) and answers 6, '2.5' + 1 NUMBER(19,1) and 3.5, MOD('5', 2) NUMBER(2,0); text beside text, beside a FLOAT, beside a VARIANT or beside a bare NULL is a FLOAT, as is a VARIANT beside anything and a signed text — those are not this reading.
    Represents an IN expression (e.g., x IN (1, 2, 3) or x IN (SELECT ...))
    Represents an INTERVAL expression (e.g., INTERVAL '10' DAY)
    The unit of an IntervalExpression.
    Represents an x IS NULL / x IS NOT NULL test.
    Represents a JSON array literal (e.g., [1, 2, 3])
    Represents a JSON object literal (e.g., {'name': 'Alice', 'age': 30})
    A lambda argument to a higher-order function — <param> -> <body> or (<param>, …) -> <body> (e.g.
    Snowflake multi-pattern matching: x LIKE ANY (p1, p2, …), x LIKE ALL (…) and x ILIKE ANY (…), with an optional shared ESCAPE.
    Pure SQL LIKE/ILIKE evaluation extracted from ExpressionEvaluatorVisitor: translate a LIKE pattern (with an explicit ESCAPE char) to a regex and match against it, caching the compiled Pattern.
    Represents a literal value (string, number, boolean, null)
    The kind of a LiteralExpression value.
    A scalar subquery whose select list has more than one item — refused while the statement compiles ("Unsupported: Scalar subquery with multi-column SELECT clause.", anchored on the subquery's own SELECT), a refusal that has to escape the typing pass that finds it while every other planning fault there merely leaves the subquery untyped.
    Represents object property access (e.g., data:name, json:address:city).
    A membership index over a subquery's first-column values, built once for an uncorrelated value IN (subquery) so each outer row is an O(1) probe instead of an O(subqueryRows) linear scan — turning the membership test from O(outer × sub) into O(outer + sub).
    PRIOR <column> inside a CONNECT BY predicate: the column's value on the PARENT row of the hierarchy step being considered, as opposed to the candidate child row every other reference reads.
    Represents a quantified comparison expression (e.g., x > ANY (subquery))
    The quantifier of a QuantifiedComparisonExpression — ANY/SOME (equivalent) or ALL.
    Which step of an exact arithmetic operation ran out of the 128-bit carrier — the two refusal shapes that need to know an operand's NULLABILITY before their sentence is complete (see RawRangeOverflow).
    An exact arithmetic step ran out of the 128-bit carrier, and the sentence still needs the refused operand's NULLABILITY — which only the evaluator holding the expression tree can resolve.
    Static return-type inference for scalar SQL routine bodies: the type the body expression is KNOWN to produce over the routine's declared parameters, or null when undetermined.
    Which row, counting from 0, the operator is currently evaluating expressions for — what the SEQ1 / SEQ2 / SEQ4 / SEQ8 family reads.
     
    The three GROUPING / SORTING key positions Snowflake names in its "cannot be used as ... keys" rejection.
    Where a node sits inside the expression TEXT it was parsed from — a line (1-based) and a character offset within that line (0-based), the two numbers Snowflake reports as error line 1 at position 7.
    The spread operator **<expr>: inside an array constructor or a function argument list the inner ARRAY's elements are spliced in as individual elements/arguments; inside an object constructor the inner OBJECT's pairs are merged in.
    The single truthiness rule for a value in predicate position — Snowflake's implicit boolean coercion: a BOOLEAN as itself, a VARCHAR via TO_BOOLEAN's text forms ('true', 't', 'yes', 'y', 'on', '1', case-insensitive), a number as zero/non-zero, NULL and anything else as FALSE.
    Represents a subquery expression (scalar subquery or EXISTS)
    Per-(outer-query) memo for subqueries that are evaluated once per outer row.
     
     
    Row-constructor IN test: (a, b) IN (SELECT x, y ...), (a, b) IN ((1, 2), (3, 4)), or the type-invalid flat spelling (a, b) IN (1, 2).
    The type a SQL UDF's parameter carries INSIDE the body, which is not always the type it was declared with.
    Represents a unary operation (e.g., NOT x, -5, EXISTS(...))
    The operator of a UnaryOperationExpression — logical NOT, arithmetic NEGATE, or EXISTS.
    Live's refusal of a correlated subquery whose shape its planner cannot evaluate ("Unsupported subquery type cannot be evaluated at line L, position P").
    Pure value-casting helpers extracted from ExpressionEvaluatorVisitor: SQL CAST/coercion of a value to a target type, NUMBER(p,s) scale/precision enforcement, integer rounding, and hex decoding.
    A VARIANT read as a number wherever a number is needed: its JSON number, its JSON string when that spells one, and a JSON boolean as 1 / 0.
     
    A window function call (one carrying an OVER clause) that appears nested inside a larger expression — e.g.