Language reference
Len (string length)
Syntax
Len(<string>)
π Len(name) → name_length (Users)
Description
Len returns the number of characters in a string — useful for validating input lengths, filtering by name size, or reporting field widths.
Technical Description
Len(s: STRING) → NUMBER. Returns the character count of s, counted in code points — so a character outside the basic multilingual plane, an emoji say, counts once. NULL input returns NULL. PURE and DETERMINISTIC, so the optimizer may fold it on constants.
Examples
Length of each name:
π name, Len(name) → chars (Users)
PROJECT name, Len(name) -> chars (Users)
Filter to short codes:
σ Len(code) <= 5 (Products)
σ Len(code) ≤ 5 (Products)
SELECT Len(code) <= 5 (Products)
Find suspiciously long entries:
σ Len(description) > 1000 (Articles)
SELECT Len(description) > 1000 (Articles)
Pushdown
SQL: folds to CHAR_LENGTH(<s>) on the MySQL, PostgreSQL and DuckDB dialects, and to LENGTH(<s>) on SQLite, which lacks the name but counts the same way, and to CHARACTER_LENGTH(<s>, CODEUNITS32) on Db2, whose own functions count bytes unless told otherwise. Each counts a string in characters, which is what relix counts in, and each was put on that list by running it against text holding a character outside the basic multilingual plane. H2 (the generic dialect) counts UTF-16 code units, so its same-named function answers differently for such text, and is offered nothing.
Limitations
Operates on STRING values; a non-string argument is an evaluation error. NULL in → NULL out.