Skip to content

Add system.metadata.functions table for queryable function metadata #1236

Description

@mbasmanova

Today, function metadata is only available via SHOW FUNCTIONS, which returns all function signatures as a flat list. There is no way to query function metadata using standard SQL — e.g., to get distinct function names, filter by function type, or find functions owned by a specific team.

Proposal

Add a system.metadata.functions table to the existing system catalog, alongside system.runtime.queries.

Schema

Column Type Description
function_name VARCHAR Function name
function_type VARCHAR scalar, aggregate, or window
return_type VARCHAR Return type signature (e.g., bigint, array(T))
argument_types ARRAY(VARCHAR) Argument type signatures
is_variadic BOOLEAN Whether the function accepts a variable number of arguments
owner VARCHAR Responsible team/person
properties JSON Type-specific metadata (see below)

One row per function signature (overload).

Properties JSON

Type-specific metadata that doesn't apply uniformly to all function types:

Scalar functions:

{"deterministic": true, "null_on_null_input": true}

Aggregate functions:

{"order_sensitive": false, "ignore_duplicates": true}

Window functions:

{}

Example queries

-- Distinct function names
SELECT DISTINCT function_name FROM system.metadata.functions ORDER BY 1;

-- All aggregate functions
SELECT DISTINCT function_name FROM system.metadata.functions WHERE function_type = 'aggregate';

-- Functions owned by a specific team
SELECT DISTINCT function_name FROM system.metadata.functions WHERE owner = 'team_name';

-- Non-deterministic scalar functions
SELECT function_name FROM system.metadata.functions
WHERE json_extract_scalar(properties, '$.deterministic') = 'false';

-- Functions that accept a BIGINT first argument
SELECT function_name FROM system.metadata.functions WHERE argument_types[1] = 'bigint';

-- Functions with exactly 2 arguments
SELECT DISTINCT function_name FROM system.metadata.functions WHERE cardinality(argument_types) = 2;

Implementation notes

Function metadata is available via existing Velox APIs:

  • getFunctionSignatures() — scalar functions (simple + vector)
  • getAggregateFunctionSignatures() — aggregate functions
  • windowFunctions() — window functions

Each registration includes signatures (FunctionSignature) and metadata (VectorFunctionMetadata for scalars, AggregateFunctionMetadata for aggregates). The owner field is currently only available on scalar function metadata; extending it to aggregate and window metadata would be a separate Velox change.

The implementation can follow the existing pattern of system.runtime.queries — add a new SystemTable subclass under the metadata schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions