Package dev.frostlake.executor
Class SelectItemAccessors
java.lang.Object
dev.frostlake.executor.SelectItemAccessors
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. Extracted from
QueryExecutor; pure functions over ANTLR FrostlakeParser contexts with no engine state.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringA select item's alias as CANONICAL TEXT, or null when it has none.static org.antlr.v4.runtime.ParserRuleContextThe select item's full expression context (thebooleanExprwrapper) — for TEXT use:getOriginalText/getTextof the whole projected item.static StringReturns qualifier for thet.*/{t.*}forms, or null for a bare star.The select item's underlying value expression — for STRUCTURAL use: aggregate/window detection and per-group evaluation.The EXCLUDE/RENAME/REPLACE/ILIKE modifiers on a*,t.*or{*}item (empty if none).static booleanstatic booleanSnowflake's braced star ({*},{* EXCLUDE (c)},{t.*}) — an OBJECT constructor over the row, i.e.static booleanstatic booleanstatic booleanWhether this select item is an EXPRESSION with no name of its own: unaliased and not a column reference.static StringThe output column name Snowflake gives a braced-star item: the item's own source form with its identifiers canonicalised —{*},{* EXCLUDE (A)},{T.*}— or its explicit alias when it carries one.static voidSnowflake refuses to project the UNIT-LESS interval literal on its own:SELECT INTERVAL '1 day'and the multi-partSELECT INTERVAL '1 day, 2 hours'both fail with "interval literal is not supported in this form" (live-verified).The expression under any number of wrapping parentheses; a parenthesized BOOLEAN body ((a AND b)) stays put.Peel a booleanExpr to its underlying value expression (null if it is a boolean AND/OR/NOT).
-
Method Details
-
isStarItem
-
isQualifiedStarItem
-
isObjectStarItem
Snowflake's braced star ({*},{* EXCLUDE (c)},{t.*}) — an OBJECT constructor over the row, i.e.OBJECT_CONSTRUCT(*). It projects ONE object-valued column, never the star's N columns, so it is deliberately NOT a star item. -
isExprItem
-
rejectStandaloneInterval
Snowflake refuses to project the UNIT-LESS interval literal on its own:SELECT INTERVAL '1 day'and the multi-partSELECT INTERVAL '1 day, 2 hours'both fail with "interval literal is not supported in this form" (live-verified). The UNIT-SUFFIXED spelling is a first-class value and projects fine —SELECT INTERVAL '1' DAYis typedINTERVAL DAY(9), aliases fine, andTO_VARCHARof it is+1— so onlyIntervalStringExpris rejected here, neverIntervalExpr.Both spellings stay legal as an operand of date arithmetic, so the test is on each item's ROOT expression: in
DATE '2024-01-01' + INTERVAL '1 day'the root is the addition and the item stands. -
getItemExpression
public static org.antlr.v4.runtime.ParserRuleContext getItemExpression(FrostlakeParser.SelectItemContext item) The select item's full expression context (thebooleanExprwrapper) — for TEXT use:getOriginalText/getTextof the whole projected item. Returns the full item even oncebooleanExprcarries a real OR/AND/NOT body (e.g.SELECT a AND b). -
getItemValueExpr
public static FrostlakeParser.ExpressionContext getItemValueExpr(FrostlakeParser.SelectItemContext item) The select item's underlying value expression — for STRUCTURAL use: aggregate/window detection and per-group evaluation. TodaybooleanExpris a trivial pass-through so this is simply its innerexpression; whenbooleanExprgains a real OR/AND/NOT body this becomes "unwrap the value alternative" and is null for a boolean projection. -
unwrapValue
Peel a booleanExpr to its underlying value expression (null if it is a boolean AND/OR/NOT). -
unwrapParens
public static FrostlakeParser.ExpressionContext unwrapParens(FrostlakeParser.ExpressionContext expr) The expression under any number of wrapping parentheses; a parenthesized BOOLEAN body ((a AND b)) stays put. Snowflake treats a parenthesized column reference exactly like the bare one when naming and validating a select item —SELECT (amount)projects a column namedAMOUNT, and a CTAS accepts it without an alias (both live-verified). -
isUnnamedExpressionItem
Whether this select item is an EXPRESSION with no name of its own: unaliased and not a column reference. A (possibly parenthesized, possibly qualified) column reference and aCONNECT_BY_ROOT colitem take the column's name; every other unaliased expression has only its source text. CTAS and CREATE VIEW refuse such items with "Missing column specification" (live-verified) because the projection cannot supply a declared column name. A boolean-bodied item (SELECT a AND b) has no value expression and no name either. -
getItemAlias
A select item's alias as CANONICAL TEXT, or null when it has none. Text rather than a parse context because the two spellings reach different rules: `AS x` matches the wider aliasName (which admits CASE, CAST, CONSTRAINT, CROSS, DEFAULT, INNER, JOIN and WHEN, all live-legal there), while the bare `x` matches identifier. Every caller wanted the canonical name anyway. -
getStarModifiers
public static List<FrostlakeParser.StarModifierContext> getStarModifiers(FrostlakeParser.SelectItemContext item) The EXCLUDE/RENAME/REPLACE/ILIKE modifiers on a*,t.*or{*}item (empty if none). -
getItemQualifier
Returns qualifier for thet.*/{t.*}forms, or null for a bare star. -
objectStarLabel
The output column name Snowflake gives a braced-star item: the item's own source form with its identifiers canonicalised —{*},{* EXCLUDE (A)},{T.*}— or its explicit alias when it carries one. Rebuilt from the parse tree rather than re-read off the SQL text.
-