Package dev.frostlake.executor
package dev.frostlake.executor
-
ClassDescriptionCache key for statement-invariant facts of the generic aggregate path: a kind tag, up to three CONTEXT objects compared by reference IDENTITY (a new table / context object means a new key, so no explicit clearing is needed across statements), and the argument text.Stateless aggregate-evaluation helpers extracted from
QueryExecutor: WITHIN GROUP parsing, PERCENTILE_CONT/DISC evaluation, and the simple aggregate value reducer.An aggregate's value that its declared type cannot hold — live's row-time "Number out of representable range: type FIXED[SB16](38,38){nullable}, value 3", raised where the DECLARED type is still a legal NUMBER but the value written into it is not: MEDIAN over a NUMBER(38,35) declares NUMBER(38,38), and a median of 3 has no room there.What an AGGREGATION POLICY allows: which aggregates leak a row, and what a body's verdict says.A bare column name carried by both sides of an ON-joined relation — live's "SQL compilation error: ambiguous column name 'T'".The one-row result an anonymous block answers when it runs as a statement — directly, or as the text of an EXECUTE IMMEDIATE: a single column namedanonymous blockholding the value its RETURN produced, or NULL typed VARCHAR when the block ran to its end without a RETURN.Substitutes procedural scripting BIND variables (:var) into raw SQL text before it is parsed/executed.A value too long for itsVARCHAR(n)column, rejected on the write path.Snowflake's compile-time type matching of a value against the column it is written to (live-verified matrix).Which conditional branch a DDL statement took — the two outcomes whose status sentence depends on what the catalog held BEFORE the statement ran, which the parse tree alone cannot say.The conditional branch the CURRENT statement's DDL handler took, reported by the handler itself: the status sentence forCREATE … IF NOT EXISTSthat found its object, and forDROP … IF EXISTSthat did not, depends on what the catalog held a moment BEFORE — a fact only the handler's own skip branch knows.Snowflake hierarchical queries —[START WITH <pred>] CONNECT BY [PRIOR] c = [PRIOR] c.A block'sWHEN … CONTINUE THENexception handling, consulted by loop executors so that a loop-body error matching a CONTINUE handler resumes at the next loop iteration (Snowflake CONTINUE semantics).The correlated subqueries live can evaluate.Owns the named-cursor registry forProceduralExecutor: declaration, lookup, and the save/restore of cursor names around nested blocks.The sentence a statement that produces no rows of its own answers with.The type an UNTYPED declaration (LET y := <expr>,DECLARE y DEFAULT <expr>) takes from an initialiser the direct rules do not cover: the initialiser is typed as a SQL expression over the declared types in scope, then widened the way live declares the name.The declared RETURNS type of the procedure whose body is running, with the block and compound depths its body started at — what tells a RETURN written directly in that body (the one live converts to the declared type) from one nested in an IF, a loop, a handler or an inner block (kept as it is).Statement-scoped duplicate-key guard for deferred-apply INSERTs.The envelope live wraps a DML write failure in —DML operation to table T failed on column C with error: …— around whatever sentence the value itself earned.Whether a projection expression NAMES a given column — read from the expression's own tokens, the wayMaskingPolicyApplierrewrites references, so a name inside a string literal and a same-named function call are both left out of it.Evaluates expressions against rows.A FILE_FORMAT that names a file format.The per-TYPE file-format property surface a real account exposes, measured tree by tree: which options each type accepts (an option outside its type's tree refusesOption X is not valid for file format type Y.), each property's declared type, its current-value default and the constant default column DESC prints (JSON-family NULL_IF starts[]while the default column still reads[\N]).One property row: name, declared type, current-value default, DESC's default column.The value of an expression written over GROUPED rows, computed over the row's own source group.Resolves the sort value of an ORDER BY item that could NOT be matched to a SELECT column after GROUP BY / aggregation — Snowflake allows ordering by a grouped column or an aggregate that is not in the SELECT list (e.g.How wide a WRITTEN integer literal may be.A dotted column qualifier naming no FROM-clause key — live's "SQL compilation error: invalid identifier 'R.C'": an alias REPLACES the table name, in the SELECT list, WHERE, GROUP BY and ORDER BY alike (each measured).What a JOIN POLICY demands of a query's FROM clause: the protected table must be INNER joined to a DIFFERENT table on an equality between their columns.The collation a sorting, grouping or de-duplicating key compares under.A statement that BEGINS with comments reports its positions from the first real token, not from the top of the text.The MERGE evaluation shape for one (source table, target table, aliases) combination: the merged__MERGE__table exposingalias.col/tablename.col/ bare-name slots, oneExpressionEvaluatorover it, and the slot mapping that refills a values list per source/target row pair.What a request carrying SEVERAL statements answers when one of them fails while running.A value that could not be read as a number where one was required — live's "Numeric value 'a' is not recognized", and the VARIANT spelling of the same failure.The sentence a number too wide for its destination gets.Stateless helpers that read text and names out of ANTLR parse-tree nodes.Builds the procedural-statement hierarchy (ProceduralBlock / IfStatement / CaseStatement / LoopStatement / WhileStatement / ForStatement / …) from the ANTLR parse tree.WHICH select item was being evaluated when a row-time failure was raised.Query Executor - Executes SQL statements using ANTLR-based parsingQuery results held by query ID so RESULT_SCAN can read them back, plus the per-session history of query IDs that LAST_QUERY_ID walks.A thread-local mode in which a relation is read for its SHAPE and never for its rows: every base source resolves to zero rows and a FROM-less item that cannot be computed is left NULL, so the columns come out typed by the static channel while nothing value-dependent runs.Owns procedural scripting variable state and nested-scope semantics forProceduralExecutor: the variable map plus the scope stack used by BEGIN…END and control-flow blocks.Stateless accessors over SELECT-item parse-tree nodes — star / qualified-star / braced-star / expression item predicates, plus the alias, qualifier and value/full expression of an item.The session parameters SHOW PARAMETERS lists, with their defaults, descriptions and type words.One row ofSessionParameterCatalog: the parts of a session parameter that do not change with the session.The flavour a BARETIMESTAMPmeans, which the session's TIMESTAMP_TYPE_MAPPING parameter names.The zone the session's TIMEZONE parameter names, reachable from the value layer.Stateless set-operation row math — UNION / INTERSECT / EXCEPT (ALL and distinct variants) and DISTINCT — extracted fromQueryExecutor.Executes SHOW / DESCRIBE catalog-introspection commands.Small stateless helpers shared by more than one SHOW/DESCRIBE sub-executor.An expression with every SIBLING SELECT ALIAS it mentions replaced by that alias's defining expression.TheSBntag Snowflake prints for a fixed-point number — the smallest SIGNED-INTEGER width, in bytes, that holds the number's unscaled value.How Snowflake lays out an access-control refusal:"SQL access control error:", a newline, then the detail — the same two-line layoutSqlCompilationErrordocuments for compilation errors.Visitor that executes SQL commands by visiting the ANTLR parse tree.How Snowflake lays out a compilation-error message.Canonical form of a SQL identifier, matching Snowflake's identifier resolution: an unquoted identifier folds to UPPERCASE (site→SITE, so it lands in the catalog, INFORMATION_SCHEMA, SHOW output and result-set column labels the same way Snowflake stores it); a "double-quoted" identifier keeps its exact case (the surrounding quotes are stripped); a$npositional parameter becomesCOLUMNn.Binds a named parameter into a SQL body by substituting each occurrence of the parameter's bare name with a replacement string — for UDF / stored-procedure bodies and masking-policy bodies, where the parameter is written as an ordinary identifier.Splits a multi-statement SQL SCRIPT into its top-level statements for clients that execute and report per statement (the HTTP server's init script, the console's script runner).The single, canonical decode for a single-quoted SQL string literal — the one place that turns aSTRING_LITERALtoken (or its already-stripped inner text) into the value it denotes.Small predicates over lexed SQL tokens, shared by the lexer-driven substitution paths (BindVariableSubstitutor,MaskingPolicyApplier,JdbcMarshaling).Resolves the stage referencesTO_FILEis given, reusing the executor's ownQueryExecutor.resolveCopyBaseDir(String)— the one place that already knows how@stage,@db.schema.stage,@~and@%tablemap onto local directories.A star written as a function ARGUMENT —COUNT(*),HASH_AGG(t.*),COUNT(* EXCLUDE (a)),COUNT(* ILIKE 'a%')— and what it stands for: the in-scope columns it expands to, so that the call is then an ordinary multi-argument one (live-verified: a qualified star expands to that relation's columns only, an EXCLUDE drops the named columns, an ILIKE keeps the matching ones, andHASH_AGG(t.*)equalsHASH_AGG(t.a, t.b, t.c)).One effective output column produced by expanding aSELECT *after its EXCLUDE / RENAME / REPLACE / ILIKE modifiers: the value expression to project, the output column name (RENAME changes it), the original source column name (to tell whether it was renamed), and a best-effort output data type.The one instant a statement calls "now".How many top-level statements a request holds, counted the way the account counts them (live-verified).Letting a statement's failure out with the message it already has.EvaluatesSYSTEM$FUNCNAME(...)built-in system functions invoked from expression context.WhatSYSTEM$TYPEOFanswers: a DECLARED type name and a physical storage tag, and the two come from different places — which is the whole point of this class.Which arguments each table function actually takes, and how Snowflake refuses the rest.What a table function's parameter will take.A TRANSIENT object keeps at most ONE day of history, and asking for more is refused.A:nameinside a scripting block naming no declared variable — the same "invalid identifier" refusal as any other unresolvable name, and deliberately worded identically.Stateless value/ordering comparison helpers extracted fromQueryExecutor.Builds and evaluates SQL expressions on behalf ofSQLCommandVisitor: the procedural expression AST (buildExpression), constant / DDL-time evaluation (evaluateExpression), and theSYSTEM$built-in family (evaluateSystemFunc).Refusing a statement that names a warehouse which is not there.First-occurrence 1-based position, RANK and DENSE_RANK of every row of ONE sorted window partition, built in a single pass over the partition.