UDF()

All functions > CORE > UDF()

Returns a reference to a UDF (user-defined function).

Signatures

Returns: A UDF function reference

UDF(config: JSON) → UDF
sql
ParameterTypeRequiredDescription
configJSONYesJSON configuration for the user-defined function

Notes

  • Defines a user-defined function (UDF) in the feature mesh
  • UDFs allow custom logic to be integrated into features
  • Configuration specifies the UDF's implementation and signature
  • Enables extension of FeatureMesh with custom functionality
  • Part of the FeatureMesh core extensibility system

Examples

JSON UDF with FEATUREQL and SQL templates (4-udfs-base.slt)

FeatureQL
WITH
    normalized_quarter := UDF(
        JSON '{
        "positions": ["date_input"],
        "signatures": [
            ["DATE", "VARCHAR"],
            ["TIMESTAMP", "VARCHAR"]
        ],
        "templates": {
            "FEATUREQL": "NORMALIZED_QUARTER({{ jexpr(p(''date_input'')) }})",
            "SQL": "CONCAT(CAST(YEAR({{ jexpr(p(''date_input'')) }}) AS VARCHAR), ''Q'', CAST(QUARTER({{ jexpr(p(''date_input'')) }}) AS VARCHAR))"
        }
    }'
    )
SELECT
    quarter_from_date := NORMALIZED_QUARTER(DATE '2025-08-15'),
    quarter_from_timestamp := TIMESTAMP '2025-10-15 14:30:00'.NORMALIZED_QUARTER() -- also works with chaining syntax
;
Result
QUARTER_FROM_DATE VARCHARQUARTER_FROM_TIMESTAMP VARCHAR
2025Q32025Q4

Last update at: 2026/06/20 10:08:10