Class FunctionRegistry

java.lang.Object
dev.frostlake.functions.FunctionRegistry

public class FunctionRegistry extends Object
  • Constructor Details

  • Method Details

    • registerAlias

      public void registerAlias(String name, BuiltInFunction function)
      Registers an alias name for an already-constructed function (used by FunctionProviders).
    • register

      public void register(BuiltInFunction function)
    • registerAggregate

      public void registerAggregate(AggregateFunction function)
    • registerTableFunction

      public void registerTableFunction(TableFunction function)
    • getCatalog

      public Catalog getCatalog()
      The catalog this registry's functions read metadata from, for a FunctionProvider whose pack contributes a catalog-aware function. The engine's own such built-ins (GET_DDL, the INFORMATION_SCHEMA-adjacent context functions) are handed it at construction; a pack sees the registry and nothing else, so it asks here.
    • getSessionContext

      public SessionContext getSessionContext()
      The session a pack's function answers for — the current role, database and schema.
    • setQueryRunner

      public void setQueryRunner(QueryRunner runner)
      How a pack's function runs SQL of its own. Installed by the executor once it exists — the registry is built first — so a function that needs it holds the REGISTRY and asks at call time rather than capturing a runner it would have been handed as null.
    • getQueryRunner

      public QueryRunner getQueryRunner()
    • setTaskScheduler

      public void setTaskScheduler(TaskScheduler taskScheduler)
      Hands the task scheduler to the built-ins that need it. The scheduler is constructed after this registry, so it arrives here rather than through a constructor.
    • getFunction

      public BuiltInFunction getFunction(String name)
    • getAggregateFunction

      public AggregateFunction getAggregateFunction(String name)
    • getTableFunction

      public TableFunction getTableFunction(String name)
    • hasFunction

      public boolean hasFunction(String name)
    • hasAggregateFunction

      public boolean hasAggregateFunction(String name)
    • hasTableFunction

      public boolean hasTableFunction(String name)
    • getAllFunctions

      public Collection<BuiltInFunction> getAllFunctions()
    • getAllAggregateFunctions

      public Collection<AggregateFunction> getAllAggregateFunctions()
    • getAllTableFunctions

      public Collection<TableFunction> getAllTableFunctions()
    • allDispatchableNames

      public SortedSet<String> allDispatchableNames()
      The list of built-in names this engine can dispatch — the single source SHOW FUNCTIONS and SHOW BUILTIN FUNCTIONS enumerate, so a listing and a working call can no longer disagree.

      It is the union of six families, each contributed by the very structure the dispatcher consults:

      • the scalar map's keys — keys, not getAllFunctions() values, because an alias such as SUBSTR is a second key onto a Substring instance whose BuiltInFunction.getName() still answers SUBSTRING. Enumerating values listed SUBSTRING twice and SUBSTR never;
      • the aggregate map's keys (same alias story: ARRAYAGG, BIT_OR_AGG, …);
      • the table-function map's keys;
      • WindowFunctionNames — window functions live in WindowFunctionEvaluator, never in these maps;
      • HigherOrderFunctionNames — TRANSFORM / FILTER / REDUCE are taken by ExpressionEvaluatorVisitor before the registry lookup;
      • SystemFunctionNames and OperatorFunctionNames — evaluated by the SYSTEM$ evaluators and by the grammar respectively.

      The first three families cannot drift because the listing reads the same maps getFunction / getAggregateFunction / getTableFunction resolve against; the next three cannot drift because their dispatchers reject names those sets do not declare. Only OperatorFunctionNames is curated, and its entries are re-verified by test.

      Returns:
      every dispatchable built-in name, upper-cased and sorted; never null