Class TemporaryObjectStatements

java.lang.Object
dev.frostlake.executor.udf.TemporaryObjectStatements

public final class TemporaryObjectStatements extends Object
Whether a statement creates a TEMPORARY object, and which kind Snowflake calls it — the question an owner's rights stored procedure has to answer before running a handler's statement.

Answered from the PARSE TREE, by asking the CREATE statement which of its optional tokens are present. The previous implementation split the SQL on whitespace and looked at the first few words, which is the thing this project does not do — and it was not merely stylistic: because the text check ran BEFORE the parser, it "recognised" three spellings the grammar could not actually parse, so CREATE VOLATILE TABLE inside a procedure produced a confident refusal for a statement the engine would have rejected as a syntax error anywhere else.

The kind names are Snowflake's own, as they appear in its refusal — TABLE, STAGE, FILE_FORMAT — with the underscore in FILE_FORMAT and no space.

Only the kinds Frostlake's grammar can express are answered here — which, since the grammar learned the temporary spellings of VIEW and FUNCTION, is every kind Snowflake refuses under owner's rights.

  • Method Details

    • temporaryObjectKind

      public static String temporaryObjectKind(String sqlText)
      The Snowflake kind name when sqlText creates a temporary object, otherwise null.

      Unparseable text answers null: it is not this class's job to report a syntax error, and the engine will raise a better one when it runs the statement.

    • isTemporary

      public static boolean isTemporary(FrostlakeParser.CreateStatementContext create)
      Whether a parsed CREATE carries one of the temporary keywords.

      TRANSIENT is deliberately absent: measured live, an owner's rights procedure creates a transient table happily, and a transient object outlives its session. Only TEMPORARY, TEMP and VOLATILE are the temporary spellings — VOLATILE included, live-verified for views, functions and procedures alike, where a leading VOLATILE is the temporary keyword and not the volatility attribute a function may carry after RETURNS.