Custom scalar logic¶
Part of Streaming Transformations. See all pages in this section.
A PIPE may call your own scalar user-defined functions, so per-row logic that would otherwise need a downstream job can run at ingest time. UDFs are permitted in both positions the pipe subquery offers:
- In the
SELECTlist, to compute a derived column. - In the
WHEREpredicate, to filter on a computed value.
Supported handler languages are SQL and JavaScript. SECURE, IMMUTABLE, and MEMOIZABLE SQL UDFs are also supported; a memoizable UDF takes no arguments, so it can contribute a looked-up constant but can’t itself receive a streamed value.
Example — A derived column from a SQL UDF¶
Map a site code to its local timezone, and land the event time already converted:
Example — Filtering on a JavaScript UDF result¶
A JavaScript UDF may appear in the WHERE predicate. Here only readings the function classifies as out of range are ingested:
As with any WHERE clause in a pipe, records that do not satisfy the predicate are discarded silently and do not appear in load history.
Usage notes¶
- Avoid long-running UDFs to minimize impact on stream throughput and latency.
Limitations¶
- SQL and JavaScript scalar UDFs only; Python, Java, and Scala are currently unsupported as are all UDAFs, UDTFs, and external functions.
See also¶
The Scenarios show real-world use cases that combine custom scalar logic with other transformations. For the complete syntax with all features combined, see the Reference.
Previous: Stream enrichment · Next: Lateral Flatten