Skip to main content

Scalar Functions

All scalar functions available in LynxFlow expressions. Functions marked null_on_failure return null when the input is invalid; those with a strict variant (name!) raise a query error instead.

Conversion

FunctionParamsResultFallibilityStrictDescription
int(x: any)intnull_on_failureint!Cast to int; null on failure.
float(x: any)floatnull_on_failurefloat!Cast to float; null on failure.
string(x: any)stringinfallible-Render any value as a string.
bool(x: any)boolnull_on_failurebool!Cast to bool; null on failure.
timestamp(x: any, layout: string?)timestampnull_on_failuretimestamp!Parse RFC3339 (or layout) to timestamp; null on failure.
duration(x: string)durationnull_on_failureduration!Parse a duration string ("100ms", "5m"); numbers use n * 1ms instead.

Conditional

FunctionParamsResultFallibilityStrictDescription
if(cond: bool, then: any, else: any)anyinfallible-Null condition yields null.
case(pairs: any...)anyinfallible-case(cond1, v1, cond2, v2, ...[, default]); trailing odd argument is the default.
remap(x: any, from: array, to: array, default: any?)anynull_on_failure-Map x through parallel from/to arrays; default is null.
coalesce(values: any...)anyinfallible-First non-null, non-missing argument.
nullif(a: any, b: any)anyinfallible-Null when a == b, else a.
exists(field: any)boolinfallible-True when the field is present, even if the value is null.
is_null(field: any)boolinfallible-True when present with an explicit null value.
is_missing(field: any)boolinfallible-True when the field was never extracted.
typeof(x: any)stringinfallible-Type name: string, int, float, bool, timestamp, duration, array, object, null, missing.

String

FunctionParamsResultFallibilityStrictDescription
len(x: any)intnull_on_failure-Length of a string (runes) or array (elements).
lower(s: string)stringnull_on_failure--
upper(s: string)stringnull_on_failure--
trim(s: string, chars: string?)stringnull_on_failure--
ltrim(s: string, chars: string?)stringnull_on_failure--
rtrim(s: string, chars: string?)stringnull_on_failure--
substr(s: string, start: int, len: int?)stringnull_on_failure-0-based start; negative counts from end.
replace(s: string, pattern: regex, with: string)stringnull_on_failure-Regex replace all.
replace_first(s: string, pattern: regex, with: string)stringnull_on_failure-Regex replace first match.
split(s: string, sep: string)arraynull_on_failure--
split_regex(s: string, pattern: regex)arraynull_on_failure-Split a string by regex matches.
split_part(s: string, sep: string, n: int)stringnull_on_failure-Return the 0-based split segment, or null when out of range.
index_of(x: any, needle: any)intnull_on_failure-0-based index in a string or array; null when not found.
count_substr(s: string, sub: string)intnull_on_failure-Count non-overlapping substring occurrences.
count_matches(s: string, pattern: regex)intnull_on_failure-Count regex matches.
lpad(s: string, n: int, char: string?)stringnull_on_failure-Left-pad a string to n runes; pad defaults to space.
rpad(s: string, n: int, char: string?)stringnull_on_failure-Right-pad a string to n runes; pad defaults to space.
repeat(s: string, n: int)stringnull_on_failure-Repeat a string n times.
translate(s: string, from: string, to: string)stringnull_on_failure-Replace characters from one set with characters from another.
levenshtein(a: string, b: string, damerau: bool?)intnull_on_failure-Edit distance between two strings.
jaro_winkler(a: string, b: string)floatnull_on_failure-Jaro-Winkler similarity between two strings.
join(arr: array, sep: string)stringnull_on_failure--
starts_with(s: string, prefix: string)boolnull_on_failure--
ends_with(s: string, suffix: string)boolnull_on_failure--
printf(format: string, args: any...)stringnull_on_failure--
urldecode(s: string)stringnull_on_failure--
urlencode(s: string)stringnull_on_failure-Encode a string for URL query components.
regex_escape(s: string)stringnull_on_failure-Escape a string for literal use in a regex pattern.
normalize_utf8(s: string, form: string?)stringnull_on_failure-Normalize Unicode text as nfc, nfd, nfkc, or nfkd.
punycode_encode(s: string)stringnull_on_failure-Encode a domain name with IDNA punycode.
punycode_decode(s: string)stringnull_on_failure-Decode an IDNA punycode domain name.
base64_decode(s: string)stringnull_on_failurebase64_decode!Decode standard base64; null on invalid input.
base64_encode(s: string)stringnull_on_failure-Encode a string as standard base64.
base64url_decode(s: string)stringnull_on_failurebase64url_decode!Decode raw URL-safe base64; null on invalid input.
base64url_encode(s: string)stringnull_on_failure-Encode a string as raw URL-safe base64.
hex(s: string)stringnull_on_failure-Encode a string as lowercase hexadecimal.
unhex(s: string)stringnull_on_failureunhex!Decode hexadecimal bytes; null on invalid input.
url_parse(s: string)objectnull_on_failure-Parse a URL into {scheme, host, port, path, query, fragment}.
url_domain(s: string)stringnull_on_failure-Parse a URL and return its host.
url_etld1(s: string)stringnull_on_failure-Return the registrable domain using the public suffix list.
url_tld(s: string)stringnull_on_failure-Return the public suffix using the public suffix list.
url_path(s: string)stringnull_on_failure-Parse a URL and return its path.
url_protocol(s: string)stringnull_on_failure-Parse a URL and return its scheme/protocol.
url_param(s: string, name: string)stringnull_on_failure-Return the first URL query parameter value by name.
url_strip_query(s: string, fragment: bool?)stringnull_on_failure-Remove the URL query string; optionally remove fragment too.
path_normalize(s: string)stringnull_on_failure--
useragent_parse(s: string)objectnull_on_failure-Optional build.
FunctionParamsResultFallibilityStrictDescription
has(field: string, term: string)boolnull_on_failure-Whole-token match, always case-insensitive; FST term index. Fast.
contains(field: string, sub: string)boolnull_on_failure-Substring, case-insensitive; bloom-assisted scan. Moderate.
contains_cs(field: string, sub: string)boolnull_on_failure-Case-sensitive substring.
has_any(field: string, terms: array)boolnull_on_failure-True when any term is present as a whole token.
has_all(field: string, terms: array)boolnull_on_failure-True when all terms are present as whole tokens.
contains_phrase(field: string, phrase: string)boolnull_on_failure-Case-insensitive phrase substring match.
contains_any(field: string, subs: array)boolnull_on_failure-Case-insensitive match for any substring.
contains_any_cs(field: string, subs: array)boolnull_on_failure-Case-sensitive match for any substring.
matches_any(s: string, patterns: array)boolnull_on_failure-True when any regex pattern matches.
glob(field: string, pattern: string)boolnull_on_failure-Glob match, case-sensitive; literal-prefix extraction when possible.
has_glob(field: string, pattern: string)boolnull_on_failure-Whole-token glob match (*, ?, -escapes), always case-insensitive; FST term-dictionary expansion. Moderate.
tokens(s: string)arraynull_on_failure-Return lowercase tokenizer-contract tokens.

Regex

FunctionParamsResultFallibilityStrictDescription
matches(s: string, pattern: regex)boolnull_on_failure-Regex match (linear-time engine). Slow tier; (?i) for case-insensitive.
extract(s: string, pattern: regex)stringnull_on_failure-First capture group.
extract_all(s: string, pattern: regex)arraynull_on_failure--
extract_groups(s: string, pattern: regex)objectnull_on_failure-Return named regex capture groups as an object.

Math

FunctionParamsResultFallibilityStrictDescription
abs(x: number)numbernull_on_failure--
round(x: number, digits: int?)floatnull_on_failure--
floor(x: number)intnull_on_failure--
ceil(x: number)intnull_on_failure--
sqrt(x: number)floatnull_on_failure--
ln(x: number)floatnull_on_failure--
log(x: number, base: number?)floatnull_on_failure-Base 10 by default.
exp(x: number)floatnull_on_failure--
pow(x: number, y: number)floatnull_on_failure--
clamp(x: number, lo: number, hi: number)numbernull_on_failure--
bucket(x: number, bounds: array)numbernull_on_failure-Snap x to the largest bound <= x.
sin(x: number)floatnull_on_failure--
cos(x: number)floatnull_on_failure--
tan(x: number)floatnull_on_failure--
asin(x: number)floatnull_on_failure--
acos(x: number)floatnull_on_failure--
atan(x: number)floatnull_on_failure--
atan2(y: number, x: number)floatnull_on_failure--
is_finite(x: number)boolnull_on_failure-True for numeric values that are neither NaN nor infinite.
is_nan(x: number)boolnull_on_failure-True for numeric NaN values.
bit_and(a: int, b: int)intnull_on_failure-Bitwise AND for integers.
bit_or(a: int, b: int)intnull_on_failure-Bitwise OR for integers.
bit_xor(a: int, b: int)intnull_on_failure-Bitwise XOR for integers.
bit_shl(a: int, n: int)intnull_on_failure-Shift an integer left by n bits.
bit_shr(a: int, n: int)intnull_on_failure-Shift an integer right by n bits.
greatest(values: any...)anynull_on_failure-Largest scalar value; null propagates.
least(values: any...)anynull_on_failure-Smallest scalar value; null propagates.

Humanize

FunctionParamsResultFallibilityStrictDescription
humanize_bytes(n: number)stringnull_on_failure-Format bytes with binary units (KiB, MiB, ...).
humanize_count(n: number)stringnull_on_failure-Format counts with SI suffixes (K, M, ...).
humanize_duration(d: duration)stringnull_on_failure-Format a duration in readable units.
bar(x: number, lo: number, hi: number, width: int?)stringnull_on_failure-Render a fixed-width ASCII bar for x in [lo, hi].

Time

FunctionParamsResultFallibilityStrictDescription
now()timestampinfallible-Query start time (stable within one query).
bin(x: any, width: any, origin: any?)anynull_on_failure-Snap a timestamp or number to a bucket boundary; optional origin shifts the bucket grid.
strftime(ts: timestamp, format: string, tz: string?)stringnull_on_failure-Format a timestamp in UTC or an IANA timezone.
strptime(s: string, format: any)timestampnull_on_failurestrptime!Parse with one layout or the first matching layout in an array.
time_of_day(ts: timestamp, tz: string?)durationnull_on_failure-Duration since midnight in UTC or an IANA timezone.
day_of_week(ts: timestamp, tz: string?)intnull_on_failure-0 = Sunday; optional timezone controls the local day.
from_unix(n: int, unit: string)timestampnull_on_failure-Convert Unix epoch in s, ms, us, or ns to a timestamp.
to_unix(ts: timestamp, unit: string)intnull_on_failure-Convert a timestamp to Unix epoch in s, ms, us, or ns.
date_trunc(ts: timestamp, part: string, tz: string?)timestampnull_on_failure-Truncate a timestamp to a calendar part.
date_part(ts: timestamp, part: string, tz: string?)intnull_on_failure-Extract a calendar part from a timestamp.
date_diff(a: timestamp, b: timestamp, part: string)intnull_on_failure-Difference b - a in a calendar unit.
timestamp_guess(s: string)timestampnull_on_failure-Parse a timestamp using common layouts.

Hash

FunctionParamsResultFallibilityStrictDescription
md5(s: string)stringnull_on_failure--
sha1(s: string)stringnull_on_failure--
sha256(s: string)stringnull_on_failure--
xxhash64(s: string)stringnull_on_failure--

Network

FunctionParamsResultFallibilityStrictDescription
cidr_match(cidr: string, ip: string)boolnull_on_failure--
ip_parse(s: string)objectnull_on_failure--
is_ip(s: string)boolinfallible--
is_ipv4(s: string)boolinfallible--
is_ipv6(s: string)boolinfallible--
ip_to_int(ip: string)intnull_on_failure-Convert an IPv4 string to a 32-bit integer; IPv6 returns null.
ip_from_int(n: int)stringnull_on_failure-Convert a 32-bit integer to an IPv4 string.
ipmask(mask: string, ip: string)stringnull_on_failure--

Array

FunctionParamsResultFallibilityStrictDescription
slice(x: any, start: int, end: int?)anynull_on_failure-Slice an array or string with 0-based indexes; negative indexes count from the end.
array_concat(arrays: array...)arraynull_on_failure--
array_distinct(arr: array)arraynull_on_failure--
array_sort(arr: array)arraynull_on_failure--
array_sum(arr: array)numbernull_on_failure-Sum numeric array elements.
array_avg(arr: array)floatnull_on_failure-Average numeric array elements.
array_min(arr: array)anynull_on_failure-Minimum comparable array element.
array_max(arr: array)anynull_on_failure-Maximum comparable array element.
array_compact(arr: array)arraynull_on_failure-Remove consecutive duplicate elements.
array_deltas(arr: array)arraynull_on_failure-Adjacent differences with leading null.
array_cumsum(arr: array)arraynull_on_failure-Cumulative sums across array elements.
generate_series(start: any, stop: any, step: any?)arraynull_on_failure-Series from start to stop, excluding stop. Integers use integer steps; timestamps require a duration step.
zip(arrays: array...)arraynull_on_failure-Zip equal-length arrays into arrays of tuples.
flatten(arr: array)arraynull_on_failure-One level.
any(arr: array, pred: lambda)boolnull_on_failure-any(tags, t -> t.name == "vip")
all(arr: array, pred: lambda)boolnull_on_failure--
filter(arr: array, pred: lambda)arraynull_on_failure--
map(arr: array, fn: lambda)arraynull_on_failure--
reduce(arr: array, init: any, fn: lambda)anynull_on_failure-Fold array elements with (acc, x) -> expr.
array_reduce(agg: string, arr: array)anynull_on_failure-Apply a supported aggregate name to an array; duplicate names such as sum use array_sum instead.
array_count(arr: array, pred: lambda)intnull_on_failure-Count elements matching a predicate.
array_has_any(a: array, b: array)boolnull_on_failure--
array_has_all(a: array, b: array)boolnull_on_failure--
array_intersect(a: array, b: array)arraynull_on_failure-Elements from a that also appear in b, preserving a order.
array_except(a: array, b: array)arraynull_on_failure-Elements from a that do not appear in b, preserving a order.

Object

FunctionParamsResultFallibilityStrictDescription
keys(obj: object)arraynull_on_failure--
values(obj: object)arraynull_on_failure--
merge(a: object, b: object)objectnull_on_failure-Right side wins on key collision.
has_key(obj: object, key: string)boolnull_on_failure--
entries(obj: object)arraynull_on_failure-Convert an object to sorted {key, value} entries.
from_entries(arr: array)objectnull_on_failure-Build an object from {key, value} entries.
to_json(x: any)stringnull_on_failure--
from_json(s: string)anynull_on_failurefrom_json!Null on invalid JSON, never the original string.
is_json(s: string)boolinfallible-True when a string contains valid JSON.
json_value(s: string, path: string)anynull_on_failure-Extract a scalar JSON value by path.
json_query(s: string, path: string)stringnull_on_failure-Extract a raw JSON fragment by path.

Generated from the LynxFlow registry. See RFC-002 for the full specification.