Declarations of one table whose column names differ only past their
first 63 bytes put that one column twice in the table's MATERIALIZED
source, so PostgreSQL rejected the query as ambiguous although each
declaration ran alone. The source now names its columns, and is keyed
by its table's name, as PostgreSQL keeps them: every such declaration
reads the one column or relation, once, each with its own checks.
PostgreSQL keeps the whole characters within a name's first 63 bytes, so
two columns of one relation that share them are one column to it, and the
query failed with an ambiguous reference. Fail at compile time instead,
naming both columns.
The prefix of invented names grew with the plan's names, so a 63-byte
table name made every helper name truncate to one identifier, and a
57-byte one dropped the suffixes of the tables' sources. Number the
prefix instead: __, then __1_, __2_, ... A name starts with at most one
of those, so invented names stay short and PostgreSQL keeps them whole.
The type of an operand built from integer literals was chosen from the
values of the current batch, so results depended on batch boundaries
and slice pushdown. A when or coalesce of literals now carries the
range of its literals; a scalar fits by its value; other operands
computed from literals count as Int32.
Accepted source columns kept their PostgreSQL types inside the query, so
expressions saw a different type than the declared one: lower() failed on
enums, enum comparisons parsed literals as labels and enums sorted by
declaration, char(n) compared without padding, smallint sums overflowed
where Int32 doesn't, and real arithmetic rounded to Float32 where Float64
doesn't. Read every declared column as the PostgreSQL type of its
declared type (strings, enums and char(n) as text, as PostgreSQL converts
them) where the result reads the source, so every expression sees it.
The SQL engine checked only temporal units and decimal digits, so an
INTEGER 256 declared Int8, a DOUBLE 0.1 declared Float32 or a NUMERIC 1
declared decimal(38, 20) passed, silently rounded or failed to decode,
while memory rejects them. Give every column type in tableTypes the
conditions its values must meet for the declared type to hold them
exactly (integer ranges, Float32 round trips, decimal precision, scale and
64-bit storage, finite dates, timestamp range and whole units, intervals
without months), and derive both the row checks and the null-guarded
reads from them, with memory's messages. The checks read the source, so
columns the query doesn't read are checked too.
The row checks and the result read a table through a NOT MATERIALIZED
source unless it called volatile functions, so PostgreSQL could scan it
twice and a view that samples rows (TABLESAMPLE) or calls a function that
differs per scan could pass the checks on rows the result doesn't return.
Read every table name once, through one MATERIALIZED source that
PostgreSQL computes once per statement, for the checks and the result of
every node that reads it; timestamps are read as UTC by the nodes, since
the source is shared.
DataFrame.validate and table reads checked the values of fields a schema
constrains, but ignored the struct's own checks (Schema.Struct(...).check),
so rows the schema rejects were accepted. conform now runs them on the rows
when the struct has any. A SQL engine checks tables column by column, so a
query over a table whose schema has them fails when it is compiled.
The SQL engine read every declared Timestamp/Duration table column as
microseconds and rejected Decimal columns, while the memory engine
conforms tables to the declared unit, precision and scale. Read table
columns as Schema_.arrowType gives them, accept numeric for decimals, and
fail in the statement, with memory's message, on values the declared type
can't hold exactly (fractions of the unit, nanoseconds beyond 64 bits,
decimals that need rounding or more digits). Inexact values read as null so
that reading them doesn't fail before the checks do.
Row checks and the result now share one statement and snapshot; volatile views are computed once for both. Column types are checked against what memory accepts, Null columns must hold only nulls, timestamps must be in DateTime range and read as UTC whatever the session time zone, and intervals must not have months.
Compile runs the plan through the in-memory engine on zero-row inputs
(values emptied, tables from their declared columns) and uses the frames
for every type decision. Compiled now carries the result schema; the
final query renders each column as text (temporal values as integers in
their unit) and the engine decodes rows against that schema.
Also fixes round (float, integer and decimal semantics of the engine),
boolean sums, window functions in filters, temporal and decimal values
at full precision, OVER () for empty partition lists, countDistinct of
empty input, helper names that clash with columns, sqrt of negative
numbers, and keeps the driver's message in errors.