substring
substring(value: string, start: int64, [length: int64]?) -> string
Returns a contiguous slice of a string. Non-negative start is a zero-based offset from the left edge of the string (the compiler adjusts this to the engine’s 1-based SUBSTRING convention). Negative start follows the same “from the right” indexing rules as SQL SUBSTRING for negative origins.
If value or start is null, the result is null. With three arguments, if length is null the result is null; a non-positive length yields an empty string. If start is out of range for the string at compile time, the folded result is an empty string. Indices and lengths are measured in Unicode scalar values, not bytes.
Domain
This is a scalar function (calculates a single output value for a single input row).
Categories
Examples
make_col rest:substring(message, 1)
Takes everything after the first character using a zero-based start index, leaving the remainder of the string.
make_col prefix:substring(trace_id, 0, 8)
Extracts the first eight characters from a trace identifier for a compact grouping key.
Updated 21 days ago