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
| Parameter | Type | Required | Description |
|---|---|---|---|
config | JSON | Yes | JSON 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
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))"
}
}') AS normalized_quarter
SELECT
normalized_quarter(DATE '2025-08-15') as QUARTER_FROM_DATE,
TIMESTAMP '2025-10-15 14:30:00'.normalized_quarter() as QUARTER_FROM_TIMESTAMP -- also works with chaining syntax
;Result
| QUARTER_FROM_DATE VARCHAR | QUARTER_FROM_TIMESTAMP VARCHAR |
|---|---|
| 2025Q3 | 2025Q4 |