Class TableFunctionArguments

java.lang.Object
dev.frostlake.executor.TableFunctionArguments

public final class TableFunctionArguments extends Object
Which arguments each table function actually takes, and how Snowflake refuses the rest.

Whether a table function accepts NAME => value at all is a property of the FUNCTION, not of table functions in general. FLATTEN takes five named arguments; SPLIT_TO_TABLE takes none and answers invalid argument for function [SPLIT_TO_TABLE] unexpected argument [STRING] at position 1, for the very spelling its parameters are documented under; GENERATOR sits at the other extreme and silently IGNORES anything it does not recognise, positional arguments included. So each function's surface is listed here from measurement, and a function with no entry is left alone.

All of these are COMPILE-time refusals on live, raised before a row is read, and all but one carry the position of the function name.

  • Method Details

    • validateQualification

      public static void validateQualification(String functionName, String schemaQualifier)
      Refuse a function that only exists under INFORMATION_SCHEMA when the call did not say so. The qualifier is checked rather than discarded: Frostlake resolved these by their last name part, so a bare QUERY_HISTORY(…) ran where live answers an invalid identifier.
      Parameters:
      schemaQualifier - the CANONICAL schema part written immediately before the function's own name (quoted spellings already unwrapped by the parse-tree reader), or empty when the call is unqualified
    • validateNames

      public static void validateNames(String functionName, org.antlr.v4.runtime.Token nameToken, List<String> namesInOrder)
      Refuse a named argument the function does not take, and a required one the call never supplied.
      Parameters:
      functionName - the function as written, unqualified and upper-cased
      nameToken - the function-name token, whose position the refusal reports
      namesInOrder - one entry per argument in call order — the name as written and upper-cased, or null where the argument was passed positionally
    • validateArity

      public static void validateArity(String functionName, org.antlr.v4.runtime.Token nameToken, List<String> argumentTexts)
      Refuse a call whose positional argument count the function does not accept.

      SPLIT_TO_TABLE takes exactly two, and live spells the three refusals three different ways — including, for the one-argument call, a message that names the internal SPLIT rewrite the arguments were folded into ([SPLIT('a,b' AS "1")]) and carries no position at all. The rewritten call renders a literal argument exactly as written, which is the shape this reproduces.

      Parameters:
      argumentTexts - the source text of each positional argument, in order
    • kindOfNamed

      public static TableFunctionParameterKind kindOfNamed(String functionName, String parameterName)
      The type a named parameter takes, or null when the function's surface has not been measured.
    • kindOfPositional

      public static TableFunctionParameterKind kindOfPositional(String functionName, int index)
      The type the index-th positional argument takes (0-based). Live names such a parameter by its POSITION rather than its name — FLATTEN('[1,2,3]') is invalid type [VARCHAR(7)] for parameter '1' — which is what nameOfPositional(java.lang.String, int) spells, while the type rule itself is the named parameter's.
    • nameOfPositional

      public static String nameOfPositional(String functionName, int index)
      How live names a positional parameter in a type refusal — its 1-based position for most functions, but the parameter's own name for the ones that spell it out.
    • firstPositionalParameter

      public static String firstPositionalParameter(String functionName)
      The parameter a leading positional argument fills. INPUT for most, but not all — TO_QUERY's first parameter is SQL, so a call naming it INPUT is missing its required argument.