Skip to Content
OpenETL
Reference

SQL restrictions and errors

Look up refused SQL statements, clauses, names and stream operations.

Edit on GitHub

Use this reference when a SQL transform fails to plan or evaluate.

What's refused

The engine plans the statements when openetl plan or openetl apply checks a pipeline, and again when each sync or continuous job starts. A statement it refuses is a problem in the plan, written as transform.sql:LINE:COLUMN: MESSAGE, and openetl apply refuses the pipeline:

  problems:
    transform.sql:16:18: there's no column mail; there are id, email, name, country, updated_at

If a sync or a continuous pipeline's job starts with statements that the engine refuses, it fails with CONFIG_INVALID, and its error has the same messages.

Statements of other kinds

These are refused, each at the place it is written. The message says what was found.

WhatMessage
A window function without OVERrank is a window function, which takes OVER: rank(…) OVER (PARTITION BY … ORDER BY …)
JOINa join: transforms don't run joins yet (tier 4)
Two relations in FROMreading two relations: transforms don't run joins yet (tier 4)
A subquery in an expression, such as IN (SELECT …) or EXISTS (…)a subquery: transforms don't run joins yet (tier 4)
GROUP BY without a windowGROUP BY without a window: transforms don't run updating statements yet (tier 5)
An aggregate, such as count(*) or sum(x), without a windowan aggregate without a window: transforms don't run updating statements yet (tier 5)
HAVING without a windowHAVING without a window: transforms don't run updating statements yet (tier 5)
DISTINCT, DISTINCT ONDISTINCT: transforms don't run updating statements yet (tier 5)
A function that is not in the list, such as a user-defined functionmy_udf isn't a function transforms can call

A view of one of these kinds is refused too, where the view is defined.

Clauses and statements

WhatMessage
ORDER BYa stream has no order, so ORDER BY is refused
LIMIT, OFFSETa stream has no end, so LIMIT and OFFSET are refused
FETCHa stream has no end, so FETCH is refused
UNION, INTERSECT, EXCEPTUNION, INTERSECT and EXCEPT aren't supported
WITHWITH isn't supported: name the query with CREATE VIEW, before the statements that read it
SELECT without FROMa SELECT reads a stream or a view: it needs a FROM
VALUESa statement reads a stream or a view, not VALUES
UNNEST in FROMUNNEST goes in the SELECT list: SELECT unnest(list) AS item FROM …
INSERT INTO x (a, b) …INSERT INTO takes an output's name and a SELECT, without a list of columns: the SELECT names the output's columns
A computed column without ASname this column: lower(region) AS name
A SELECT on its owna SELECT on its own writes nothing: write INSERT INTO output SELECT …, or name it with CREATE VIEW
Other statements, such as UPDATE, DELETE or CREATE TABLEa transform's statements are INSERT INTO … SELECT and CREATE VIEW … AS SELECT, not DELETE FROM
No INSERT INTOa transform writes at least one output, with INSERT INTO … SELECT
A view more than 32 views deepview v32 is 33 views deep, counting each view it reads through: views go at most 32 deep; read a view nearer the stream, or merge views into one

Expressions

Expressions take the operators, syntax and types that SQL expressions and types lists. Other syntax that the parser reads is refused at the place it is written, with a message that names it. Some examples:

WhatMessage
An operator that is not in the list, such as ^, &, |, #, <<, >>, @> or ~~^ isn't an operator transforms take: power(x, y) raises x to the power y, with the operator, and what to write where there is an equivalent
A type that CAST does not take, such as CHAR(5), FLOAT(54), TIMESTAMP(3) or JSONCHAR(5) isn't a type transforms take: CHAR pads a string with spaces to its length, which transforms don't: write VARCHAR(N) to cut a string to N characters, and rpad(s, n) to pad it, with the type, and what to write
A typed literal other than DATE '…', TIME '…', TIMESTAMP '…' and TIMESTAMPTZ '…', such as TIME WITH TIME ZONE '12:00'TIME WITH TIME ZONE '…' isn't a literal transforms take: write DATE '…', TIME '…', TIMESTAMP '…' or TIMESTAMPTZ '…', or a CAST
INTERVAL with a fraction before a unit other than SECOND, or more than a number before its unit, such as INTERVAL '1.5' DAYan INTERVAL with its unit after the quotes takes a whole number, or a number of seconds, such as INTERVAL '2' DAY: write INTERVAL '1 day 12 hours' for more than one unit
INTERVAL with another unit after the quotes, such as INTERVAL '1' WEEKan INTERVAL's unit after the quotes is YEAR, MONTH, DAY, HOUR, MINUTE or SECOND: write others inside the quotes, such as INTERVAL '2 weeks'
INTERVAL with TO or a precision, such as INTERVAL '1-2' YEAR TO MONTHan INTERVAL takes one unit, such as INTERVAL '2' DAY, without a precision or TO: write INTERVAL '1 year 2 months' for more than one
Another kind of string, such as N'…' or U&'…'a string is written '…', with '' for a quote, or E'…' with escapes
X'…' or B'…'X'…' and B'…' aren't supported: decode('…', 'hex') gives binary
ANY (…) or ALL (…) with another operator, such as x > ANY (list) or x = ALL (list)ANY (…) takes =, and ALL (…) takes <>: x = ANY(list) is whether list has x, and x <> ALL(list) whether it hasn't
COLLATECOLLATE isn't supported: strings compare by their bytes, in UTF-8
ESCAPE other than '\' with a pattern that is not a literal, such as LIKE pattern ESCAPE '!'ESCAPE takes a pattern written as a literal, unless it's ESCAPE '\': escape % and _ with a backslash in a pattern that isn't
A pattern that ends with its escape character, such as LIKE 'a!' ESCAPE '!'a LIKE pattern doesn't end with its escape character
ESCAPE with more than one characterESCAPE takes one character, or '' for none
A slice with a step, such as list[1:5:2]a slice takes no step, list[a:b:step]: write list[a:b]
A struct's field read with a dot, such as s.a or (s).as.a reads a field with a dot, which transforms don't: write s['a']
A row of values, such as (a, b) = (1, 2)a row of values in parentheses isn't supported: compare each value on its own
RESPECT NULLSfirst_value(…) RESPECT NULLS isn't supported: leave it out
An argument by name, such as f(x => 1)f takes its arguments in order, not by name
ORDER BY in a function's arguments, such as array_to_string(tags, ',' ORDER BY tag)array_to_string takes its arguments without ORDER BY
NULLS FIRST or NULLS LAST in OVER or WITHIN GROUPNULLS FIRST and NULLS LAST aren't supported
SELECT ALLSELECT ALL isn't supported: write SELECT
Types in FROM's alias, such as FROM orders AS o (a INT)FROM's alias is a name, and the names of the columns, as AS t (a, b), without their types
A column read, or named with AS, whose name starts with __openetl___openetl_x starts with __openetl_, as the engine's own columns do: give it another name

Names and columns

WhatMessage
A stream or view that is not therethere's no stream or view nope
FROM an outputcleaned is an output, and FROM reads a source's stream or a view: name the SELECT that writes it with CREATE VIEW, and read that
Two statements that write one outputx is written by an earlier statement: one statement writes each output
An output or a view whose name starts with _openetl, in any caseoutput _openetl_markers: names that start with _openetl are OpenETL's own
A view read before it is definedview later is defined after this statement: define a view before the statements that read it
A column that is not therethere's no column nope; there are id, region, amount, created_at
A quoted column in another casethere's no column "employee_id": a quoted name matches exactly, so write "EMPLOYEE_ID", or the name unquoted
A name that fits two columns or streamsid fits the columns "id" and "ID", which differ only by case: quote the name to pick one
A column name used twicethere's already a column id: give this one another name with AS
Types that do not combineexpressions have incompatible types (has type Utf8; has type Int64)
A type an output cannot holdcolumn nothing is Null, which an output can't hold: CAST it to a type it can

Group windows

WhatMessage
A stream without an event timeorders has no event time, which a group window goes by: set eventTime on the stream in source.streams
A window over another columntumble goes by the event time of logins, at: write tumble("at", …)
A window outside GROUP BYtumble is a group window, which goes in GROUP BY: select window_start and window_end for its bounds
window_start or window_end in WHEREwindow_start is a window's bound, and WHERE runs before rows are grouped: compare it in HAVING
Two windowsa group window groups by one window: tumble, hop or session
ROLLUP, CUBE, GROUPING SETSa group window groups by its window and columns, without ROLLUP, CUBE or GROUPING SETS
A computed group keya group window groups by columns of orders, renamed or not, beside its window: lower(orders.region) is computed
A group key of a list or a structa group window can't group by tags, of type List(Utf8)
A size in monthstumble's sizes are in days, hours, minutes or seconds, as a month's length varies
A size of zero or lesstumble's sizes are more than zero, and under 290,000 years
A hop's slide larger than its sizehop's slide is at most its size, so every row is in a window: hop(time, slide, size)
A hop with more than 1,000 windows a rowhop puts each row in at most 1000 windows: its size over its slide is more
An aggregate it does not run, such as stddevstddev isn't an aggregate transforms run: a group window takes count, sum, min, max, avg, approx_distinct, median and percentile_cont
DISTINCT in an aggregatecount(DISTINCT …) isn't supported: approx_distinct(x) estimates how many distinct values x has
An output without window_starta group window's output keeps window_start, which with its group keys is its primary key: select window_start
An output without a group keya group window's output keeps its group keys, which with window_start are its primary key: select region
The window itself in the SELECT listselect a window's bounds as window_start and window_end, not the window
A group window in a viewa view is row-wise, so it can't group by a window: group in the INSERT INTO … SELECT that reads the view
A group window in a subquerya group window is in the statement's own SELECT, not in a subquery's
A group window over a changelog streamchanges is a changelog, and a group window groups appended rows: transforms don't run updating statements yet (tier 5)

The plan also has a problem where a group window's stream is read in a way that the window cannot take (Reads), and where a stream sets watermark.lateness and the window's output is not merged.

Window functions

WhatMessage
A stream without an event timeorders has no event time, which OVER goes by: set eventTime on the stream in source.streams
ORDER BY another column, or no ORDER BYOVER goes by the event time of orders, created_at: write ORDER BY created_at
ORDER BY the event time and other columnsOVER orders by the event time alone, which ties don't change: write ORDER BY created_at
ORDER BY … DESC, other than in a dedupeOVER's frames end at the current row in event-time order: write ORDER BY created_at without DESC
ROW_NUMBER() selected, not comparedROW_NUMBER() deduplicates, keeping the rows where it's 1: compare it = 1 in QUALIFY, or in the WHERE of a SELECT that reads it; count(*) OVER (… ROWS UNBOUNDED PRECEDING) numbers every row
ROW_NUMBER() without PARTITION BYROW_NUMBER() … = 1 keeps a row for each key of its PARTITION BY: partition by the columns that identify a row
A dedupe that doesn't select a PARTITION BY columna deduplicated output keeps its PARTITION BY columns, which are its primary key: select customer
ROW_NUMBER() and another function OVER in a statementROW_NUMBER() … = 1 deduplicates on its own: compute other functions OVER in a statement of their own
ROW_NUMBER() with an argument, FILTER or DISTINCTROW_NUMBER() takes nothing but OVER (…)
A frame that does not end at the current rowOVER's frames end at the current row: write ROWS or RANGE BETWEEN … PRECEDING AND CURRENT ROW
A frame that starts after the current rowa frame starts before the current row, or at it
GROUPSGROUPS frames aren't supported: write ROWS or RANGE
A RANGE offset that is a number, such as RANGE BETWEEN 5 PRECEDING AND CURRENT ROW, on a function other than lag or ROW_NUMBER()a RANGE frame's offset is an INTERVAL, such as INTERVAL '1 hour'
A RANGE offset in monthsa RANGE frame's offset is in days, hours, minutes or seconds, as a month's length varies
A RANGE offset in parts of a microseconda RANGE frame's offset is whole microseconds
A negative RANGE offset, or one that does not fit a 64-bit count of the event time's unit: about 292,000 years of microseconds, or about 292 years of nanosecondsa RANGE frame's offset is zero or more, and under 290,000 years
An event time that is not a timestamp, such as a numberOVER goes by a timestamp, not Int64, with the column's type
leadlead reads rows after the current one, and OVER's frames end at the current row: lag reads the rows before it
Another function, such as last_valuelast_value isn't a function OVER takes: OVER takes sum, count, min, max, avg, lag and first_value, and ROW_NUMBER() … = 1 to deduplicate
rankrank(): transforms don't run updating statements yet (tier 5)
dense_rankdense_rank(): transforms don't run updating statements yet (tier 5)
ROW_NUMBER() compared otherwise than = 1ROW_NUMBER() compared other than = 1, as in a top-N: transforms don't run updating statements yet (tier 5)
Two PARTITION BY or ORDER BY in a statementa statement's OVER clauses have one PARTITION BY and ORDER BY, by which one operator keeps their state: compute the others in a statement of their own
A computed PARTITION BY columnOVER partitions by columns of orders, renamed or not: lower(orders.region) is computed
A PARTITION BY that is not deterministicrandom() isn't deterministic, so it can't feed a window's partition
PARTITION BY a list or a structOVER can't partition by tags, of type List(Utf8)
DISTINCT in count, sum or avgcount(DISTINCT …) isn't supported over a frame
IGNORE NULLSfirst_value(…) IGNORE NULLS isn't supported
FILTER on lag or first_valuelag takes no FILTER, which is for aggregates
lag's offset other than a constant of 1 or morelag's offset is a constant whole number, 1 or more
lag's default other than a constantlag's default is a constant, of the value's type
sum or avg of a value that is not a numberthere's no sum(Utf8): CAST the argument to a type it takes, with the function and the value's type
min, max, first_value or lag of a list, a struct or a mapfirst_value takes a number, text, binary, a boolean, a date, a time, a timestamp or a UUID, not List(Utf8), with the function and the value's type
OVER over a changelog streamcdc is a changelog, and OVER reads appended rows: transforms don't run updating statements yet (tier 5)
OVER and a group window in one statementa statement groups by a window or computes OVER, not both: compute OVER in a statement of its own
OVER in a viewa view is row-wise, so it can't compute OVER: compute it in the INSERT INTO … SELECT that reads the view
OVER in WHEREWHERE runs before OVER, so it can't read OVER's values: compare them in QUALIFY, or in the WHERE of a SELECT that reads this one
WINDOWWINDOW isn't supported: write each OVER (…) in full
OVER over another OVER's valuesOVER over the values of another OVER isn't supported: compute a statement's OVER over the stream's rows
unnest of OVER's rowsUNNEST of OVER's rows isn't supported: unnest the stream's rows before OVER, in a view

The plan also has a problem where the stream of OVER is read in a way that it cannot take (OVER reads), where the stream sets watermark.lateness and no group window reads it, and where the output is merged and its primary key does not hold the PARTITION BY columns, on a destination with several writer lanes (The output).

A dedupe has these problems in the plan, each about the spec, not the SQL. A job that starts with a first-row dedupe over a stream without dedupe.retention fails with CONFIG_INVALID and the same message.

WhatMessage
A first-row dedupe over a stream without dedupe.retentiontransform.sql:1:1: the dedupe writing "events_once", ROW_NUMBER() … = 1 in ascending order of the event time, keeps each key's first row, and stream "events" sets no dedupe.retention, how long it remembers a key: set source.streams[].dedupe.retention to a duration of event time, such as 24h, after which a key's next row is written again, or to unbounded, to remember every key
A first-row dedupe with a duration as its retention, over a stream that can repeat rows and is not read with full_refresh, into a destination that stages and applies or writes each commit in a transaction, and not merged into a destination that stages and applies, under a require above exactly_once_withindelivery.require: stream "events_once" gets exactly_once_within (a dedupe's output over superset inputs, which remembers a key 24h0m0s of event time from its first row, and writes a repeat after that again), below exactly_once: to accept that a key is written again by a row 24h0m0s or more of event time after its first row, set delivery.require: exactly_once_within; to remember every key from then on, set source.streams[events].dedupe.retention: unbounded (a key already forgotten stays forgotten)
A latest-row dedupe whose output isn't mergedtransform.sql:1:1: the dedupe writing "latest_profiles", ROW_NUMBER() … = 1 in descending order of the event time, keeps each key's latest row, as upserts and deletes that only a merge applies, and the output is written with append: set destination.write: merge, on a destination that merges
A first-row dedupe over a stream read by another cursor than its event timethe dedupe writing "events_once" reads stream "events" with incremental by cursor "id", not by its eventTime "created_at", so each sync's read would start its keys again, and write each key's first row again: read it with full_refresh
watermark.lateness on a stream that a latest-row dedupe readsstream "profile_changes" sets watermark.lateness, which the dedupe writing "latest_profiles" doesn't take: it writes each key's latest row as it comes, whatever the watermark. Set no lateness
dedupe.retention on a stream that no first-row dedupe readsstream "profile_changes" sets dedupe.retention, which only a dedupe that keeps each key's first row takes, ROW_NUMBER() … = 1 in ascending order of its eventTime, and no statement of transform.sql dedupes it so: set no dedupe
A dedupe.retention under 1µsstream "events" sets dedupe.retention 1ns, under the microsecond that event time counts in: set 1µs or more, or unbounded

Changelog streams

WhatMessage
A statement that drops a key columncdc is a changelog, so what reads it keeps its key (id) unchanged, renamed or not; this drops it
A statement that changes a key column, such as id + 1 or a cast… keeps its key (id) unchanged, renamed or not; this changes it
unnest… keeps its key (id) unchanged, renamed or not; this multiplies the rows of it
WHERE on a changelog stream without a primary keylog is a changelog without a primary key, so WHERE is refused, as a row that fails it has no key to delete it by: give the stream a primary key at its source, or read it with full_refresh or incremental in a scheduled pipeline

When rows run

A statement that plans can still fail on a row. Examples are a cast of a value that does not convert, and an integer divided by zero. The engine quarantines such a row, and writes the rest of the batch. The Pipeline reference says where quarantined rows go, and what a change to a stream's schema does to the statements that read it. Quarantine files gives the format of their lines, and the code of each failure.

The settings that streams can and cannot have beside transform.sql are in the Pipeline reference.

On this page