Relix

Language reference

Find an operator

Every operator, predicate and function, with the glyph and keyword forms that reach it. These are the same names the engine's own documentation lookup resolves.

Operators

Joins

Set operations

Aggregates

Predicates

Literals

PageWritten asWhat it does
String, number and boolean"…" scalar-literals literal literals string string literal strings number number literal numbers quote quotes escape boolean true false String, number and boolean literals
Datedate '…' date-literal date literal Date literal
Timetime '…' time-literal time literal Time literal
Timestamptimestamp '…' timestamp-literal timestamp literal Timestamp literal
TimestampTztimestamptz '…' timestamptz timestamptz literal timestamp with time zone datetimeoffset offset A timestamp that keeps its offset
Durationduration '…' duration-literal duration literal interval Duration literal
Array[expr, …] array-construction array construction array list Array construction literal
Struct{name: expr} struct-construction struct construction struct record tuple tuple constructor row value composite named_struct object Struct construction literal
Truth relationsunit truth-relations truth relation empty dee dum Zero-column truth relations

Language and scripts

PageWritten asWhat it does
Assignment:= assignment Name a relation expression
Sourcesource Declare an external data source
HTTP sourcehttp http-source http source HTTP / JSON data source
Connectionconnection Declare a named database connection
GEDCOM sourcegedcom gedcom-source gedcom source ged Read a GEDCOM genealogy file as individuals and families
MongoDB sourcemongodb mongodb-source mongodb source mongo Read a MongoDB collection as a relation
JSON sourcejson json-source json source json file records Read a JSON file as a relation, with no declared columns
Generator sourcegenerator generator-source generator source naturals primes A generated series of rows: Range, Naturals, Primes
Envenv environment env statement Name the environment file and profile a script's placeholders come from
Log sourcelog-source log source access log clf Read a web server access log as a typed relation
Namespacenamespace Declare a namespace
Importimport Import definitions from another script
Inline table[| … |] inline-table inline table Literal relation value written inline
Defdef function definition define function create function user-defined function udf Define a scalar or relation function
Def relationdef relation def-relation tvf Define a relation-valued (table-valued) function
With ordinalitywith ordinality with-ordinality ordinality Attach a row number when unnesting
Relaterelate relationship relationships Declare a named, bounded relationship between two relations
Delimited identifier`name` delimited-identifier delimited identifier backtick quoted-identifier Backtick a name that collides with a reserved word
Bound parameter$name parameter parameters bound parameter bind $ A value supplied when the query runs, never written into its text
Comments-- comment comments /* Ignore text: -- to end of line, / … / for a block
Operator spellingsσ / select spellings spelling ascii unicode glyph glyphs syntax Every operator's Unicode glyph and its ASCII equivalent
Grammarebnf grammar bnf The whole language as one EBNF grammar
Relation catalogrelix.relations introspection-relations relations boundedness bounded unbounded row_count relix.relations — every relation the script can name, its kind, size and whether it ends
Column catalogrelix.columns introspection-columns columns distinct_count null_count relix.columns — every column of every relation, its type and its distinct and NULL counts
Logical plan catalogrelix.plan introspection-plan plan relix.dependencies dependencies expression tree relix.plan / relix.dependencies — every view's expression tree, and which view reads which relation, as rows
Connection catalogrelix.connections introspection-connections connections relix.connections — the declared connections, by name and dialect, with nothing secret
Introspection stdlibrelix.unused introspection introspection-stdlib relix.deps relix.impact relix.find relix.schema relix.cycles relix.funcs relix.unused / deps / impact / find / schema / cycles / funcs — introspection shipped as Relix
Observability feedrelix.events introspection-events events relix.rules feed relix.events / relix.rules — the previous run's engine decisions, as rows
Component inventoryrelix.version introspection-version version components inventory relix.version — the engine, the facade and every discovered provider, as rows
Candidate keysrelix.keys introspection-keys keys candidate key candidate keys relix.keys — the collected candidate keys of every relation, one row per key column
Reserved namespacerelix.catalog introspection-catalog catalog reserved namespace relix.catalog — the relix.* surface describing itself
CASEcase case when case expression searched case simple case when then decode conditional A value chosen by conditions: CASE WHEN c THEN a ELSE b END
Subquery( relation ) subquery sub-query scalar subquery correlated subquery correlated nested query inner query select in select value from another table A relation used as a value: its one column in its one row, per row when it reads the row
COLLATEcollate collation nocase case-insensitive case insensitive ignore case binary collation locale Compare, sort and group strings under a collation: s COLLATE NOCASE
CASTcast convert conversion type conversion to_number to_string try_cast parse value Convert a value to a type: CAST(x AS NUMBER)
AT TIME ZONEat time zone at-time-zone time zone timezone conversion zone The wall-clock time in a zone: ts AT TIME ZONE 'Europe/London'
EXTRACTextract date part datepart date_part day of week iso week A field of a date or time: EXTRACT(WEEK FROM d)
Arithmetic and concatenation+ arithmetic * / % || concatenation concatenate concat operator remainder operator modulo Arithmetic and concatenation: + - * / % ||

Advanced operators

PageWritten asWhat it does
Closureclosure rclosure ⁺ transitive-closure linked chain either direction reachable Transitive / reflexive-transitive closure
Clustercluster Partition rows into clusters
Covercover Combinatorial test-suite generation (t-way covering arrays)
Downsampledownsample Reduce row density over a time / numeric axis
Fixpointfix fixpoint General monotone recursion (least fixpoint)
Iterateiterate iteration pagerank convergence Replace-each-round iteration: PageRank, state machines, convergence
Optimizeoptimize LP / ILP declarative optimisation
Pathpath levels below steps hops distance Enumerate shortest / all paths in a graph
Record linkagerecord-linkage linkage entity-resolution deduplication dedupe fuzzy-match similarity-join Find rows that probably describe the same thing: similarity join, best match, CLUSTER
Samplesample bernoulli tablesample Bernoulli (row-probability) random sampling
Reservoirreservoir reservoir-sample order by random() order by random Reservoir (fixed-size) random sampling
Sessionizesessionize Gap-and-island / sessionisation
Solvesolve Constraint solving over a relation
Top-Ktop topk top-k top with ties Return top-K rows per group
Tracetrace Diagnostic operator — print rows as they pass through
Optimizeroptimizer optimiser rules rewrites Logical rewrite rules — what fires, when, and how to see it
Pushdownpushdown push-down explain What folds into a backend and what the engine computes

Functions

PageWritten asWhat it does
Lenlen String length
UCaseucase Upper-case
LCaselcase Lower-case
Trimtrim Strip surrounding whitespace
LTrimltrim Strip leading whitespace
RTrimrtrim Strip trailing whitespace
Leftleft Leftmost characters
Rightright Rightmost characters
Midmid Substring
InStrinstr Find substring position
Chrchr Character from code
Ascasc Code of first character
Replacereplace Substitute text
LPADlpad Pad on the left
RPADrpad Pad on the right
REVERSEreverse Characters in reverse order
REPEATrepeat A string written n times
SPLIT_PARTsplit_part One field of a delimited string
CONCAT_WSconcat_ws Join with a separator, skipping NULLs
INITCAPinitcap Capitalise each word
MD5md5 A string's MD5 digest, in hex
SHA1sha1 A string's SHA-1 digest, in hex
SHA256sha256 A string's SHA-256 digest, in hex
SHA2sha2 A string's SHA-2 digest of a given length, in hex
HASHBYTEShashbytes SQL Server's digest by algorithm name, in hex
STANDARD_HASHstandard_hash Oracle's digest by algorithm name, in hex
REGEXP_LIKEregexp_like Does a regular expression match
REGEXP_REPLACEregexp_replace Replace a regular-expression match
REGEXP_SUBSTRregexp_substr The text a regular expression matches
REGEXP_COUNTregexp_count How many times a regular expression matches
CHARchar Character from code
CHAR_LENGTHchar_length String length
LENGTHlength String length
LOWERlower Lower-case
REPLICATEreplicate A string written n times
UPPERupper Upper-case
SUBSTRINGsubstring Part of a string, as SQL counts it
SUBSTRsubstr Part of a string, as SQL counts it
STRPOSstrpos Position of a substring
CHARINDEXcharindex Position of a substring, SQL Server's order
ASCIIascii Code of the first character
CONCATconcat Join values as text, skipping NULLs
JSON_VALUEjson_value A scalar read out of JSON text
JSON_QUERYjson_query An object or array read out of JSON text
JSON_EXTRACTjson_extract Any value read out of JSON text
Levenshteinlevenshtein Edit distance between two strings
EditSimilarityeditsimilarity Edit distance as a score from 0 to 1
JaroWinklerjarowinkler Similarity of short strings, favouring a shared start
Trigramtrigram Overlap of three-character pieces
Soundexsoundex Phonetic key for a name
Absabs Absolute value
Intint Floor to integer
Fixfix Truncate toward zero
Roundround Round to nearest
Ceilceil Round up
Sgnsgn Sign
Sqrsqr Square root
Loglog Logarithm
Log10log10 Base-10 logarithm
Expexp Exponential
Sinsin Sine
Coscos Cosine
Tantan Tangent
Atnatn Arctangent
Asinasin Arcsine
Acosacos Arccosine
Atan2atan2 Two-argument arctangent
Degreesdegrees Radians to degrees
Radiansradians Degrees to radians
Pipi The constant π
Powerpower Raise to a power
Modmod Remainder
Randrand Random number
CEILINGceiling Round up
FLOORfloor Floor to integer
RANDOMrandom Random number
SIGNsign Sign
SQRTsqrt Square root
LNln Logarithm
TRUNCtrunc Truncate towards zero, to places
TRUNCATEtruncate Truncate towards zero, to places
NOWnow current_timestamp localtimestamp Current timestamp
CURRENT_DATEcurrent_date Today
CURRENT_TIMEcurrent_time Current clock time
YEARyear Extract year
MONTHmonth Extract month
DAYday Extract day of month
HOURhour Extract hour
MINUTEminute Extract minute
SECONDsecond Extract second
DOWdow Day of week, Sunday 0
ISODOWisodow ISO day of week, Monday 1
DOYdoy Day of year
WEEKweek ISO week number
ISOYEARisoyear ISO week-numbering year
QUARTERquarter Quarter of the year
EPOCHepoch Seconds since 1970
TIMEZONEtimezone Wall-clock time in a zone
FROM_TZfrom_tz A local wall-clock time read as an instant in a zone
MAKE_DATEmake_date A date from its parts
LAST_DAYlast_day Last day of the month
DATEDIFFdatediff timestampdiff Calendar units between two dates
DATE_TRUNCdate_trunc Truncate timestamp to a unit
DATEADDdateadd Add a number of units to a date
ADD_MONTHSadd_months Move a date by whole months, as Oracle does
DATE_ADDdate_add Add an interval to a date, as MySQL writes it
DATE_SUBdate_sub Subtract an interval from a date, as MySQL writes it
AGEage The years, months and days between two dates
MINUTESminutes Measure a duration in minutes
SECONDSseconds Measure a duration in seconds
DAYSdays Measure a duration in days
to_dateto_date Parse a string to a DATE
to_timestampto_timestamp Parse a string to a TIMESTAMP
to_timeto_time Parse a string to a TIME
to_timestamptzto_timestamptz A TIMESTAMPTZ from text or a timestamp
DATEFROMPARTSdatefromparts A date from its parts
EOMONTHeomonth Last day of the month
TIMESTAMPADDtimestampadd Add a number of units to a date
IIfiif if Inline if / conditional value
Nznz Null-to-value
Coalescecoalesce ifnull nvl First non-null
NULLIFnullif Value-to-null
Switchswitch Multi-branch conditional value
Choosechoose Pick a value by position
IsNullisnull Test for missing value
IsNumericisnumeric Test if value looks numeric
CStrcstr Convert to string
CIntcint Convert to integer
CDblcdbl Convert to number
CBoolcbool Convert to boolean
TO_CHARto_char Format a date or number as text
FORMATformat A number with grouped digits
Entriesentries Read an object's fields as rows
ARRAY_TO_STRINGarray_to_string Join an array's elements into one string
CARDINALITYcardinality The number of elements in an array
ARRAY_LENGTHarray_length The number of elements in an array
LEASTleast Smallest of several values
GREATESTgreatest Largest of several values