You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Varka is a research/experimental execution engine inside this Spark fork. It
compiles whole date-expression projections into a single SIMD vector loop -
bytecode emitted with the JDK 25 Class-File API, running the Vector API over
zero-copy Panama MemorySegment views of Arrow DateDayVector buffers -
bypassing Spark's per-row code generation on the happy path.
This page is long, and the sections stand on their own. If you are new here, the
Glossary is the one to read first - lane, word, morsel and epilogue all mean
something specific in this engine and appear on almost every page after it.
Table of contents
{:toc}
Overview
The Spark SQL runtime normally executes expressions by generating Java source,
compiling it with Janino, and running one expression evaluation per row. Varka
eliminates that runtime compilation overhead (string generation and Janino
parsing) and unlocks SIMD by operating on whole columnar batches at once.
Since milestone 2 it does not dispatch to per-op kernels: an eligible
projection is compiled to a vector IR and fused - however many expressions
and however deep their nesting, the emitted class runs one loop with one load
per input column and one store per output. Since VARKA-21 the same machinery
serves filters: an eligible predicate becomes a mask kernel whose single
output is the selection bitmap, and the batch is compacted - or its rows
skipped at the row boundary - by that mask.
Varka reads thirteen Spark types: BooleanType as a bitmap; ByteType and
ShortType on lanes of their own width; IntegerType, DateType and
YearMonthIntervalType on 32-bit lanes; LongType, TimestampNTZType, TimeType
and DayTimeIntervalType on 64-bit lanes; FloatType and DoubleType on floating
lanes; and DecimalType to precision 38, as an unscaled long to precision 18 and a
pair of longs above it. What fuses, by type below says how much of each fuses.
The rest of this section describes the date family, which began over the three
types that are int32 both in Spark and in the Arrow cache: DateType (stored as
INT days since epoch), IntegerType, and YearMonthIntervalType in every unit
(VARKA-67), whose value is a count of months whether it is spelled INTERVAL YEAR, INTERVAL MONTH or
INTERVAL YEAR TO MONTH. An interval column reaches the same lanes as a date
one; where it may appear is decided by Spark's own typing, so it fuses in
d + ym, in the ordered comparisons and IN, and in the same-typed
greatest/least/coalesce/IF/CASE. CAST between an INT and a
MONTH-unit interval is a relabel in both directions and emits nothing, as is
the cast between two year-month units that ends at MONTH - the one type
coercion inserts when two units meet, so ymm + ymy fuses like ymm + ymm2.
Since VARKA-68 the INT-to-YEAR cast, which multiplies by twelve, fuses
wherever the compile-time bound rules that multiply's overflow out - over a
calendar field it does, over a bare int column it does not. The direction that
divides by twelve fuses too: EXTRACT(YEAR FROM ym), CAST(ymy AS INT), ym / k for a literal integral
k (rounded half away from zero, as Spark does) and a cast that narrows a year-month interval to a
YEAR-ended unit. The emitter's range-narrowed magic division covers about a forty-thousandth of a full
int32 month count, so these divide through 64-bit lanes, which is exact over all of it. ym / -1, a
zero, BIGINT, fractional or column divisor stays residual.
VARKA-68 also admits the algebra whose operands and result are both intervals:
ym + ym, ym - ym, -ym, abs(ym), ym * k and make_ym_interval(y, m),
and, in ADD_MONTHS' month-count position, d - ym_col. None of these has a
wrapping form - Spark computes every one with addExact, subtractExact,
negateExact or multiplyExact whatever the session's ANSI mode - so the check
is unconditional and only a compile-time bound takes it off. A checked * has
no int-lane overflow test, so ym * k fuses only where the bound proves it safe
and is residual otherwise, exactly as VARKA-63's int multiply is; abs is not an
op the IR has but the blend if (ym < 0) -ym else ym, whose negation arm alone
can condemn a batch. try_add(ym, ym) and the other try_* spellings are
residual, having no null-on-overflow lowering.
The supported expression surface, then, over those columns and day offsets that
are a foldable integer literal, an
IntegerType column (VARKA-38; a ByteType or ShortType one fuses too, as
date_add(d, y1) shows) or int arithmetic over those (VARKA-63), including that column
spelled as a day interval,
d + CAST(i AS INTERVAL DAY) and d - CAST(i AS INTERVAL DAY) (VARKA-56; a
literal interval folds to date_add before planning). The cast throws past
106751991 days in every mode, so the evaluator checks the offset column per
batch and a batch holding such a value is recomputed on the row engine, which
raises that error, counted as numFallbackBatchesDeclined. A stored INTERVAL DAY column and i * INTERVAL '1' DAY (which widens to a sub-day interval and
becomes timestamp arithmetic) decline:
DATE_ADD / DATE_SUB / DATEDIFF, nested to any depth up to the
emitter's chain cap, including chains mixing them.
CASE WHEN and IF over date comparisons (<, <=, >, >=, =) and
their AND / OR / NOT combinations - executed branch-free by mask
blend, with SQL's three-valued null semantics. BETWEEN arrives from the
optimizer as its paired comparisons and fuses the same way.
IN over date literals in condition position (VARKA-20): an EQ chain
joined by OR, capped at 16 deduplicated literals - a longer list declines
with a recorded reason rather than risking the emitter's budgets.
COALESCE / NVL / IFNULL / NVL2 and the IS [NOT] NULL predicates
(VARKA-20), lowered onto a validity-reading condition. A guarded operand
must be a bare column, or for IS [NOT] NULL a predicate, whose unknown
rows the test reads off the predicate's own masks (VARKA-334); any other
operand declines.
GREATEST / LEAST (null-skipping) and DAYOFWEEK / WEEKDAY.
YEAR / MONTH / DAYOFMONTH / QUARTER, and the EXTRACT spellings that
desugar to them (VARKA-26). One civil-from-days decomposition per date,
lowered entirely to magic multiplies because no vector divide exists, and
shared between the fields over it: year(d), month(d), dayofmonth(d), quarter(d) run one decomposition and four short tails in one loop method
(VARKA-32). The lowering is defined over years -12800 to 33134 -
every date SQL can write, and then some - and the range is enforced where a
day can leave it, not at every extraction (VARKA-51 and VARKA-52). It stays exact
for a further nine thousand years, to 42400, which is what an intermediate
may reach: a value the compiler has already bounded below and is only
shifting upward is admitted against that wider ceiling rather than the
enforced one (VARKA-69). A date column
is taken to hold 0001-01-01..9999-12-31, the project's column contract,
and is not checked at ingestion. Spark stores any 32-bit day count, so
wherever a fused answer rests on that range the kernel checks it (VARKA-379):
it compares the column's values with the range as it loads them, in its own
loop, and declines a batch holding a live day outside it to the row path,
counted as numFallbackBatchesDeclined under the value-range reason. The
compiler bounds how far the arithmetic
under a calendar function can shift such a day - literal DATE_ADD offsets,
NEXT_DAY, LAST_DAY, ADD_MONTHS with a literal count, and their
compositions - and an entry whose shift can leave the range is residual at
compile time, with the interval as its reason (year(date_add(d, 20000000)) is the canonical case; the row engine computes it). Two
producers it cannot bound that way carry a per-batch range check instead,
and either one declines the whole batch to the row path, counted as
numFallbackBatchesDeclined: a DATE_ADD/DATE_SUB with a column
offset whose result a calendar function reads, checked against the enforced
range above rather than the wider one an intermediate may reach, since what
a producer hands on should stay inside the range every consumer expects; and
an ADD_MONTHS with a column
count, checked on the count itself (see below) - that one wherever it
sits, because the check protects its own month arithmetic rather than a
consumer's, so a bare add_months(d, m) carries it too. A DATE_ADD with
no calendar consumer is never checked - it returns what 32-bit addition
returns, as Spark's does.
NEXT_DAY (VARKA-33) with a literal weekday, resolved at compile time so
one kernel class serves every weekday; a null or unrecognized literal
declines. Since VARKA-59 a weekday column fuses too, through a derived
input: before the kernel runs, the evaluator maps the string column to the
weekday number per batch by the row engine's own parser, so the kernel reads
an int column and the semantics are the row engine's by construction - an
unrecognized name is NULL with ANSI off; with ANSI on it declines the batch
to the row engine, which raises its ILLEGAL_DAY_OF_WEEK error where a
non-null date sits beside the name and returns NULL where the date is null,
exactly as it does alone. Any collation is admitted, since the parser
ignores it. A weekday that is an expression over a column stays residual.
DAYOFYEAR (VARKA-34), LAST_DAY (VARKA-36) and ADD_MONTHS / date + INTERVAL n MONTH (VARKA-40), all over the same civil-from-days prefix;
LAST_DAY and ADD_MONTHS return dates. ADD_MONTHS' month count is a
literal, (VARKA-60) an integer column, (VARKA-67) a stored year-month
interval column, or (VARKA-68) arithmetic over any of those - the negation
behind d - ym_col, and the CAST(m AS INTERVAL YEAR) whose value is
twelve times the column rather than the column itself. What lets a derived
count in is that the range check below is lanewise on the count's value
and cares nothing about what produced it; NEXT_DAY's weekday, which has
no such check, still takes a literal or a column only. A column count
carries a per-batch
range check on the count itself, the same route as the day producer above:
a lane outside VarkaChrono.MONTH_ARITH_MIN/MAX_MONTHS (about 2047 years
either way, where the lowering's magic division by 12 stops being exact)
declines the batch to the row engine rather than compute past it.
MAKE_DATE(year, month, day) (VARKA-42) over int columns and literals, in
both evaluation modes: an invalid month or day is a null date with ANSI
off and, with ANSI on, sends the batch to the row engine, which raises
Spark's own error at that row; a year outside the whole years of the
calendar range goes to the row engine in both modes, so the kernel never
publishes a date the lowering is not exact for.
WEEKOFYEAR, EXTRACT(WEEK FROM d) and DATE_PART('WEEK', d) (VARKA-37), the ISO-8601 week
by the Thursday rule: the day is moved to the Thursday of its Monday-based
week and the week is that Thursday's ordinal day in sevens, so the year
boundaries need no correction. The shift is its own node and the week tail's
prefix runs over it, which is what makes EXTRACT(YEAROFWEEK FROM d)
(VARKA-58) YEAR over the same shift, sharing the shift and its prefix with
WEEKOFYEAR of the same date; a projection mixing either with YEAR or
MONTH of the same date decomposes twice, once per side.
EXTRACT(DAYOFWEEK_ISO FROM d) / DATE_PART('DOW_ISO', d) (VARKA-57),
Monday 1 to Sunday 7, as one node: the analyzer spells it weekday(d) + 1,
and that spelling by hand fuses the same way. Since VARKA-63 any other
integer arithmetic over a field fuses too, but as arithmetic over the
weekday rather than as this node, so weekday(d) + 2 answers 2 more than
the weekday and not 1.
TRUNC(date, fmt) at the date levels. With a literal format (VARKA-35),
YEAR/YYYY/YY, MONTH/MON/MM and QUARTER are one node each with
the level as part of the kernel's shape, and WEEK is rewritten onto
NEXT_DAY over DATE_SUB, which is Spark's own definition of it. With a
stored string column as the format (VARKA-61), one node computes all four
periods per row and selects on the level, which the evaluator parses per
batch through the row engine's own parseTruncLevel into a derived int32
input (the mechanism NEXT_DAY uses for a weekday column), so any collation
is admitted; rows whose format is null, unrecognised or below a day are NULL,
as on the row engine, in either ANSI mode. That node costs about the three
literal tails plus the week's, so a literal format remains the shape to
write. The output is a date that can feed further date arithmetic in the
same fused chain. A literal null format, a literal spelling trunc does not
accept, every sub-day literal level, and a format that is an expression over
a column decline: the row engine answers the literal cases with a NULL
column, which no kernel can produce.
UNIX_DATE relabels a date column to its underlying INT day count with no
new node and no emitted code (VARKA-41); the paired DATE_FROM_UNIX_DATE
compiles the same way but still declines, since its child is an integer
column and only a date_add/date_sub offset position reads one (VARKA-38).
+, -, * and unary - over int32 values (VARKA-63): an IntegerType
column, an int literal, any fused int field (YEAR, MONTH, DATEDIFF,
the weekday family) or nested arithmetic over those. The evaluation mode
travels with the node. Under LEGACY the lanes wrap, as DATE_ADD always
has. Under ANSI a sign test marks the overflowing lanes and the batch is
recomputed on the row engine, which raises Spark's own
ARITHMETIC_OVERFLOW; TRY_ADD, TRY_SUBTRACT and TRY_MULTIPLY clear
those lanes from the output's validity instead and the batch runs on. Where
the operands' own ranges prove the result cannot leave int32 the check is not
emitted at all, which is what lets YEAR(d) * 100 + MONTH(d) fuse under
ANSI. The calendar bounds every field; DATEDIFF is bounded only where both
of its operands are, so a DATE_ADD with an offset large enough to wrap the
int32 day, or one shifted by a column with no calendar function over it,
leaves the difference unbounded and the check in place. Both of those rest on
the stored-date contract below, which nothing enforces at ingestion: a date
column holding a day outside 0001..9999 can carry a bound that is not true of
it. A checked multiply whose operands carry no such bound declines: an
int32 lane has no cheap overflow test for *, so it stays on the row engine
rather than wrapping silently. DIV and % are not lowered; the 64-bit,
narrow and floating arithmetic are families of their own (What fuses, by type).
Common subtrees shared across outputs are computed once per lane group
(DAG-CSE), which no per-row engine can keep in a vector register.
A projection does not have to be fully eligible: eligible entries fuse,
untouched input columns are forwarded zero-copy, and the remaining entries run
the standard row path per row, merged with the kernel outputs (VARKA-12).
Out of scope, by the owner's decision of 14 October 2026, are STRING and every
cast to or from it, TIMESTAMP with the local time zone, and decimal division;
CalendarInterval (a struct of months, days and microseconds) and nested types
have no representation. Day offsets are int32, whether a literal, a column or
arithmetic over them.
Varka is designed as a drop-in, zero-risk replacement: every Varka path falls
back to the standard row engine on any failure, so results are always correct.
What fuses, by type
The tables below answer, per Spark type and per family of functions, how much of Spark's scalar
surface fuses today. They are read from the census of Spark's function registry over the thirteen
types (sql/varka/plans/m8/census.tsv), which lists every function and operator whose inputs and
result can all be one of those types, and from the coverage table of the next section, one row
per fused spelling. An entry absent from the census is out of scope with a recorded reason: a
STRING, a nested type, an aggregate or a nondeterministic function, say.
Math functions are exact by default. Today Varka fuses nine math functions, sin, cos,
tan, sec, csc, cot, asin, acos and atan; the others (exp, log, pow, atan2,
the hyperbolic functions and the rest of the family) decline to the row engine until their ports
land. Every math function Varka fuses returns Spark's answer bit for bit. Spark computes exp,
log, pow and their neighbours with StrictMath, fdlibm's answer on every host, and sin,
cos, tan, tanh and cbrt with Math, which Java specifies only to within one ulp of the
exact result: their last bit is the host JVM's choice inside that bound, and the default
reproduces that choice rather than relying on the bound. spark.sql.codegen.varka.math.ulpContract.enabled, off by default,
lets a function compute with the JDK's vector math library where the function's bound is
contracted for the host's library: faster, and within that many representable doubles of Spark's
answer instead of equal to it. A value computed so and then grouped, joined on, sorted or written
as a partition key above the kernel can land on the other side of a threshold from Spark's
answer, so the mode is for a consumer that tolerates it. No function has a contracted bound yet,
so none computes under the contract and the setting changes no plan today: each function
reads exact; no contract.
Written by dev/varka_census.py from the census (sql/varka/plans/m8/census.tsv, sql/varka/plans/m8/casts.tsv), the compiler's cast probe (sql/varka/plans/m8/casts_fused.tsv) and sql/varka/coverage.json; regenerate it with python3 dev/varka_census.py, and python3 dev/varka_census.py --check fails while it is stale.
By type
An entry is a function or operator of the census; a type counts fused for it only when every form of the entry over that type fuses, and in part when some form does. Left, by need is the rest by what fusing it takes (plumbing, a compiler arm and IR on lanes that exist; semantics, Spark's overflow, NaN, rounding or scale rules; ulp, a math function exact to Spark's answer); the family table names the plan rows that owe them. Declined are the entries the owner's decision keeps off the type. Coverage rows are the rows of the coverage table below that read a column of the type; a row reading decimals of both bands counts at 19 to 38, whose lane pair it needs.
Type
Lanes
Entries
Fused
In part
Left, by need
Declined
Coverage rows
BooleanType (bool)
bitmap
41
29
2
plumbing 4, semantics 6
0
40
ByteType (byte)
BYTE, INT
75
52
2
plumbing 4, semantics 17
0
57
ShortType (short)
SHORT, INT
75
52
2
plumbing 4, semantics 17
0
55
IntegerType (int)
INT
90
65
2
plumbing 4, semantics 19
0
128
LongType (bigint)
LONG
85
60
2
plumbing 5, semantics 18
0
90
FloatType (float)
FLOAT
66
36
2
plumbing 5, semantics 23
0
62
DoubleType (double)
DOUBLE
102
54
2
plumbing 4, semantics 24, ulp 18
0
82
DecimalType (dec)
LONG, words per value: 1 to precision 18, 2 to precision 38
66
2
9
plumbing 12, semantics 43
3
85: 60 to precision 18, 25 at precision 19 to 38
DateType (date)
INT
63
49
1
plumbing 1, semantics 12
0
107
TimestampNTZType (ntz)
LONG
54
49
0
plumbing 1, semantics 4
0
75
TimeType (time)
LONG
49
34
3
plumbing 1, semantics 11
0
47
YearMonthIntervalType (ym)
INT
55
36
3
plumbing 3, semantics 13
0
37
DayTimeIntervalType (dt)
LONG
57
34
2
plumbing 5, semantics 16
0
33
By family
One row per section of Spark's function registry, and per family of the operators the parser builds with no registry entry: its entries in scope, those fused for every type they admit, those fused for at least one, those fused in part for some type, the types still owed and the plan rows the unfinished entries name.
The math functions that do not fuse yet, by the plan row that fuses them (the ones that fuse today are named above and compute Spark's answer exactly): what each will return by default once fused, and the bound it will compute to with spark.sql.codegen.varka.math.ulpContract.enabled true, which the host library's contract (row 367) states.
One matrix per evaluation mode, rows the source type and columns the target, each cell by that mode's own legality: blank where the mode rejects the cast, = for an identity the analyzer removes, context where the cast fuses only inside another operator, as a coverage row (compiled under ANSI) shows, and otherwise how many of the probe's forms (interval unit pairs, decimal precisions and scales) fuse. LEGACY is the mode with spark.sql.ansi.enabled false, ANSI with it true, and TRY is try_cast.
LEGACY
from \ to
bool
byte
short
int
bigint
float
double
dec
date
ntz
time
ym
dt
bool
=
fused
fused
fused
fused
fused
fused
declined
byte
fused
=
fused
fused
fused
fused
fused
declined
declined
declined
short
fused
fused
=
fused
fused
fused
fused
declined
declined
declined
int
fused
fused
fused
=
fused
fused
fused
declined
fused
declined
bigint
fused
fused
fused
fused
=
declined
declined
declined
declined
declined
float
fused
declined
declined
declined
declined
=
fused
declined
double
fused
declined
declined
declined
declined
fused
=
declined
dec
declined
declined
declined
declined
declined
declined
declined
declined
declined
declined
date
declined
declined
declined
declined
declined
declined
declined
declined
=
fused
ntz
fused
=
fused
time
declined
declined
declined
declined
declined
fused
3 of 6
ym
declined
declined
2 of 3
declined
declined
fused
dt
declined
declined
declined
fused
declined
36 of 90
time to time (relabel or truncation), 3 of 6 forms; declined: TIME(3) to TIME(0); TIME(6) to TIME(0); TIME(6) to TIME(3)
ym to int (unit division), 2 of 3 forms; declined: INTERVAL YEAR TO MONTH to INT
dt to dt (relabel or unit narrowing), 36 of 90 forms; declined: INTERVAL DAY to INTERVAL DAY TO HOUR; INTERVAL DAY to INTERVAL DAY TO MINUTE; INTERVAL DAY to INTERVAL HOUR; INTERVAL DAY to INTERVAL HOUR TO MINUTE; INTERVAL DAY to INTERVAL MINUTE; INTERVAL DAY TO HOUR to INTERVAL DAY; INTERVAL DAY TO HOUR to INTERVAL DAY TO MINUTE; INTERVAL DAY TO HOUR to INTERVAL HOUR; INTERVAL DAY TO HOUR to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO HOUR to INTERVAL MINUTE; INTERVAL DAY TO MINUTE to INTERVAL DAY; INTERVAL DAY TO MINUTE to INTERVAL DAY TO HOUR; INTERVAL DAY TO MINUTE to INTERVAL HOUR; INTERVAL DAY TO MINUTE to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO MINUTE to INTERVAL MINUTE; INTERVAL DAY TO SECOND to INTERVAL DAY; INTERVAL DAY TO SECOND to INTERVAL DAY TO HOUR; INTERVAL DAY TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL DAY TO SECOND to INTERVAL HOUR; INTERVAL DAY TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO SECOND to INTERVAL MINUTE; INTERVAL HOUR to INTERVAL DAY; INTERVAL HOUR to INTERVAL DAY TO HOUR; INTERVAL HOUR to INTERVAL DAY TO MINUTE; INTERVAL HOUR to INTERVAL HOUR TO MINUTE; INTERVAL HOUR to INTERVAL MINUTE; INTERVAL HOUR TO MINUTE to INTERVAL DAY; INTERVAL HOUR TO MINUTE to INTERVAL DAY TO HOUR; INTERVAL HOUR TO MINUTE to INTERVAL DAY TO MINUTE; INTERVAL HOUR TO MINUTE to INTERVAL HOUR; INTERVAL HOUR TO MINUTE to INTERVAL MINUTE; INTERVAL HOUR TO SECOND to INTERVAL DAY; INTERVAL HOUR TO SECOND to INTERVAL DAY TO HOUR; INTERVAL HOUR TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL HOUR TO SECOND to INTERVAL HOUR; INTERVAL HOUR TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL HOUR TO SECOND to INTERVAL MINUTE; INTERVAL MINUTE to INTERVAL DAY; INTERVAL MINUTE to INTERVAL DAY TO HOUR; INTERVAL MINUTE to INTERVAL DAY TO MINUTE; INTERVAL MINUTE to INTERVAL HOUR; INTERVAL MINUTE to INTERVAL HOUR TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL DAY; INTERVAL MINUTE TO SECOND to INTERVAL DAY TO HOUR; INTERVAL MINUTE TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL HOUR; INTERVAL MINUTE TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL MINUTE; INTERVAL SECOND to INTERVAL DAY; INTERVAL SECOND to INTERVAL DAY TO HOUR; INTERVAL SECOND to INTERVAL DAY TO MINUTE; INTERVAL SECOND to INTERVAL HOUR; INTERVAL SECOND to INTERVAL HOUR TO MINUTE; INTERVAL SECOND to INTERVAL MINUTE
ANSI
from \ to
bool
byte
short
int
bigint
float
double
dec
date
ntz
time
ym
dt
bool
=
fused
fused
fused
fused
fused
fused
declined
byte
fused
=
fused
fused
fused
fused
fused
declined
declined
declined
short
fused
fused
=
fused
fused
fused
fused
declined
declined
declined
int
fused
fused
fused
=
fused
fused
fused
declined
fused
context
bigint
fused
fused
fused
fused
=
declined
declined
declined
declined
declined
float
fused
declined
declined
declined
declined
=
fused
declined
double
fused
declined
declined
declined
declined
fused
=
declined
dec
declined
declined
declined
declined
declined
declined
declined
context
declined
declined
date
=
fused
ntz
fused
=
fused
time
declined
declined
declined
declined
declined
fused
3 of 6
ym
declined
declined
2 of 3
declined
declined
fused
dt
declined
declined
declined
fused
declined
36 of 90
time to time (relabel or truncation), 3 of 6 forms; declined: TIME(3) to TIME(0); TIME(6) to TIME(0); TIME(6) to TIME(3)
ym to int (unit division), 2 of 3 forms; declined: INTERVAL YEAR TO MONTH to INT
dt to dt (relabel or unit narrowing), 36 of 90 forms; declined: INTERVAL DAY to INTERVAL DAY TO HOUR; INTERVAL DAY to INTERVAL DAY TO MINUTE; INTERVAL DAY to INTERVAL HOUR; INTERVAL DAY to INTERVAL HOUR TO MINUTE; INTERVAL DAY to INTERVAL MINUTE; INTERVAL DAY TO HOUR to INTERVAL DAY; INTERVAL DAY TO HOUR to INTERVAL DAY TO MINUTE; INTERVAL DAY TO HOUR to INTERVAL HOUR; INTERVAL DAY TO HOUR to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO HOUR to INTERVAL MINUTE; INTERVAL DAY TO MINUTE to INTERVAL DAY; INTERVAL DAY TO MINUTE to INTERVAL DAY TO HOUR; INTERVAL DAY TO MINUTE to INTERVAL HOUR; INTERVAL DAY TO MINUTE to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO MINUTE to INTERVAL MINUTE; INTERVAL DAY TO SECOND to INTERVAL DAY; INTERVAL DAY TO SECOND to INTERVAL DAY TO HOUR; INTERVAL DAY TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL DAY TO SECOND to INTERVAL HOUR; INTERVAL DAY TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO SECOND to INTERVAL MINUTE; INTERVAL HOUR to INTERVAL DAY; INTERVAL HOUR to INTERVAL DAY TO HOUR; INTERVAL HOUR to INTERVAL DAY TO MINUTE; INTERVAL HOUR to INTERVAL HOUR TO MINUTE; INTERVAL HOUR to INTERVAL MINUTE; INTERVAL HOUR TO MINUTE to INTERVAL DAY; INTERVAL HOUR TO MINUTE to INTERVAL DAY TO HOUR; INTERVAL HOUR TO MINUTE to INTERVAL DAY TO MINUTE; INTERVAL HOUR TO MINUTE to INTERVAL HOUR; INTERVAL HOUR TO MINUTE to INTERVAL MINUTE; INTERVAL HOUR TO SECOND to INTERVAL DAY; INTERVAL HOUR TO SECOND to INTERVAL DAY TO HOUR; INTERVAL HOUR TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL HOUR TO SECOND to INTERVAL HOUR; INTERVAL HOUR TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL HOUR TO SECOND to INTERVAL MINUTE; INTERVAL MINUTE to INTERVAL DAY; INTERVAL MINUTE to INTERVAL DAY TO HOUR; INTERVAL MINUTE to INTERVAL DAY TO MINUTE; INTERVAL MINUTE to INTERVAL HOUR; INTERVAL MINUTE to INTERVAL HOUR TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL DAY; INTERVAL MINUTE TO SECOND to INTERVAL DAY TO HOUR; INTERVAL MINUTE TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL HOUR; INTERVAL MINUTE TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL MINUTE; INTERVAL SECOND to INTERVAL DAY; INTERVAL SECOND to INTERVAL DAY TO HOUR; INTERVAL SECOND to INTERVAL DAY TO MINUTE; INTERVAL SECOND to INTERVAL HOUR; INTERVAL SECOND to INTERVAL HOUR TO MINUTE; INTERVAL SECOND to INTERVAL MINUTE
TRY
from \ to
bool
byte
short
int
bigint
float
double
dec
date
ntz
time
ym
dt
bool
=
fused
fused
fused
fused
fused
fused
declined
byte
fused
=
fused
fused
fused
fused
fused
declined
declined
declined
short
fused
fused
=
fused
fused
fused
fused
declined
declined
declined
int
fused
fused
fused
=
fused
fused
fused
declined
fused
declined
bigint
fused
fused
fused
fused
=
declined
declined
declined
declined
declined
float
fused
declined
declined
declined
declined
=
fused
declined
double
fused
declined
declined
declined
declined
fused
=
declined
dec
declined
declined
declined
declined
declined
declined
declined
declined
declined
declined
date
=
fused
ntz
fused
=
fused
time
declined
declined
declined
declined
declined
fused
3 of 6
ym
declined
declined
2 of 3
declined
declined
fused
dt
declined
declined
declined
fused
declined
36 of 90
time to time (relabel or truncation), 3 of 6 forms; declined: TIME(3) to TIME(0); TIME(6) to TIME(0); TIME(6) to TIME(3)
ym to int (unit division), 2 of 3 forms; declined: INTERVAL YEAR TO MONTH to INT
dt to dt (relabel or unit narrowing), 36 of 90 forms; declined: INTERVAL DAY to INTERVAL DAY TO HOUR; INTERVAL DAY to INTERVAL DAY TO MINUTE; INTERVAL DAY to INTERVAL HOUR; INTERVAL DAY to INTERVAL HOUR TO MINUTE; INTERVAL DAY to INTERVAL MINUTE; INTERVAL DAY TO HOUR to INTERVAL DAY; INTERVAL DAY TO HOUR to INTERVAL DAY TO MINUTE; INTERVAL DAY TO HOUR to INTERVAL HOUR; INTERVAL DAY TO HOUR to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO HOUR to INTERVAL MINUTE; INTERVAL DAY TO MINUTE to INTERVAL DAY; INTERVAL DAY TO MINUTE to INTERVAL DAY TO HOUR; INTERVAL DAY TO MINUTE to INTERVAL HOUR; INTERVAL DAY TO MINUTE to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO MINUTE to INTERVAL MINUTE; INTERVAL DAY TO SECOND to INTERVAL DAY; INTERVAL DAY TO SECOND to INTERVAL DAY TO HOUR; INTERVAL DAY TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL DAY TO SECOND to INTERVAL HOUR; INTERVAL DAY TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL DAY TO SECOND to INTERVAL MINUTE; INTERVAL HOUR to INTERVAL DAY; INTERVAL HOUR to INTERVAL DAY TO HOUR; INTERVAL HOUR to INTERVAL DAY TO MINUTE; INTERVAL HOUR to INTERVAL HOUR TO MINUTE; INTERVAL HOUR to INTERVAL MINUTE; INTERVAL HOUR TO MINUTE to INTERVAL DAY; INTERVAL HOUR TO MINUTE to INTERVAL DAY TO HOUR; INTERVAL HOUR TO MINUTE to INTERVAL DAY TO MINUTE; INTERVAL HOUR TO MINUTE to INTERVAL HOUR; INTERVAL HOUR TO MINUTE to INTERVAL MINUTE; INTERVAL HOUR TO SECOND to INTERVAL DAY; INTERVAL HOUR TO SECOND to INTERVAL DAY TO HOUR; INTERVAL HOUR TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL HOUR TO SECOND to INTERVAL HOUR; INTERVAL HOUR TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL HOUR TO SECOND to INTERVAL MINUTE; INTERVAL MINUTE to INTERVAL DAY; INTERVAL MINUTE to INTERVAL DAY TO HOUR; INTERVAL MINUTE to INTERVAL DAY TO MINUTE; INTERVAL MINUTE to INTERVAL HOUR; INTERVAL MINUTE to INTERVAL HOUR TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL DAY; INTERVAL MINUTE TO SECOND to INTERVAL DAY TO HOUR; INTERVAL MINUTE TO SECOND to INTERVAL DAY TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL HOUR; INTERVAL MINUTE TO SECOND to INTERVAL HOUR TO MINUTE; INTERVAL MINUTE TO SECOND to INTERVAL MINUTE; INTERVAL SECOND to INTERVAL DAY; INTERVAL SECOND to INTERVAL DAY TO HOUR; INTERVAL SECOND to INTERVAL DAY TO MINUTE; INTERVAL SECOND to INTERVAL HOUR; INTERVAL SECOND to INTERVAL HOUR TO MINUTE; INTERVAL SECOND to INTERVAL MINUTE
Expression coverage
One row per expression the compiler fuses, in the spelling you would write it,
over the columns sql/varka/coverage.json lists with their types: d and d2
are dates, i an int, and ymm, ymy and ym year-month intervals of the
three unit ranges, and each other type has one or two columns of its own (l a
bigint, x a double, ntz a TIMESTAMP_NTZ, d9 to d38 decimals named by
their precision, and so on). The Overview above states the conditions in prose; this is the list to
scan when the question is simply whether an expression is covered.
Anything absent declines and runs on Spark's row engine. A decline is a normal
outcome, not an error: the entries that fuse still fuse, and the rest of the
projection is unaffected.
Two things are worth stating before the list, because they decide several
rows and are invisible in the spelling. Every comparison and null test fuses
over each of the thirteen types, a bare IntegerType column included (i > 0,
as year(d) = 2021 does), over DECIMAL for the forms What fuses, by type
counts in part, and IN over every type but BOOLEAN. A null
test fuses over a predicate as well as over a column, as a filter and as the
condition of a CASE: (d = d2) IS NULL is the predicate's unknown rows, read
off the masks it already computes. Spark's default optimizer
(NullDownPropagation) first rewrites a null test over an ordered comparison
or a negation into null tests on its operands, so (d < d2) IS NULL reaches
Varka as d IS NULL OR d2 IS NULL; a test over an equality, a conjunction or
a disjunction reaches it as written. And a checked
multiply fuses only where a bound proves it cannot overflow, which is why the
multiply rows below are written over a calendar field rather than over a plain
column.
The Domain column is filled for a row whose kernel can decline a batch: the
predicate, over the row's columns, inside which the kernel answers. Outside it
the batch goes to the row engine, which answers or raises exactly as Spark
would have; an empty cell means every input of the column types is answered.
Where the two evaluation modes differ the domain is ANSI's, the mode the table
is compiled under: the checked int arithmetic and make_date's date check exist
only there, and the legacy mode wraps or nulls as Spark does with no guard. The
bounds are rendered from the constants the emitter reads, so a moved bound
regenerates the table rather than leaving it stale, and VarkaCoverageSuite
fails a row that carries a guard and names no domain, or names one and carries
no guard. VarkaCoverageDifferentialSuite runs each such row under its domain,
its negation and IS NULL (VARKA-279).
The table is generated, not written. VarkaCoverageSuite compiles every row
below through VarkaExpressionCompiler and fails if any of them declines, fails
if the compiler matches an expression class that no row exercises, and fails if
this file differs from what it renders. So a table claiming an expression the
engine does not have, and a table missing one the engine gained, are both build
failures. Regenerate it after adding a row with:
The 128-bit lanes column is sql/varka/width_audit.json's census on AMD Ryzen AI 9 HX PRO 370 w/ Radeon 890M at a forced 128-bit species: vector means C2 refused no Vector API call in the row's kernel there; per-lane names the constructions it had no lowering for, which then run as Java loops over the lanes (VARKA-153). It is this x86 JVM's table below its own width: the pool's aarch64 runner, whose native species is 128 bits, refuses nothing (VARKA-153.md 6).
The Switches column names the family switches that keep the row off Varka, each <name> the setting spark.sql.codegen.varka.family.<name>.enabled (Configuration): the families whose nodes the row's kernel holds, as the compiler records them for a failure's families: line. A row with none compiles to a bare column read, which no switch declines.
Day arithmetic
Expression
Switches
Domain
Notes
128-bit lanes
date_add(d, 3)
calendar
vector
date_add(d, i)
calendar
a column offset with no bound: the day sum wraps as Spark's own + does, and only a calendar node reading such a sum needs the range guard
vector
date_sub(d, 5)
calendar
vector
d + CAST(i AS INTERVAL DAY)
calendar, interval
i BETWEEN -106751991 AND 106751991
the day-interval spelling of a column offset; past the bound the cast itself throws in every mode, so the batch declines and the row engine raises
vector
datediff(d2, d)
calendar
vector
d2 - d
calendar
CAST(unix_date(d2) AS BIGINT) - unix_date(d) BETWEEN -106751991 AND 106751991
a day-time interval in microseconds, not datediff's day count; Spark raises where the int day count overflows or its product overflows a long, in every mode, so the batch declines and the row engine raises. The legacy CalendarInterval result is not fused
per-lane: compare to mask, mask logic, mask broadcast, mask test
unix_date(d)
calendar
vector
date_from_unix_date(unix_date(d))
calendar
vector
Calendar fields
Expression
Switches
Domain
Notes
128-bit lanes
year(d)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
month(d)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
day(d)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
quarter(d)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
dayofyear(d)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
dayofweek(d)
calendar
vector
weekday(d)
calendar
vector
extract(DAYOFWEEK_ISO FROM d)
calendar
vector
weekofyear(d)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
extract(YEAROFWEEK FROM d)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
last_day(d)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
next_day(d, 'MONDAY')
calendar
the day name must be a literal
vector
make_date(2021, i, 1)
calendar
i BETWEEN 1 AND 12
the month under ANSI: an invalid date declines the batch and the row engine raises; the legacy form answers null and declines nothing
vector
trunc(d, 'YEAR')
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
trunc(d, 'MONTH')
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
trunc(d, 'QUARTER')
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
trunc(d, 'WEEK')
calendar
vector
Months and year-month intervals
Expression
Switches
Domain
Notes
128-bit lanes
add_months(d, 3)
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
add_months(d, i)
calendar
unix_date(d) BETWEEN -719162 AND 2932896 AND i BETWEEN -24576 AND 24564
a column month count, inside the range the month arithmetic's magic divide is exact over
vector
d + INTERVAL 3 MONTH
calendar
unix_date(d) BETWEEN -719162 AND 2932896
vector
d + ym
calendar
unix_date(d) BETWEEN -719162 AND 2932896 AND ym BETWEEN INTERVAL '-2048-0' YEAR TO MONTH AND INTERVAL '2047-0' YEAR TO MONTH
the interval's month count, under the same range
vector
d - ym
calendar, interval
unix_date(d) BETWEEN -719162 AND 2932896 AND ym BETWEEN INTERVAL '-2047-0' YEAR TO MONTH AND INTERVAL '2048-0' YEAR TO MONTH
the negated count under the range, so the bounds change sides
vector
make_ym_interval(year(d), month(d))
calendar, interval
unix_date(d) BETWEEN -719162 AND 2932896
the operands must be bounded - over a bare int column the checked multiply inside it keeps its overflow test and declines
vector
make_ym_interval(year(d), month(d)) * 2
calendar, interval
unix_date(d) BETWEEN -719162 AND 2932896
a checked multiply, so bounded operands again: ym * 2 over a stored interval column declines
vector
abs(ym)
interval
ym > INTERVAL '-178956970-8' YEAR TO MONTH
interval arithmetic is exact in every mode: the one count whose negation overflows declines
vector
ym - ymm
interval
CAST(ym AS BIGINT) - CAST(ymm AS BIGINT) BETWEEN -2147483648 AND 2147483647
exact in every mode: a difference outside the month count's int declines
vector
ym + ym
interval
CAST(ym AS BIGINT) + CAST(ym AS BIGINT) BETWEEN -2147483648 AND 2147483647
the sum, exact in every mode as the difference is
vector
CAST(ymy AS INTERVAL MONTH)
none
vector
CAST(i AS INTERVAL MONTH)
none
a relabel of the count; CAST(i AS INTERVAL YEAR) multiplies by twelve, checked
vector
CAST(i AS INTERVAL YEAR)
interval
i BETWEEN -178956970 AND 178956970
a multiply by twelve behind a range guard on the year count, which Spark checks in every mode: a count past it declines the batch under LEGACY and ANSI, where the row engine raises, and nulls the lane under try_cast; inside it the wrapping multiply is exact
vector
CAST(ymm AS INT)
none
a relabel of a MONTH-ended interval; a YEAR-ended one divides by twelve
vector
CAST(ymy AS INT)
interval
the whole years: v / 12 over a count nothing bounds, the division extract(YEAR FROM ym) builds
vector
CAST(ym AS INTERVAL YEAR)
interval
narrowing to a YEAR-ended unit drops the months: (v / 12) * 12, a wrapping multiply that cannot overflow since the product is no larger than the count
vector
ym / 12
interval
a literal integral divisor rounds half away from zero (IntMath.divide HALF_UP): the truncated quotient, moved one step away from zero when the remainder reaches half the divisor, all on the int lane with no widening or guard
vector
ym / -7
interval
a negative divisor flips the direction the rounding moves, which a sign slip would show only here
vector
extract(YEAR FROM ym)
interval
a division by twelve over a month count nothing bounds, so the calendar's range-narrowed magic cannot serve it; a multiply-high through 64-bit lanes does
vector
extract(YEAR FROM ym) - 1
interval, intArithmetic
extract(YEAR FROM ym) > -2147483648
the quotient feeding further int arithmetic, checked under ANSI; the check cannot fire, since the quotient is within +/-178956970
vector
Day-time interval arithmetic
Expression
Switches
Domain
Notes
128-bit lanes
dt + dt2
interval
if(dt IS NULL OR dt2 IS NULL, NULL, try_add(dt, dt2) IS NOT NULL)
a sum past the long raises in every mode, so its batch declines and the row engine raises
per-lane: compare to mask, mask logic, mask broadcast, mask test
dt - dt2
interval
if(dt IS NULL OR dt2 IS NULL, NULL, try_subtract(dt, dt2) IS NOT NULL)
the difference, exact in every mode as the sum is
per-lane: compare to mask, mask logic, mask broadcast, mask test
-dt
interval
dt <> INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND
negateExact raises on the least interval alone
per-lane: compare to mask, mask logic, mask broadcast, mask test
abs(dt)
interval
dt <> INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND
the checked negation under a blend; Spark raises on the least interval in every mode, with ARITHMETIC_OVERFLOW rather than the interval condition
if(dt IS NULL, NULL, try_add(dt, INTERVAL '1' DAY) IS NOT NULL)
the literal, cast to the column's unit and folded, takes a slot in the long lane's table
per-lane: compare to mask, mask logic, mask broadcast, mask test
dt * 3
interval
if(dt IS NULL, NULL, try_multiply(dt, 3) IS NOT NULL)
multiplyExact in every mode, a bare ArithmeticException on overflow: the operand is guarded to the longs whose product fits, exactly, and the multiply wraps; a column factor declines
per-lane: compare to mask, mask logic, mask broadcast, mask test
-2 * dt
interval
if(dt IS NULL, NULL, try_multiply(-2, dt) IS NOT NULL)
the factor on the left is the same node; a negative factor swaps the guard's ends, which are not symmetric
per-lane: compare to mask, mask logic, mask broadcast, mask test
extract(DAY FROM dt)
interval
Java's truncating division by a day, exact over every long and never raising; inside d + dt over a stored INTERVAL DAY column it declines (m9/SCOPE.md item 126), inside d - dt it fuses as an int offset
vector
Integer arithmetic
Expression
Switches
Domain
Notes
128-bit lanes
i + 1
intArithmetic
i < 2147483647
checked under ANSI; the legacy mode wraps as Spark does and declines nothing
vector
i - 1
intArithmetic
i > -2147483648
checked under ANSI
vector
year(d) * 2
calendar, intArithmetic
unix_date(d) BETWEEN -719162 AND 2932896
a multiply is checked, and only bounded operands take the check off: i * 2 over a bare int column declines
vector
-i
intArithmetic
i > -2147483648
checked under ANSI
vector
abs(i)
intArithmetic
i > -2147483648
abs(Int.MinValue) is out of range, and wraps back to itself in the legacy mode
vector
try_add(i, 1)
intArithmetic
an overflowing lane is null, so the kernel declines nothing
vector
try_subtract(i, 1)
intArithmetic
an overflowing lane is null
vector
year(d) + i
calendar, intArithmetic
unix_date(d) BETWEEN -719162 AND 2932896 AND i <= 2147483647 - year(d)
checked under ANSI; the lower bound is out of reach, since a year is at least 1
vector
Narrow arithmetic
Expression
Switches
Domain
Notes
128-bit lanes
y1 + y2
intArithmetic
CAST(y1 AS INT) + CAST(y2 AS INT) BETWEEN -128 AND 127
addition at the byte's own width (VARKA-330): checked under ANSI, wrapping under the legacy mode as Spark does; the domain is the exact sum in the int lane
vector
y1 - y2
intArithmetic
CAST(y1 AS INT) - CAST(y2 AS INT) BETWEEN -128 AND 127
checked subtraction at the byte's width
vector
y1 * y2
intArithmetic
CAST(y1 AS INT) * CAST(y2 AS INT) BETWEEN -128 AND 127
a byte multiply wraps natively and is widened to int for its check
vector
-y1
intArithmetic
y1 > -128
negation raises on -128 only
vector
abs(y1)
intArithmetic
y1 > -128
abs(-128Y) is out of range, and wraps back to -128 in the legacy mode
vector
try_add(y1, y2)
intArithmetic
an overflowing lane is null, so the kernel declines nothing
vector
try_subtract(y1, y2)
intArithmetic
an overflowing lane is null
vector
try_multiply(y1, y2)
intArithmetic
an overflowing lane is null
vector
s1 + s2
intArithmetic
CAST(s1 AS INT) + CAST(s2 AS INT) BETWEEN -32768 AND 32767
addition at the short's own width, the SMALLINT twin of y1 + y2
vector
s1 - s2
intArithmetic
CAST(s1 AS INT) - CAST(s2 AS INT) BETWEEN -32768 AND 32767
checked subtraction at the short's width
vector
s1 * s2
intArithmetic
CAST(s1 AS INT) * CAST(s2 AS INT) BETWEEN -32768 AND 32767
a short multiply wraps natively and is widened to int for its check
vector
-s1
intArithmetic
s1 > -32768
negation raises on -32768 only
vector
abs(s1)
intArithmetic
s1 > -32768
abs(-32768S) is out of range, and wraps back in the legacy mode
vector
try_add(s1, s2)
intArithmetic
an overflowing lane is null
vector
try_subtract(s1, s2)
intArithmetic
an overflowing lane is null
vector
try_multiply(s1, s2)
intArithmetic
an overflowing lane is null
vector
Bigint arithmetic
Expression
Switches
Domain
Notes
128-bit lanes
l + l2
intArithmetic
if(l IS NULL OR l2 IS NULL, NULL, try_add(l, l2) IS NOT NULL)
checked under ANSI at 64 bits; the legacy mode wraps as Spark does
not emitted: a checked bigint operation on an x86 host whose 64-bit species have two lanes or fewer: its overflow test is a long-lane mask, which C2 does not lower there, so the kernel would run the Vector API's Java fallback
l - l2
intArithmetic
if(l IS NULL OR l2 IS NULL, NULL, try_subtract(l, l2) IS NOT NULL)
checked subtraction at 64 bits
not emitted: a checked bigint operation on an x86 host whose 64-bit species have two lanes or fewer: its overflow test is a long-lane mask, which C2 does not lower there, so the kernel would run the Vector API's Java fallback
l + 1
intArithmetic
l < 9223372036854775807
a literal does not bound a bigint column, so the check stays
not emitted: a checked bigint operation on an x86 host whose 64-bit species have two lanes or fewer: its overflow test is a long-lane mask, which C2 does not lower there, so the kernel would run the Vector API's Java fallback
CAST(i AS BIGINT) * 1000L
intArithmetic
a widened int times a literal cannot leave the long, so the multiply fuses with no check; l * 3 over a bigint column declines
per-lane: mask broadcast, mask test
-l
intArithmetic
l > -9223372036854775808
negation raises on Long.MinValue only
not emitted: a checked bigint operation on an x86 host whose 64-bit species have two lanes or fewer: its overflow test is a long-lane mask, which C2 does not lower there, so the kernel would run the Vector API's Java fallback
abs(l)
intArithmetic
l > -9223372036854775808
abs(Long.MinValue) is out of range, and wraps back to itself in the legacy mode
not emitted: a checked bigint operation on an x86 host whose 64-bit species have two lanes or fewer: its overflow test is a long-lane mask, which C2 does not lower there, so the kernel would run the Vector API's Java fallback
try_add(l, l2)
intArithmetic
an overflowing lane is null, so the kernel declines nothing
not emitted: a checked bigint operation on an x86 host whose 64-bit species have two lanes or fewer: its overflow test is a long-lane mask, which C2 does not lower there, so the kernel would run the Vector API's Java fallback
try_subtract(l, l2)
intArithmetic
an overflowing lane is null
not emitted: a checked bigint operation on an x86 host whose 64-bit species have two lanes or fewer: its overflow test is a long-lane mask, which C2 does not lower there, so the kernel would run the Vector API's Java fallback
Bitwise and shifts
Expression
Switches
Domain
Notes
128-bit lanes
i & 255
intArithmetic
vector
i | 4096
intArithmetic
vector
i ^ 21845
intArithmetic
vector
~i
intArithmetic
vector
i << 3
intArithmetic
the count is masked to its low five bits as Java's << does, so i << 33 is i << 1
vector
shiftright(i, i)
intArithmetic
a column count, masked the same way
vector
i >>> 28
intArithmetic
vector
bit_count(i)
intArithmetic
the bits of the value widened to a bigint, so a negative int counts its 32 high bits as well
vector
l & l2
intArithmetic
vector
l | 5000000000
intArithmetic
vector
l ^ l2
intArithmetic
vector
~l
intArithmetic
vector
l << 3
intArithmetic
vector
shiftleft(l, i)
intArithmetic
a column count is widened to the long lane and masked to its low six bits as Java's << does, so a count of 64 or -1 is as in the row engine
per-lane: mask broadcast, load or store, mask test
shiftright(l, i ^ 5)
intArithmetic
the count may be any int expression
per-lane: mask broadcast, load or store, mask test
l >> 40
intArithmetic
vector
shiftrightunsigned(l, 63)
intArithmetic
vector
bit_count(l)
intArithmetic
a count computed in the long lane and narrowed to the int Spark types it as
vector
bit_count(l) + 1
intArithmetic
the narrowed count feeding int arithmetic; the sum cannot overflow, the count being at most 64
per-lane: mask broadcast, load or store
bitmap_bucket_number(l)
intArithmetic
per-lane: compare to mask, blend, mask cast, mask broadcast
bitmap_bit_position(l)
intArithmetic
per-lane: compare to mask, blend, mask cast, mask broadcast
bit_get(i, 3)
intArithmetic
a TINYINT result, the bit shifted down, masked and narrowed; a literal position past the width declines, since Spark raises on every row with a valid target
vector
bit_get(i, i)
intArithmetic
i BETWEEN 0 AND 31
a position column is guarded by the width, which declines the batch Spark raises BIT_POSITION_RANGE on
vector
getbit(l, 63)
intArithmetic
the alias, at the long lane
vector
bit_get(l, i)
intArithmetic
i BETWEEN 0 AND 63
the guarded position widened to the long lane
per-lane: mask logic, mask broadcast, mask test, load or store
bit_count(b)
intArithmetic
1 or 0, and null where the boolean is: the condition's value
vector
Choice and nulls
Expression
Switches
Domain
Notes
128-bit lanes
if(d < d2, d, d2)
predicate, condition
vector
CASE WHEN d < d2 THEN d ELSE d2 END
predicate, condition
vector
CASE WHEN (d < d2) IS NULL THEN d2 ELSE d END
predicate, condition
a condition on whether a comparison is unknown (VARKA-334); a default session's NullDownPropagation pushes the test onto the columns, so this form reaches Varka as written only with that rule excluded
vector
CASE WHEN (d < d2) IS NULL THEN d WHEN d < d2 THEN d2 ELSE d END
predicate, condition
one comparison under its null test and as a condition of its own, lowered once; a default session's NullDownPropagation pushes the test onto the columns, so this form reaches Varka as written only with that rule excluded
vector
CASE WHEN (d = d2) IS NULL THEN d2 ELSE d END
predicate, condition
the optimizer leaves an equality under its null test, so a default session reaches this form
vector
CASE WHEN (d < d2) IS TRUE THEN d ELSE d2 END
predicate, condition
IS TRUE parses to a null-safe equality with true, which fuses as the predicate and its own validity (VARKA-336)
vector
coalesce(d, d2)
condition
vector
greatest(d, d2)
intArithmetic
vector
least(d, d2)
intArithmetic
vector
if(ym IS NULL, INTERVAL '1-2' YEAR TO MONTH, ym)
predicate, condition
vector
CASE WHEN ym IS NULL THEN INTERVAL '1-2' YEAR TO MONTH ELSE ym END
predicate, condition
vector
coalesce(ym, INTERVAL '1-2' YEAR TO MONTH)
condition
vector
greatest(ym, INTERVAL '1-2' YEAR TO MONTH)
intArithmetic
vector
least(ym, INTERVAL '-1-2' YEAR TO MONTH)
intArithmetic
vector
Predicates
Predicate
Switches
Domain
Notes
128-bit lanes
d IS NULL
predicate
vector
d IS NOT NULL
predicate
vector
d = d2
predicate
vector
d < d2
predicate
vector
d <= d2
predicate
vector
d > d2
predicate
vector
d >= d2
predicate
vector
year(d) = 2021
calendar, predicate
unix_date(d) BETWEEN -719162 AND 2932896
vector
NOT (d = d2)
predicate
vector
d IN (DATE '2021-01-01', DATE '2021-06-01')
predicate
up to 16 literals
vector
year(d) = 2021 AND i > 0
calendar, predicate
unix_date(d) BETWEEN -719162 AND 2932896
every conjunct of an AND fuses or the predicate is not in this table; the int column compares in the kernel rather than leaving a residual row filter (VARKA-122)
vector
i > 0
predicate
a bare int column compares in the kernel (VARKA-122)
vector
i IS NOT NULL
predicate
the same column's validity word, which the optimizer infers beside i > 0
vector
i = 5
predicate
vector
month(d) > i
calendar, predicate
unix_date(d) BETWEEN -719162 AND 2932896
an int column against a fused int field
vector
year(d) = 2021 OR month(d) = 3
calendar, predicate
unix_date(d) BETWEEN -719162 AND 2932896
vector
(d < d2) IS NULL
predicate
the unknown partition of a comparison, read off the masks it computes (VARKA-334); a default session's NullDownPropagation pushes the test onto the columns, so this form reaches Varka as written only with that rule excluded
vector
(d < d2) IS NOT NULL
predicate
the comparison known, true or false; a default session's NullDownPropagation pushes the test onto the columns, so this form reaches Varka as written only with that rule excluded
vector
(d = d2) IS NOT NULL
predicate
the optimizer leaves an equality under its null test, so a default session reaches this form
vector
(year(d) = 2021 AND i > 0) IS NULL
calendar, predicate
unix_date(d) BETWEEN -719162 AND 2932896
whether a conjunction is known depends on its operands' values, so the calendar field under it keeps its guard
vector
(d < d2 OR i = 5) IS NOT NULL
predicate
a disjunction is not null-intolerant, so a default session reaches this form
vector
(NOT (d = d2)) IS NULL
predicate
a negation's masks are its child's, swapped; a default session drops the negation and keeps the equality under the test
vector
(d < d2) IS NULL OR d < d2
predicate
one comparison under its null test and beside it: the rows where it is not false; a default session's NullDownPropagation pushes the test onto the columns, so this form reaches Varka as written only with that rule excluded
vector
d <=> d2
predicate
two nulls are equal and a null is not equal to a value: a condition that is never unknown
vector
i <=> 5
predicate
an int column against an int literal
vector
ym <=> INTERVAL '1-2' YEAR TO MONTH
predicate
vector
NOT (d <=> d2)
predicate
a total condition under a negation
vector
d <=> d2 OR i = 5
predicate
beside a three-valued condition, which it never makes unknown
vector
equal_null(d, d2)
predicate
the function form, a replacement of the operator
vector
year(d) <=> month(d2)
calendar, predicate
unix_date(d) BETWEEN -719162 AND 2932896 AND unix_date(d2) BETWEEN -719162 AND 2932896
computed operands: a calendar field's validity is read after its value walk
vector
coalesce(d, d2) <=> d
predicate, condition
an operand with a validity word of its own (it is null only where both are), so the known-true mask is not a subset of the validity the operand comparison reads
vector
greatest(d, d2) <=> d2
predicate, intArithmetic
the same with a greatest, valid where either input is
vector
if(i > 3, d, d2) <=> d
predicate, condition
a choice as an operand: the validity follows the branch
vector
(d < d2) IS TRUE
predicate
the predicate and its own validity: true where the comparison is true, false where it is false or unknown
vector
(d < d2) IS NOT FALSE
predicate
the negation of IS FALSE, which is the predicate negated and then tested for validity
vector
(d < d2) IS NOT TRUE
predicate
the negation of IS TRUE: false exactly where the comparison is true
vector
(d < d2) IS FALSE
predicate
the same composition over the negated comparison
vector
d IS DISTINCT FROM d2
predicate
parses to the negation of a null-safe equality
vector
(year(d) = 2021 AND i > 0) IS TRUE
calendar, predicate
unix_date(d) BETWEEN -719162 AND 2932896
a calendar field under a conjunction tested for validity keeps its guard
vector
d IN (11 to 16 date literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
vector
i < 7
predicate
vector
i <= 7
predicate
vector
i >= 7
predicate
vector
i IS NULL
predicate
vector
i IN (3, 1, 12)
predicate
an int IN, the same equality chain as a date's
vector
i IN (11 to 16 int literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
vector
ym = INTERVAL '1-2' YEAR TO MONTH
predicate
vector
ym < INTERVAL '1-2' YEAR TO MONTH
predicate
vector
ym <= INTERVAL '1-2' YEAR TO MONTH
predicate
vector
ym > INTERVAL '1-2' YEAR TO MONTH
predicate
vector
ym >= INTERVAL '1-2' YEAR TO MONTH
predicate
vector
ym IN (INTERVAL '1-2' YEAR TO MONTH, INTERVAL '-0-3' YEAR TO MONTH)
predicate
vector
ym IN (11 to 16 year-month literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
vector
ym IS NULL
predicate
vector
ym IS NOT NULL
predicate
vector
Long-lane predicates
Predicate
Switches
Domain
Notes
128-bit lanes
l > l2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l = l2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l >= 5000000000
predicate
a bigint literal takes a slot in the long lane's own table
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l IS NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l IS NOT NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t < t2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t = TIME'12:34:56.789'
predicate
a TIME literal of another precision reaches the column through the widening cast, which is the identity on nanoseconds
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt > dt2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt < INTERVAL '0' SECOND
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt IS NOT NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l < l2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l <= l2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t > t2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t >= t2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t <= t2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t IS NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t IS NOT NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt = dt2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt >= dt2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt <= dt2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt IS NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CAST(TIME'12:34:56.789' AS TIME(6)) = t
predicate
a TIME literal is already TIME(6), so the cast is the identity the optimizer removes; a widening from TIME(0) or TIME(3) fuses and a narrowing declines
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
(l > l2) IS NULL
predicate
the unknown partition at the long lane (VARKA-334); a default session's NullDownPropagation pushes the test onto the columns, so this form reaches Varka as written only with that rule excluded
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
(t < t2) IS NOT NULL
predicate
the long lane's; a default session's NullDownPropagation pushes the test onto the columns, so this form reaches Varka as written only with that rule excluded
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l <=> l2
predicate
null-safe equality at the long lane (VARKA-336)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
equal_null(l, l2)
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t <=> t2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt <=> dt2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l IN (5000000000, 42, 0)
predicate
the long lane's equality chain, each literal a slot in its own table; an int literal arrives under coercion's cast to BIGINT, which the arm reads as the constant it is
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l IN (11 to 16 bigint literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t IN (TIME'12:00:00.000000', TIME'06:00:00.000000')
predicate
literals of the column's precision, so no cast reaches the column
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t IN (11 to 16 TIME literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt IN (INTERVAL '2 00:00:00' DAY TO SECOND, INTERVAL '1 00:00:00' DAY TO SECOND)
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt IN (11 to 16 day-time literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
Boolean columns
Predicate
Switches
Domain
Notes
128-bit lanes
b
none
a boolean column as a filter: unknown selects nothing
vector
NOT b
predicate
the pair swapped, no code
vector
b AND d < d2
predicate
beside a comparison, on the one lane they share
vector
b OR i = 5
predicate
an unknown column beside a comparison
vector
b AND l < l2
predicate
the boolean leaf takes the comparison's long lane
not emitted: the conjunct (l < l2), the rest fused: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
b = b2
predicate
equality of two boolean columns: unknown where either is
vector
b <= b2
predicate
an ordering over booleans, false before true: not NOT b OR b2, which is true where b is null and b2 is true
vector
b > b2
predicate
vector
b < b2
predicate
the other strict ordering: true only for false then true
vector
b >= b2
predicate
vector
b <=> b2
predicate
never unknown: two nulls are equal
vector
b IS NULL
predicate
the column's own validity word
vector
b IS NOT NULL
predicate
the column's own validity word
vector
(b AND d < d2) IS NULL
predicate
a test over a predicate: the predicate is not known
vector
coalesce(b, b2)
predicate
the first known boolean, as a condition
vector
CASE WHEN b THEN b2 ELSE d < d2 END
predicate
a boolean choice: unknown takes ELSE
vector
CASE WHEN b THEN i > 5 END
predicate
no ELSE: a null constant, so the body is masked-only
vector
Boolean columns choosing values
Expression
Switches
Domain
Notes
128-bit lanes
IF(b, d, d2)
condition
the int lane
vector
IF(b, l, l2)
condition
the leaf is lifted to the long lane of the values
per-lane: blend, mask broadcast
CASE WHEN b THEN l ELSE l2 END
condition
likewise, per branch
per-lane: blend, mask broadcast
Boolean outputs
Expression
Switches
Domain
Notes
128-bit lanes
d2 > d
predicate
a date comparison as a column, on the int lane; d < d2 as an output
vector
l2 > l
predicate
the long lane's comparison as a column
per-lane: compare to mask, mask cast
y2 > y1
predicate
the byte lane's, at the narrow lane where every value is narrow
vector
NOT b2
predicate
a boolean column negated: the pair swapped and written as two bitmaps
vector
b AND b2
predicate
a connective: false where either is false, even beside an unknown
vector
(d < d2) OR b
predicate
a comparison beside a boolean column on the lane they share
vector
l2 <=> l
predicate
null-safe equality is never unknown, so its validity is all ones
per-lane: compare to mask, mask cast
CASE WHEN b THEN b2 END
predicate
no ELSE: a null constant where b is not true, so the kernel is masked-only
vector
TINYINT columns
Predicate
Switches
Domain
Notes
128-bit lanes
y1 < y2
predicate
two narrow columns compared at the byte lane; with narrowLanes off each load widens into the int lane, in parts where the int width needs them
vector
y1 <= y2
predicate
the other ordering, so that every comparison has a row of its own
vector
y1 >= y2
predicate
vector
y1 = 5Y
predicate
a narrow column against a narrow literal, stored as the same width
vector
y1 IS NOT NULL
predicate
the column's own validity word
vector
y1 <=> y2
predicate
never unknown: two nulls are equal
vector
y1 IN (1Y, 2Y, 3Y, -1Y)
predicate
an IN list over a narrow column, lowered to an equality chain
vector
y1 IN (11 to 16 byte literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
vector
y1 BETWEEN y2 AND 5Y
predicate
two comparisons and an AND at the byte lane
vector
TINYINT columns choosing values
Expression
Switches
Domain
Notes
128-bit lanes
CASE WHEN y1 > y2 THEN y1 ELSE y2 END
predicate, condition
the output is stored at the column's own width, whichever arm computed it
vector
if(y1 IS NULL, 5Y, y1)
predicate, condition
a narrow literal in the ELSE: the stored value is one byte a row and the missing row takes the constant
vector
greatest(y1, y2)
intArithmetic
vector
least(y1, y2)
intArithmetic
vector
coalesce(y1, y2)
condition
the first non-null of two narrow columns
vector
nvl(y1, y2)
condition
rewritten to coalesce(y1, y2)
vector
ifnull(y1, y2)
condition
rewritten to coalesce(y1, y2)
vector
nvl2(y1, y2, y1)
predicate, condition
rewritten to if(y1 IS NOT NULL, y2, y1)
vector
nullif(y1, y2)
predicate, condition
rewritten to if(y1 = y2, NULL, y1): the byte lane's null, a zero broadcast with its validity clear, so the kernel is masked-only
vector
nullifzero(y1)
predicate, condition
rewritten to if(y1 = 0, NULL, y1)
vector
CASE WHEN y1 > y2 THEN y1 END
predicate, condition
the missing ELSE is the null of the byte lane
vector
zeroifnull(y1)
condition
rewritten to coalesce(CAST(y1 AS INT), 0): an INT result, the literal 0 being an int, so the byte column is widened under the null test
vector
SMALLINT columns
Predicate
Switches
Domain
Notes
128-bit lanes
s1 < s2
predicate
the two-byte twin of the TINYINT comparison
vector
s1 <= s2
predicate
vector
s1 >= s2
predicate
vector
s1 = 5S
predicate
a SMALLINT column against a SMALLINT literal
vector
s1 IS NOT NULL
predicate
vector
s1 <=> s2
predicate
vector
s1 IN (1S, 2S, 3S, -1S)
predicate
vector
s1 IN (11 to 16 short literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
vector
s1 BETWEEN s2 AND 5S
predicate
the SMALLINT twin of the TINYINT range test
vector
SMALLINT columns choosing values
Expression
Switches
Domain
Notes
128-bit lanes
CASE WHEN s1 > s2 THEN s1 ELSE s2 END
predicate, condition
two bytes a row at the store
vector
if(s1 IS NULL, 5S, s1)
predicate, condition
the two-byte twin of the TINYINT constant choice
vector
greatest(s1, s2)
intArithmetic
vector
least(s1, s2)
intArithmetic
vector
coalesce(s1, s2)
condition
vector
nvl(s1, s2)
condition
vector
ifnull(s1, s2)
condition
vector
nvl2(s1, s2, s1)
predicate, condition
vector
nullif(s1, s2)
predicate, condition
vector
nullifzero(s1)
predicate, condition
vector
CASE WHEN s1 > s2 THEN s1 END
predicate, condition
vector
zeroifnull(s1)
condition
an INT result, as the TINYINT twin
vector
Bitwise on narrow columns
Expression
Switches
Domain
Notes
128-bit lanes
y1 & y2
intArithmetic
vector
y1 | y2
intArithmetic
vector
y1 ^ y2
intArithmetic
vector
~y1
intArithmetic
the byte XOR -1
vector
y1 & 5Y
intArithmetic
a narrow literal operand
vector
bit_count(y1)
intArithmetic
the popcount of the sign-extended value: a negative byte counts its 56 high bits as well
vector
s1 & s2
intArithmetic
vector
s1 | s2
intArithmetic
vector
s1 ^ s2
intArithmetic
vector
~s1
intArithmetic
vector
bit_count(s1)
intArithmetic
a negative short counts its 48 high bits as well
vector
bit_get(y1, 7)
intArithmetic
the sign bit, read from the value widened by its sign
vector
bit_get(s1, i)
intArithmetic
i BETWEEN 0 AND 15
an int position guarded by the short's width
vector
TINYINT and SMALLINT widened to int
Predicate
Switches
Domain
Notes
128-bit lanes
y1 < i
predicate
the byte column widened on its load, compared at the int lane
vector
s1 = i
predicate
the short twin, an equality
vector
TINYINT and SMALLINT widened to int, as values
Expression
Switches
Domain
Notes
128-bit lanes
y1 + i
intArithmetic
CAST(y1 AS BIGINT) + i BETWEEN -2147483648 AND 2147483647
an int add over a widened byte load, checked under ANSI as any int add is
vector
CASE WHEN i < 0 THEN y1 END
predicate, condition
the byte lane's null beside an int guard: the choice runs on the int lane and stores one byte a row
vector
CASE WHEN i < 0 THEN s1 END
predicate, condition
the short twin
vector
date_add(d, y1)
calendar
a byte offset, read widened to the int lane; the day sum wraps as the int offset's does
vector
date_add(d, s1)
calendar
the short twin
vector
date_sub(d, y1)
calendar
the offset subtracted: the same widened column
vector
date_sub(d, s1)
calendar
vector
CAST(s1 AS INT)
none
the widening alone, stored four bytes a row
vector
CAST(y1 AS INT) * CAST(y2 AS INT)
intArithmetic
an int multiply that cannot overflow, the byte columns' range bounding the product by 2^14, so it needs no check (VARKA-480)
vector
CAST(s1 AS INT) * CAST(s2 AS INT)
intArithmetic
the short twin: a product of at most 2^30
vector
Width conversions
Expression
Switches
Domain
Notes
128-bit lanes
CAST(i AS BIGINT)
intArithmetic
a sign extension, exact in every mode
per-lane: mask broadcast, mask test
CAST(time_to_millis(t) AS INT)
time, intArithmetic
time_to_millis(t) BETWEEN -2147483648 AND 2147483647
a bigint narrowed to an int: under ANSI a value past the int range declines and the row engine raises CAST_OVERFLOW, and the legacy mode keeps the low 32 bits, as Spark does; a day's milliseconds always fit
per-lane: compare to mask, mask logic, mask broadcast, mask test
greatest(i, l)
intArithmetic
type coercion widens the int, and the pick is the long lane's
per-lane: blend, mask broadcast, load or store, mask test
CASE WHEN i < l THEN i ELSE l END
predicate, condition, intArithmetic
the widened int in a condition and in a branch of a long-valued conditional
per-lane: compare to mask, blend, mask cast, mask broadcast, load or store, mask test
Integral casts
Expression
Switches
Domain
Notes
128-bit lanes
CAST(y1 AS SMALLINT)
integralCast
a sign extension at the int lane, no instruction; every byte value in the exhaustive suite
vector
CAST(y1 AS BIGINT)
integralCast
the byte column loaded at the long width, widened in the int species and converted with I2L; exhaustive
per-lane: mask broadcast, mask test
CAST(s1 AS BIGINT)
integralCast
the short twin; exhaustive
per-lane: mask broadcast, mask test
CAST(s1 AS TINYINT)
integralCast
s1 BETWEEN -128 AND 127
the low byte under the legacy mode; under ANSI a value past the byte range declines and the row engine raises CAST_OVERFLOW; exhaustive
vector
CAST(i AS TINYINT)
integralCast
i BETWEEN -128 AND 127
the int narrowed at its store; checked under ANSI; the wrap and the range compare proven in casts.smt2
vector
CAST(i AS SMALLINT)
integralCast
i BETWEEN -32768 AND 32767
the short twin; casts.smt2
vector
CAST(l AS TINYINT)
integralCast
l BETWEEN -128 AND 127
the bigint narrowed at its store, L2I and the byte store; checked under ANSI; casts.smt2
per-lane: compare to mask, mask logic, mask broadcast, mask test
CAST(l AS SMALLINT)
integralCast
l BETWEEN -32768 AND 32767
the short twin; casts.smt2
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
CAST(b AS TINYINT)
integralCast
1 where true, 0 where false, null where null, in the byte lane under the native arm; every leaf state in the exhaustive suite
vector
CAST(b AS SMALLINT)
integralCast
the short twin; exhaustive
vector
CAST(b AS INT)
integralCast
the int lane; exhaustive
vector
CAST(b AS BIGINT)
integralCast
the long lane; exhaustive
per-lane: masked operation, mask broadcast
try_cast(s1 AS TINYINT)
integralCast
a nulling range guard: null where the short does not fit the byte, no declined batch; exhaustive
vector
try_cast(i AS TINYINT)
integralCast
the int's nulling guard over the byte range; differential
vector
try_cast(i AS SMALLINT)
integralCast
the short twin; differential
vector
try_cast(l AS TINYINT)
integralCast
the bigint's nulling guard, L2I and the byte store; differential
per-lane: compare to mask, mask logic, mask cast
try_cast(l AS SMALLINT)
integralCast
the short twin; differential
per-lane: compare to mask, mask logic, mask cast, mask broadcast, load or store
try_cast(l AS INT)
intArithmetic
the bigint's nulling guard over the int range; differential
per-lane: compare to mask, mask logic, mask cast
greatest(y1, l)
intArithmetic, integralCast
type coercion widens the byte, loaded at the long width, to meet the bigint; differential
per-lane: blend, mask broadcast, load or store, mask test
CAST(i + 1 AS TINYINT)
intArithmetic, integralCast
i BETWEEN -129 AND 126
a computed int narrowed, the add checked under ANSI as any int add is; differential
vector
CAST(i < 5 AS TINYINT)
predicate, integralCast
a comparison's value at the int lane, narrowed: a 0 or a 1 needs no wrap; differential
vector
CAST(dt AS BIGINT)
time
dt BETWEEN INTERVAL '-52124 23:53:47.370495' DAY TO SECOND AND INTERVAL '52124 23:53:47.370495' DAY TO SECOND
the whole seconds of a DAY TO SECOND interval: a truncating division by 10^6 under a guard of 2^52 microseconds, past which the row engine divides; the DAY end is exact over every long
per-lane: compare to mask, mask logic, mask broadcast, mask test
Integral cast predicates
Predicate
Switches
Domain
Notes
128-bit lanes
CAST(y1 AS BOOLEAN)
integralCast
x != 0, which cannot fail; exhaustive
vector
CAST(s1 AS BOOLEAN)
integralCast
exhaustive
vector
CAST(i AS BOOLEAN)
integralCast
differential
vector
CAST(l AS BOOLEAN)
integralCast
the long lane's compare; differential
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
s1 < l
predicate, integralCast
the short widened to the long lane by type coercion, loaded at the long width; differential
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
Width conversion predicates
Predicate
Switches
Domain
Notes
128-bit lanes
i < l
predicate, intArithmetic
an int against a bigint compares in the long lane, the int widened
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l = i
predicate, intArithmetic
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
l <=> i
predicate, intArithmetic
the int widened to meet the bigint, its validity the column's
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CAST(time_to_millis(t) AS INT) > i
time, predicate, intArithmetic
time_to_millis(t) BETWEEN -2147483648 AND 2147483647
the narrowed value compared in the int lane
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
hour(t) = 12
time, predicate
the TIME extract narrowed inside the predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
(i = 5 AND l = l2) IS NOT NULL
predicate
the int conjunct widened to meet the bigint one, and the null test over both
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
(i = 5) IS NULL OR l = l2
predicate
a null test over an int comparison lifted whole to the long lane beside a bigint one
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
Long-lane choice
Expression
Switches
Domain
Notes
128-bit lanes
greatest(l, l2)
intArithmetic
per-lane: blend, mask broadcast
least(l, 5000000000)
intArithmetic
per-lane: blend, mask broadcast
CASE WHEN l < l2 THEN l ELSE l2 END
predicate, condition
per-lane: compare to mask, blend, mask cast, mask broadcast
if(l IS NULL, l2, l)
predicate, condition
per-lane: mask broadcast, mask logic, blend
if(y1 IS NULL, l, l2)
predicate, condition
a byte column read for its validity alone, which joins the bigint kernel: the word is a bit per row at every lane (VARKA-480)
per-lane: mask broadcast, mask logic, blend
if(s1 IS NULL, l, l2)
predicate, condition
the short twin
per-lane: mask broadcast, mask logic, blend
greatest(t, t2)
intArithmetic
per-lane: blend, mask broadcast
CASE WHEN dt > INTERVAL '0' SECOND THEN dt ELSE dt2 END
predicate, condition
per-lane: compare to mask, blend, mask cast, mask broadcast
coalesce(l, l2)
condition
per-lane: blend, mask broadcast
least(t, t2)
intArithmetic
per-lane: blend, mask broadcast
CASE WHEN t < t2 THEN t ELSE t2 END
predicate, condition
per-lane: compare to mask, blend, mask cast, mask broadcast
if(t < t2, t, t2)
predicate, condition
per-lane: compare to mask, blend, mask cast, mask broadcast
coalesce(t, t2)
condition
per-lane: blend, mask broadcast
greatest(dt, dt2)
intArithmetic
per-lane: blend, mask broadcast
least(dt, dt2)
intArithmetic
per-lane: blend, mask broadcast
if(dt < dt2, dt, dt2)
predicate, condition
per-lane: compare to mask, blend, mask cast, mask broadcast
coalesce(dt, dt2)
condition
per-lane: blend, mask broadcast
Choice and nulls on every type
Expression
Switches
Domain
Notes
128-bit lanes
if(i < 0, i, i + 1)
predicate, condition, intArithmetic
i < 2147483647
an int branch is a column, a literal or int arithmetic; the checked add is qualified by its arm, so only a row taking the ELSE can overflow
vector
CASE WHEN d < d2 THEN i ELSE datediff(d, d2) END
calendar, predicate, condition
vector
coalesce(i, datediff(d, d2))
calendar, condition
vector
coalesce(i, 0)
condition
vector
zeroifnull(i)
condition
rewritten to coalesce(i, 0)
vector
greatest(i, 7)
intArithmetic
vector
least(i, -7)
intArithmetic
vector
greatest(i, -2147483648)
intArithmetic
the int minimum beside a null is the minimum, not a null
vector
least(i, 2147483647)
intArithmetic
the int maximum beside a null
vector
greatest(i, CAST(NULL AS INT))
intArithmetic
a NULL operand is the null leaf, which the pick skips as it skips a null column: the answer is i, and null only where i is
vector
least(i, NULL, -2147483648)
intArithmetic
the null leaf beside the int minimum
vector
greatest(d, NULL, d2)
intArithmetic
vector
least(ym, NULL)
intArithmetic
vector
nvl2(d, i, 0)
predicate, condition
rewritten to if(d IS NOT NULL, i, 0)
vector
CASE WHEN d < d2 THEN i END
predicate, condition
the missing ELSE is the null of the int lane
vector
if(d < d2, i, NULL)
predicate, condition
vector
nullif(i, 3)
predicate, condition
rewritten to if(i = 3, NULL, i); over a computed operand the optimizer evaluates it in a projection of its own, a second kernel
vector
nullifzero(i)
predicate, condition
rewritten to if(i = 0, NULL, i)
vector
CASE WHEN d < d2 THEN d END
predicate, condition
vector
if(d < d2, NULL, d)
predicate, condition
vector
nullif(d, d2)
predicate, condition
vector
nvl2(d2, d, d2)
predicate, condition
vector
CASE WHEN d < d2 THEN ym END
predicate, condition
vector
nullif(ym, INTERVAL '1-2' YEAR TO MONTH)
predicate, condition
vector
nvl2(d, ym, INTERVAL '0-1' YEAR TO MONTH)
predicate, condition
vector
CASE WHEN l < l2 THEN l END
predicate, condition
the missing ELSE is the null of the long lane
per-lane: compare to mask, mask cast, blend, mask broadcast
if(d < d2, l, NULL)
predicate, condition
a date condition lifted to the long lane beside the null
per-lane: compare to mask, mask cast, blend, mask broadcast, load or store, mask test
nullif(l, l2)
predicate, condition
per-lane: compare to mask, mask cast, blend, mask broadcast
nullifzero(l)
predicate, condition, intArithmetic
per-lane: compare to mask, mask cast, blend, mask broadcast, load or store, mask test
zeroifnull(l)
condition, intArithmetic
per-lane: blend, mask broadcast, load or store, mask test
nvl2(l2, l, l2)
predicate, condition
per-lane: blend, mask broadcast
greatest(l, -9223372036854775808L)
intArithmetic
the bigint minimum beside a null
per-lane: blend, mask broadcast
least(l, 9223372036854775807L)
intArithmetic
the bigint maximum beside a null
per-lane: blend, mask broadcast
greatest(l, NULL, -9223372036854775808L)
intArithmetic
the null leaf of the long lane beside the bigint minimum
per-lane: blend, mask broadcast
CASE WHEN t < t2 THEN t END
predicate, condition
per-lane: compare to mask, mask cast, blend, mask broadcast
nullif(t, t2)
predicate, condition
per-lane: compare to mask, mask cast, blend, mask broadcast
nvl2(t2, t, t2)
predicate, condition
per-lane: blend, mask broadcast
greatest(t, TIME '00:00:00')
intArithmetic
the first TIME beside a null
per-lane: blend, mask broadcast
least(t, TIME '23:59:59.999999')
intArithmetic
the last TIME beside a null
per-lane: blend, mask broadcast
least(t, NULL)
intArithmetic
per-lane: blend, mask broadcast
CASE WHEN dt < dt2 THEN dt END
predicate, condition
per-lane: compare to mask, mask cast, blend, mask broadcast
nullif(dt, dt2)
predicate, condition
per-lane: compare to mask, mask cast, blend, mask broadcast
nvl2(dt2, dt, dt2)
predicate, condition
per-lane: blend, mask broadcast
greatest(dt, NULL)
intArithmetic
per-lane: blend, mask broadcast
BETWEEN on every type
Predicate
Switches
Domain
Notes
128-bit lanes
i BETWEEN 1 AND 9
predicate
vector
d BETWEEN DATE '2000-01-01' AND d2
predicate
vector
ym BETWEEN INTERVAL '-1-0' YEAR TO MONTH AND INTERVAL '1-0' YEAR TO MONTH
predicate
vector
l BETWEEN l2 AND 5000000000
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
t BETWEEN t2 AND TIME '23:59:59'
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dt BETWEEN dt2 AND INTERVAL '1' DAY
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
TIMESTAMP_NTZ columns
Predicate
Switches
Domain
Notes
128-bit lanes
ntz < ntz2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz <= ntz2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz > ntz2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz >= ntz2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz = ntz2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz = TIMESTAMP_NTZ '2021-06-01 12:00:00'
predicate
an NTZ literal takes a slot in the long lane's table
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz <=> ntz2
predicate
null-safe equality at the long lane
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz IN (TIMESTAMP_NTZ '2021-06-01 12:00:00', TIMESTAMP_NTZ '1969-12-31 18:00:00')
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz IN (11 to 16 NTZ literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz IS NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ntz IS NOT NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d < ntz
predicate, intArithmetic
unix_date(d) BETWEEN -106751991 AND 106751991
type coercion casts the date to TIMESTAMP_NTZ, its midnight; the day is guarded so that the multiply is exact, and a batch with a day past it goes to the row engine, which raises
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CAST(ntz AS DATE) = d
predicate, intArithmetic
the UTC date of the count: an exact floor division by the microseconds of a day, a shift and a bounded division, for every count
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
TIMESTAMP_NTZ columns choosing values
Expression
Switches
Domain
Notes
128-bit lanes
greatest(ntz, ntz2)
intArithmetic
per-lane: blend, mask broadcast
least(ntz, ntz2)
intArithmetic
per-lane: blend, mask broadcast
CASE WHEN ntz < ntz2 THEN ntz ELSE ntz2 END
predicate, condition
per-lane: compare to mask, blend, mask cast, mask broadcast
if(ntz IS NULL, ntz2, ntz)
predicate, condition
per-lane: mask broadcast, mask logic, blend
coalesce(ntz, ntz2)
condition
per-lane: blend, mask broadcast
CAST(d AS TIMESTAMP_NTZ)
intArithmetic
unix_date(d) BETWEEN -106751991 AND 106751991
Spark multiplies with multiplyExact in every mode, so a day past the bound raises under LEGACY and ANSI and is null under TRY, on the row engine the guard sends its batch to
per-lane: compare to mask, mask logic, mask broadcast, mask test
CAST(ntz AS DATE)
intArithmetic
cannot fail: every quotient is a day an int holds
vector
TIMESTAMP_NTZ arithmetic
Expression
Switches
Domain
Notes
128-bit lanes
ntz - ntz2
time
if(ntz IS NULL OR ntz2 IS NULL, NULL, try_subtract(ntz, ntz2) IS NOT NULL)
a day-time interval in microseconds; a difference past the long raises in every mode
per-lane: compare to mask, mask logic, mask broadcast, mask test
ntz2 - d
time, intArithmetic
unix_date(d) BETWEEN -106751991 AND 106751991 AND if(ntz2 IS NULL OR d IS NULL, NULL, try_subtract(ntz2, d) IS NOT NULL)
type coercion casts the date to TIMESTAMP_NTZ, its midnight, under the cast's day guard, then subtracts it
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
ntz + dt
time
if(ntz IS NULL OR dt IS NULL, NULL, try_add(ntz, dt) IS NOT NULL)
a value past the long raises in every mode
per-lane: compare to mask, mask logic, mask broadcast, mask test
ntz - dt
interval, time
dt <> INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND AND if(ntz IS NULL OR dt IS NULL, NULL, try_subtract(ntz, dt) IS NOT NULL)
the interval's negation is folded into a checked subtraction; Spark negates with negateExact in every mode, so the least interval, which it raises on, is guarded
per-lane: compare to mask, mask logic, mask broadcast, mask test
ntz + INTERVAL '1' DAY
time
if(ntz IS NULL, NULL, try_add(ntz, INTERVAL '1' DAY) IS NOT NULL)
a literal interval takes a slot in the long lane's table
per-lane: compare to mask, mask logic, mask broadcast, mask test
timestampadd(MICROSECOND, l, ntz)
time
if(ntz IS NULL OR l IS NULL, NULL, try_add(ntz, try_multiply(INTERVAL '0.000001' SECOND, l)) IS NOT NULL)
per-lane: compare to mask, mask logic, mask broadcast, mask test
timestampadd(SECOND, i, ntz)
time, intArithmetic
if(ntz IS NULL OR i IS NULL, NULL, try_add(ntz, try_multiply(INTERVAL '1' SECOND, i)) IS NOT NULL)
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
timestampadd(HOUR, i, ntz)
time, intArithmetic
if(ntz IS NULL OR i IS NULL, NULL, try_add(ntz, try_multiply(INTERVAL '1' HOUR, i)) IS NOT NULL)
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
timestampadd(HOUR, l, ntz)
time
l BETWEEN -2562047788 AND 2562047788 AND if(ntz IS NULL OR l IS NULL, NULL, try_add(ntz, try_multiply(INTERVAL '1' HOUR, l)) IS NOT NULL)
per-lane: compare to mask, mask logic, mask broadcast, mask test
timestampadd(DAY, i, ntz)
time, intArithmetic
i BETWEEN -106751991 AND 106751991 AND if(ntz IS NULL OR i IS NULL, NULL, try_add(ntz, try_multiply(INTERVAL '1' DAY, i)) IS NOT NULL)
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
timestampadd(DAY, l, ntz)
time
l BETWEEN -106751991 AND 106751991 AND if(ntz IS NULL OR l IS NULL, NULL, try_add(ntz, try_multiply(INTERVAL '1' DAY, l)) IS NOT NULL)
per-lane: compare to mask, mask logic, mask broadcast, mask test
timestampadd(WEEK, i, ntz)
time, intArithmetic
i BETWEEN -15250284 AND 15250284 AND if(ntz IS NULL OR i IS NULL, NULL, try_add(ntz, try_multiply(INTERVAL '7' DAY, i)) IS NOT NULL)
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
timestampadd(WEEK, l, ntz)
time
l BETWEEN -15250284 AND 15250284 AND if(ntz IS NULL OR l IS NULL, NULL, try_add(ntz, try_multiply(INTERVAL '7' DAY, l)) IS NOT NULL)
per-lane: compare to mask, mask logic, mask broadcast, mask test
ntz + ym
calendar
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND ym BETWEEN INTERVAL '-2048-0' YEAR TO MONTH AND INTERVAL '2047-0' YEAR TO MONTH
the date moved by add_months and the time of day kept
per-lane: mask logic, mask broadcast, mask test, load or store
ntz - ym
calendar, interval
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND ym BETWEEN INTERVAL '-2047-0' YEAR TO MONTH AND INTERVAL '2048-0' YEAR TO MONTH
the negated count under the range, so the bounds change sides
per-lane: mask logic, mask broadcast, mask test, load or store
ntz + INTERVAL '1' MONTH
calendar
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
timestampadd(MONTH, i, ntz)
calendar
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND i BETWEEN -24576 AND 24564
per-lane: mask logic, mask broadcast, mask test, load or store
timestampadd(MONTH, l, ntz)
calendar
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND l BETWEEN -24576 AND 24564
per-lane: mask logic, compare to mask, mask broadcast, mask test, load or store
timestampadd(QUARTER, i, ntz)
calendar
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND i BETWEEN -8192 AND 8188
per-lane: mask logic, mask broadcast, mask test, load or store
timestampadd(QUARTER, l, ntz)
calendar
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND l BETWEEN -8192 AND 8188
per-lane: mask logic, compare to mask, mask broadcast, mask test, load or store
timestampadd(YEAR, i, ntz)
calendar
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND i BETWEEN -2048 AND 2047
per-lane: mask logic, mask broadcast, mask test, load or store
timestampadd(YEAR, l, ntz)
calendar
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND l BETWEEN -2048 AND 2047
per-lane: mask logic, compare to mask, mask broadcast, mask test, load or store
TIMESTAMP_NTZ fields
Expression
Switches
Domain
Notes
128-bit lanes
year(ntz)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
the date of the count, held to the calendar lowering's range
per-lane: mask logic, mask broadcast, mask test, load or store
month(ntz)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
day(ntz)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
quarter(ntz)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
dayofyear(ntz)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
weekofyear(ntz)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
the Thursday shift needs the guard's floor to leave room
per-lane: mask logic, mask broadcast, mask test, load or store
extract(YEAROFWEEK FROM ntz)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
last_day(ntz)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
trunc(ntz, 'YEAR')
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
a year back is the room the guard's floor leaves
per-lane: mask logic, mask broadcast, mask test, load or store
trunc(ntz, 'MONTH')
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
trunc(ntz, 'QUARTER')
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
per-lane: mask logic, mask broadcast, mask test, load or store
dayofweek(ntz)
calendar, intArithmetic
exact over every day, so no guard
per-lane: mask broadcast, load or store
weekday(ntz)
calendar, intArithmetic
per-lane: mask broadcast, load or store
extract(DAYOFWEEK_ISO FROM ntz)
calendar, intArithmetic
per-lane: mask broadcast, load or store
next_day(ntz, 'MONDAY')
calendar, intArithmetic
per-lane: mask broadcast, load or store
trunc(ntz, 'WEEK')
calendar, intArithmetic
per-lane: mask broadcast, load or store
add_months(ntz, i)
calendar, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643 AND i BETWEEN -24576 AND 24564
the guarded date moved by a column month count
per-lane: mask logic, mask broadcast, mask test, load or store
hour(ntz)
time
the microsecond of the day divided; never guarded
vector
minute(ntz)
time
vector
second(ntz)
time
the whole second, an int; the fraction of extract(SECOND ...) is a decimal
vector
CAST(ntz AS TIME(6))
time
the nanosecond of the day, a multiple of a thousand
vector
CAST(ntz AS TIME(3))
time
truncated to milliseconds: a quotient and a product
vector
CAST(ntz AS TIME(0))
time
vector
make_timestamp_ntz(d, t)
time
unix_date(d) BETWEEN -106751991 AND 106751991 AND if(d IS NULL OR t IS NULL, NULL, try_make_timestamp_ntz(d, t) IS NOT NULL)
the date guarded to the days whose midnight is a long, as the cast of a date is
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
make_timestamp_ntz(DATE'2021-06-01', t)
time
if(t IS NULL, NULL, try_make_timestamp_ntz(DATE'2021-06-01', t) IS NOT NULL)
a literal date is checked when the kernel is compiled and takes a slot, so every date shares one kernel
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
CAST(t AS TIMESTAMP_NTZ)
time
if(t IS NULL, NULL, try_make_timestamp_ntz(current_date(), t) IS NOT NULL)
the query's current date at the time of day: the optimizer rewrites the cast to make_timestamp_ntz of the date literal
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
TIMESTAMP_NTZ fields in a condition
Predicate
Switches
Domain
Notes
128-bit lanes
hour(ntz) > 12
time, predicate
the time of day needs no guard
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CAST(ntz AS TIME(3)) < TIME'12:00:00'
time, predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
year(ntz) = 2021
calendar, predicate, intArithmetic
unix_date(CAST(ntz AS DATE)) BETWEEN -5394207 AND 11382643
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
dayofweek(ntz) = 2
calendar, predicate, intArithmetic
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
Null family on floating columns
Expression
Switches
Domain
Notes
128-bit lanes
nvl(x, x2)
condition
rewritten to coalesce(x, x2)
per-lane: blend, mask broadcast
ifnull(x, x2)
condition
per-lane: blend, mask broadcast
nvl2(x, x2, x)
predicate, condition
rewritten to if(x IS NOT NULL, x2, x)
per-lane: blend, mask broadcast
nullif(x, x2)
predicate, condition
rewritten to if(x = x2, NULL, x): NaN equals NaN and -0.0 equals 0.0, and the null is the lane's zero with its validity clear, so the kernel is masked-only
rewritten to if(x = 0, NULL, x): -0.0 is zero, NaN is not
per-lane: compare to mask, mask cast, mask logic, blend, mask broadcast, load or store, mask test
zeroifnull(x)
condition, floatingCast
rewritten to coalesce(x, 0)
per-lane: blend, mask broadcast, load or store, mask test
nvl(f, f2)
condition
rewritten to coalesce(f, f2)
vector
ifnull(f, f2)
condition
vector
nvl2(f, f2, f)
predicate, condition
rewritten to if(f IS NOT NULL, f2, f)
vector
nullif(f, f2)
predicate, condition
rewritten to if(f = f2, NULL, f): NaN equals NaN and -0.0 equals 0.0, and the null is the lane's zero with its validity clear, so the kernel is masked-only
vector
CASE WHEN f < f2 THEN f END
predicate, condition
the missing ELSE is the null of the floating lane
vector
if(f IS NULL, f2, NULL)
predicate, condition
vector
nullifzero(f)
predicate, condition
rewritten to if(f = 0, NULL, f), whose CAST(f AS DOUBLE) = 0.0D the optimizer unwraps to f = 0.0F, exact since the widening is: -0.0 is zero, NaN is not; the differential runs that unwrapped form
vector
Null family predicates on floating columns
Predicate
Switches
Domain
Notes
128-bit lanes
x BETWEEN x2 AND 5.5D
predicate
two comparisons in Spark's order and an AND: a NaN is above every bound
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
equal_null(x, x2)
predicate
rewritten to the null-safe equality, under the lane's equality
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
f BETWEEN f2 AND 5.5F
predicate
two comparisons in Spark's order and an AND: a NaN is above every bound
vector
equal_null(f, f2)
predicate
rewritten to the null-safe equality, under the lane's equality
vector
Null family on TIMESTAMP_NTZ columns
Expression
Switches
Domain
Notes
128-bit lanes
nvl(ntz, ntz2)
condition
per-lane: blend, mask broadcast
ifnull(ntz, ntz2)
condition
per-lane: blend, mask broadcast
nvl2(ntz, ntz2, ntz)
predicate, condition
per-lane: blend, mask broadcast
nullif(ntz, ntz2)
predicate, condition
the long lane's null: the NTZ is its microseconds
per-lane: compare to mask, mask cast, blend, mask broadcast
CASE WHEN ntz < ntz2 THEN ntz END
predicate, condition
per-lane: compare to mask, mask cast, blend, mask broadcast
Null family predicates on TIMESTAMP_NTZ columns
Predicate
Switches
Domain
Notes
128-bit lanes
ntz BETWEEN ntz2 AND TIMESTAMP_NTZ '2000-01-01 00:00:00'
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
equal_null(ntz, ntz2)
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
equal_null on every other type
Predicate
Switches
Domain
Notes
128-bit lanes
equal_null(y1, y2)
predicate
vector
equal_null(s1, s2)
predicate
vector
equal_null(i, 5)
predicate
vector
equal_null(t, t2)
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
equal_null(dt, dt2)
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
equal_null(ym, INTERVAL '1-2' YEAR TO MONTH)
predicate
vector
Null family on BOOLEAN columns
Predicate
Switches
Domain
Notes
128-bit lanes
nvl(b, b2)
predicate
rewritten to coalesce(b, b2)
vector
ifnull(b, b2)
predicate
vector
nvl2(b, b2, b)
predicate
vector
nullif(b, b2)
predicate
rewritten to if(b = b2, NULL, b): a boolean choice with a null arm
vector
b BETWEEN b2 AND b
predicate
false before true: two orderings and an AND
vector
equal_null(b, b2)
predicate
vector
Null family on DECIMAL columns
Predicate
Switches
Domain
Notes
128-bit lanes
nvl(d9, d9s4) > d9b
predicate, condition
rewritten to coalesce at DECIMAL(11, 4), d9 times 10^2, against d9b rescaled the same way
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
ifnull(d9, d9b) IS NULL
predicate, condition
null where both operands are
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
nvl2(d9, d9b, d9s4) < d9
predicate, condition
rewritten to if(d9 IS NOT NULL, d9b, d9s4) at DECIMAL(11, 4)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
nullif(d9, d9b) IS NULL
predicate, condition
rewritten to if(d9 = d9b, NULL, d9): the null branch's validity is false, so the test is true where the two are equal or d9 is null
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
nullif(d9, d9s4) > 0.00
predicate, condition
the equality at DECIMAL(11, 4), the choice and its null at d9's DECIMAL(9, 2); a kernel holding the null takes the masked body
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
nullif(d18, d18b) <=> d18
predicate, condition
the null-safe equality reads the null branch as null
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
nullifzero(d9) IS NOT NULL
predicate, condition
rewritten to if(d9 = 0, NULL, d9): the int zero is DECIMAL(1, 0) as the literal needs, cast to the column's type and folded
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
nullifzero(d16s9) < d9s4
predicate, condition
compared at DECIMAL(16, 9): d9s4 times 10^5
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
zeroifnull(d9) = 0.00
predicate, condition
rewritten to coalesce(d9, 0) at DECIMAL(12, 2), where the int zero widens as DECIMAL(10, 0)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
zeroifnull(d18) >= d18b
predicate, condition
DECIMAL(18, 2): sixteen integral digits hold the zero's ten
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CASE WHEN d9 < d9b THEN d9 END IS NULL
predicate, condition
the missing ELSE is the decimal null
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CASE WHEN d9 < d9b THEN d9s4 END > d9
predicate, condition
the choice at DECIMAL(9, 4), compared at DECIMAL(11, 4)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
if(d9 IS NULL, d9b, NULL) = d9b
predicate, condition
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 BETWEEN d9b AND d9s4
predicate
two comparisons and an AND, the upper one at DECIMAL(11, 4)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 BETWEEN 0.00 AND d18b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
equal_null(d9, d9s4)
predicate
rewritten to d9 <=> d9s4 at DECIMAL(11, 4)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
equal_null(d18, d18b)
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
DOUBLE columns
Predicate
Switches
Domain
Notes
128-bit lanes
x < x2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x <= x2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x > x2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x >= x2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x = x2
predicate
NaN equals NaN, and -0.0 equals 0.0
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x <> x2
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x <=> x2
predicate
null-safe equality under the lane's own equality
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x < 1.5D
predicate
the literal is its bits in the table of the lane's width; a literal that is not NaN needs no NaN test, so this is the bare IEEE compare
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x = 1.5D
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x <= 1.5D
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x > 1.5D
predicate
the IEEE <= negated, so a NaN is above the literal
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x >= 0.0D
predicate
the IEEE < negated; -0.0 and 0.0 are one value
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x <> 0.0D
predicate
the IEEE = negated
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
1.5D < x
predicate
a literal on the left is the swapped compare
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x = CAST('NaN' AS DOUBLE)
predicate
true where the IEEE x <= Infinity is false, so NaN alone; no NaN test
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x < CAST('NaN' AS DOUBLE)
predicate
the IEEE x <= Infinity: every value but NaN
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x IN (1.5D, -2.5D, 0.0D, CAST('NaN' AS DOUBLE))
predicate
an equality chain under the lane's equality
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x IN (11 literals)
predicate
an IN list this long arrives from the optimizer as an InSet and fuses the same way
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
isnan(x)
predicate
never null: false on a null row
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x IS NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x IS NOT NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
DOUBLE columns choosing values
Expression
Switches
Domain
Notes
128-bit lanes
greatest(x, x2)
intArithmetic
Spark's order, the first of two equal operands kept
one multiply by Math.toDegrees(1.0), which is the JDK's own formula
vector
radians(x)
floatingArithmetic
one multiply by Math.toRadians(1.0)
vector
f + f2
floatingArithmetic
the float sum, rounded once
vector
f - f2
floatingArithmetic
vector
f * f2
floatingArithmetic
vector
f * 2.5F
floatingArithmetic
vector
-f
floatingArithmetic
vector
abs(f)
floatingArithmetic
vector
Floating arithmetic over other types
Expression
Switches
Domain
Notes
128-bit lanes
y1 / i
floatingArithmetic, floatingCast
CASE WHEN y1 IS NOT NULL THEN i <> 0 END
both operands cast to double, then the double division; a zero divisor of the cast raises under ANSI and is null under the legacy mode
per-lane: compare to mask, mask logic, mask broadcast, mask test
s1 / i
floatingArithmetic, floatingCast
CASE WHEN s1 IS NOT NULL THEN i <> 0 END
a short over an int, each converted exactly
per-lane: compare to mask, mask logic, mask broadcast, mask test
x / i
floatingArithmetic, floatingCast
CASE WHEN x IS NOT NULL THEN i <> 0 END
the int divisor cast beside the double dividend
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
f / f2
floatingArithmetic, floatingCast
CASE WHEN f IS NOT NULL THEN f2 <> 0.0F END
both floats widened exactly: Spark divides floats as doubles
per-lane: compare to mask, mask logic, mask broadcast, mask test
try_divide(i, y1)
floatingArithmetic, floatingCast
the legacy division over the casts: null on a zero divisor
per-lane: compare to mask, mask cast, mask broadcast, mask test
sqrt(i)
floatingArithmetic, floatingCast
the int converted exactly, then the square root
per-lane: mask broadcast, mask test
signum(i)
floatingArithmetic, floatingCast
per-lane: compare to mask, mask cast, mask logic, mask broadcast, blend, mask test
degrees(i)
floatingArithmetic, floatingCast
per-lane: mask broadcast, mask test
sqrt(f)
floatingArithmetic, floatingCast
the float widened exactly, then the double square root
per-lane: mask broadcast, mask test
signum(f)
floatingArithmetic, floatingCast
a float NaN widened keeps its payload, which signum returns
per-lane: compare to mask, mask cast, mask logic, mask broadcast, blend, mask test
radians(s1)
floatingArithmetic, floatingCast
per-lane: mask broadcast, mask test
signum(ym)
floatingArithmetic
the months' sign as a double: (m > 0) - (m < 0) on the int lane, then I2D, so a zero is +0.0 and a null null
per-lane: mask broadcast, mask test
signum(dt)
floatingArithmetic
the microseconds' sign on the long lane, narrowed to the int lane, then I2D: no conversion from a long
per-lane: compare to mask, masked operation, mask cast, mask broadcast, load or store, mask test
Rounding
Expression
Switches
Domain
Notes
128-bit lanes
rint(x)
rounding
the nearest integer, a tie to the even one, the sign kept on a zero, the canonical NaN for every NaN
per-lane: compare to mask, blend
floor(l)
rounding
the identity over a bigint, in every mode
vector
ceil(l)
rounding
vector
ceiling(l)
rounding
ceil by another name
vector
floor(i)
rounding
FLOOR(CAST(i AS DOUBLE)): the int widened to a bigint, exact in every mode, with no conversion to a double
per-lane: mask broadcast, mask test
ceil(i)
rounding
per-lane: mask broadcast, mask test
round(i, 0)
rounding
a scale of 0 or more is the identity
vector
round(l, 0)
rounding
vector
bround(l, 0)
rounding
vector
truncate(l, 0)
rounding
vector
round(i, -1)
rounding
i BETWEEN -2147483644 AND 2147483644
HALF_UP to a multiple of ten; under ANSI a value whose rounding leaves the int raises, so its batch declines
vector
round(i, -2)
rounding
no int overflows at this scale, so ANSI has no guard
vector
bround(i, -1)
rounding
i BETWEEN -2147483645 AND 2147483645
HALF_EVEN: a tie goes to the even multiple
vector
bround(i, -2)
rounding
vector
truncate(i, -2)
rounding
DOWN never overflows
vector
round(i, -10)
rounding
every int rounds to 0
vector
round(y1, -1)
rounding
y1 BETWEEN -124 AND 124
computed at the int lane and wrapped to the byte
vector
bround(y1, -1)
rounding
y1 BETWEEN -125 AND 125
vector
truncate(y1, -1)
rounding
vector
round(s1, -1)
rounding
s1 BETWEEN -32764 AND 32764
computed at the int lane and wrapped to the short
vector
bround(s1, -2)
rounding
s1 BETWEEN -32749 AND 32749
vector
truncate(s1, -2)
rounding
vector
Math functions
Expression
Switches
Domain
Notes
Form
128-bit lanes
sin(x)
math
exact: a per-lane Math.sin call, the host's answer as Spark's
exact: per-lane Math call
vector
cos(x)
math
exact: a per-lane Math.cos call
exact: per-lane Math call
vector
tan(x)
math
exact: a per-lane Math.tan call
exact: per-lane Math call
vector
asin(x)
math
exact: a per-lane StrictMath.asin call, which Math.asin delegates to
exact: per-lane StrictMath call
vector
acos(x)
math
exact: a per-lane StrictMath.acos call
exact: per-lane StrictMath call
vector
atan(x)
math
exact: a per-lane StrictMath.atan call
exact: per-lane StrictMath call
vector
sec(x)
math
1 / Math.cos(x) as Spark writes it: Java's division, so a zero cosine is an infinity and no null
exact: per-lane Math call
vector
csc(x)
math
1 / Math.sin(x): csc(0.0) is +inf and csc(-0.0) -inf
exact: per-lane Math call
vector
cot(x)
math
1 / Math.tan(x)
exact: per-lane Math call
vector
sin(x) * 2.0D + cos(x2)
floatingArithmetic, math
the arithmetic around the calls in the kernel
exact: per-lane Math call
vector
sin(i)
floatingCast, math
the int converted exactly, then the call
exact: per-lane Math call
per-lane: mask broadcast, mask test
Math functions as conditions
Predicate
Switches
Domain
Notes
Form
128-bit lanes
sin(x) < 0.5D
predicate, math
the call, then the floating compare in Spark's order
exact: per-lane Math call
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
Floating casts to BOOLEAN
Expression
Switches
Domain
Notes
128-bit lanes
CAST(x AS BOOLEAN)
predicate
x != 0: a NaN is true and both zeros false, as a BOOLEAN output
per-lane: compare to mask, mask cast, mask logic, mask broadcast
CAST(f AS BOOLEAN)
predicate
vector
Floating casts to BOOLEAN as conditions
Predicate
Switches
Domain
Notes
128-bit lanes
NOT CAST(x AS BOOLEAN)
predicate
x = 0.0 as the filter: both zeros pass and a NaN does not
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CAST(f AS BOOLEAN) OR f > 1.5F
predicate
the float's test in a disjunction at its lane
vector
Floating casts
Expression
Switches
Domain
Notes
128-bit lanes
CAST(i AS FLOAT)
floatingCast
rounded once to nearest, ties to even, as the JVM converts
vector
try_cast(i AS FLOAT)
floatingCast
the same rounding: a cast to a floating type never fails
vector
CAST(CAST(y1 AS INT) * CAST(y2 AS INT) AS FLOAT)
intArithmetic, floatingCast
a product of two widened bytes
vector
CAST(i AS DOUBLE)
floatingCast
exact: an int's 32 bits fit the double's 53
per-lane: mask broadcast, mask test
CAST(y1 AS FLOAT)
floatingCast
the byte widened at its load, then converted, exact
vector
CAST(s1 AS FLOAT)
floatingCast
the short twin
vector
CAST(y1 AS DOUBLE)
floatingCast
the byte loaded as a bigint kernel loads it, into the low half of the int species, then converted
per-lane: mask broadcast, mask test
CAST(s1 AS DOUBLE)
floatingCast
the short twin
per-lane: mask broadcast, mask test
CAST(f AS DOUBLE)
floatingCast
exact, a NaN's payload and both zeros kept
per-lane: mask broadcast, mask test
CAST(x AS FLOAT)
floatingCast
rounded once; past the float range an infinity, never an error
per-lane: mask broadcast, load or store
CAST(b AS DOUBLE)
floatingCast
1.0 or 0.0, and null where the boolean is
per-lane: mask broadcast, mask test
CAST(b AS FLOAT)
floatingCast
vector
CAST(i > 3 AS DOUBLE)
predicate, floatingCast
a condition as its one or zero, then converted
per-lane: mask broadcast, mask test
CAST(l > 5 AS DOUBLE)
predicate, intArithmetic, floatingCast
a long one or zero, narrowed to the int lane, then I2D
per-lane: compare to mask, masked operation, mask cast, mask broadcast, load or store, mask test
CAST(l > 5 AS FLOAT)
predicate, intArithmetic, floatingCast
the float twin: a float value in a kernel of the long lane
per-lane: compare to mask, masked operation, mask cast, mask broadcast, load or store
x + i
floatingArithmetic, floatingCast
type coercion casts the int to a double beside the double column
per-lane: mask broadcast, load or store, mask test
f * i
floatingArithmetic, floatingCast
the int cast to a float beside the float column, at one lane count
per-lane: mask broadcast, mask test
f + x
floatingArithmetic, floatingCast
the float widened exactly to meet the double
per-lane: mask broadcast, load or store, mask test
i / 2.0D
floatingArithmetic, floatingCast
an int division is a double division over its cast
per-lane: mask broadcast, mask test
CAST(CAST(l AS INT) AS FLOAT)
intArithmetic, floatingCast
l BETWEEN -2147483648 AND 2147483647
the bigint narrowed to INT, checked under ANSI, then I2F, a float value in a long kernel
per-lane: compare to mask, mask logic, mask broadcast, mask test, load or store
CASE WHEN f > 1.5F THEN i END
predicate, condition
the float condition crossed to the int values' lane
vector
IF(i > 3, x, x2)
predicate, condition
the int condition crossed up to the double values by its word
per-lane: blend, mask broadcast, load or store, mask test
CASE WHEN x > 1.5D THEN i END
predicate, condition
a 64-bit mask's word read by the int species
per-lane: compare to mask, mask cast, mask broadcast, load or store
IF(l > 5, f, f2)
predicate, condition, intArithmetic
the long condition crossed down to the float values by its word
per-lane: compare to mask, mask cast, mask broadcast, load or store
IF(b, x, x2)
condition
the boolean column relabelled to the double values' lane
per-lane: blend, mask broadcast
CASE WHEN b THEN f ELSE f2 END
condition
the float twin
vector
IF(NOT (x > 1.5D OR f > 1.5F), i, 7)
predicate, condition
NOT and OR at the double lane, then down
per-lane: compare to mask, mask broadcast, mask logic, mask cast, load or store
CASE WHEN f > 1.5F AND i > 3 THEN i END
predicate, condition
a mixed AND at the int lane, as a guard
vector
CAST((f > 1.5F AND i > 3) AS INT)
predicate, integralCast
the mixed AND as its one or zero
vector
Floating casts as conditions
Predicate
Switches
Domain
Notes
128-bit lanes
CAST(i AS FLOAT) > 1.5F
predicate, floatingCast
the float comparison crossed to the int lane, beside the null test of i the optimizer infers
vector
CAST(i AS DOUBLE) < x
predicate, floatingCast
the int null test crossed to the double lane by its word
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
f > 1.5F AND i < 3
predicate
a float conjunct beside an int one, one kernel
vector
x > 1.5D AND l < l2
predicate
a double conjunct beside a long one, crossed by the cast
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback; a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
f > 1.5F AND x < x2
predicate
two floating widths, the float mask crossed by its word
not emitted: the conjunct (x < x2), the rest fused: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CAST(x AS BOOLEAN) = b2
predicate
the boolean column relabelled to the double lane, its bit read the same
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
(f > 1.5F OR i > 3) AND x > 0.5D
predicate
a crossing under a crossing: the OR at the int lane, then crossed to the double one
not emitted: the conjunct (x > 0.5D), the rest fused: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
x > 1.5D AND (d = DATE '2021-01-01' OR d = DATE '2021-06-01') AND l > 5
predicate, intArithmetic
the range set has no long form and crosses to the long lane by its word
not emitted: the conjunct (x > 1.5D), the rest fused: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback; the conjunct (l > CAST(5 AS BIGINT)), the rest fused: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
DECIMAL columns
Predicate
Switches
Domain
Notes
128-bit lanes
d9 < d9b
predicate
two DECIMAL(9, 2) values compare as their unscaled longs
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 <= d9b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 > d9b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 >= d9b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 = d9b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 <> d9b
predicate
the NOT of the equality
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 <=> d9b
predicate
null-safe equality at the long lane
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 = 0.42
predicate
the literal is cast to the column's DECIMAL(9, 2) and its unscaled long takes a slot in the long table
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 < d18
predicate
type coercion casts d9 to DECIMAL(18, 2), which keeps every unscaled value: the cast is the column
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 < d18b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 = d18b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 <=> d18b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 >= 123456789012.34
predicate
a literal of fourteen digits
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 IS NULL
predicate
a validity read; the slots are checked too, since Spark's null test reads a valid row's value and raises on a slot outside the precision
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 IS NOT NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 IS NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 IS NOT NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 < d9s4
predicate
both sides at DECIMAL(11, 4): d9's unscaled value times 100, exact since nine digits times 10^2 stay within eleven (decimal64.smt2)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 = d9s4
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 <=> d9s4
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d16s9 >= d9s4
predicate
at DECIMAL(16, 9): d9s4 times 10^5
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 > 1.5
predicate
the literal takes its slot at the column's scale, 150
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 < 0.425
predicate
in the analyzed form at DECIMAL(10, 3), the column times 10 against 425; the optimizer folds it to d9 < 0.43, of one scale
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 < 10000000.0125
predicate
at DECIMAL(12, 4): the column times 100 against 100000000125, kept end to end since the literal does not fit d9's type
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
-d9 < d9b
predicate
a negation, which cannot overflow: an unscaled value within 18 digits is never the long lane's minimum
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
abs(d9) >= d9b
predicate
a compare with zero, a negation and a blend; the lanewise ABS is the decimalAbsLanewise option
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
greatest(d9, d9s4) > d9b
predicate, intArithmetic
the null-skipping pick at DECIMAL(11, 4), each branch carrying its rescale
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
coalesce(d9, d9b) IS NULL
predicate, condition
null where every operand is: the validity of each leaf, ORed, and every leaf's slots checked
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
(-d18) IS NOT NULL
predicate
a negation is null where its operand is
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CASE WHEN d9 < d9b THEN d9 ELSE d9s4 END > 0.0
predicate, condition
a choice at DECIMAL(11, 4) under a comparison; the branch of the smaller scale carries its rescale
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 IN (0.42, 0.00, -1.25)
predicate
the equality chain of every lane's IN, each literal's unscaled long at the column's scale a slot in the long table
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 IN (0.425, 1.5)
predicate
in the analyzed form at DECIMAL(10, 3), the column times 10 against 425 and 1500; the optimizer drops 0.425, which no value of d9 equals, and leaves d9 = 1.50
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18 IN (11 to 16 decimal literals)
predicate
an IN list this long arrives from the optimizer as an InSet of Decimals, each read at the column's scale
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
DECIMAL lane pair
Predicate
Switches
Domain
Notes
128-bit lanes
d38 < d38b
predicate
LT(hi) | (EQ(hi) & ULT(lo)): five lane calls over the two pairs
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 <= d38b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 > d38b
predicate
d38b < d38, the operands swapped
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 >= d38b
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 = d38b
predicate
both words equal
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 <> d38b
predicate
the NOT of the equality
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 <=> d38b
predicate
each word's null-safe equality, ANDed: the words share a validity
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d19 < d38
predicate
coercion casts d19 to DECIMAL(38, 2), which keeps both words
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d18b < d38
predicate
across the 64-bit boundary: d18b's long and its sign extension
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 = 12345678901234567890123
predicate
a literal wider than a long, cast to the column's scale at compile time, its two words in two slots of the long table
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d3810 > 1.5
predicate
at DECIMAL(38, 10), the baseline's type
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 IS NULL
predicate
the low word's validity, its slots checked as Spark's reader does
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 IS NOT NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d19 IS NULL
predicate
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
IF(d18 > 0.00, d38, d38b) IS NULL
predicate, condition
a choice or a pick of wide values is null only where its leaves are, so the test reads no word of the value
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
coalesce(d38, d19) IS NULL
predicate, condition
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
greatest(d38, d38b) IS NOT NULL
predicate, intArithmetic
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d38 IN (1.00, 12345678901234567890, -0.50)
predicate
the OR of the equalities, each literal's two words in two slots of the long table
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
-d38 < d38b
predicate
lo' = -lo and hi' = ~hi + (lo = 0): the borrow is the only carry, and Spark negates a wide value exactly
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
abs(d38) >= d38b
predicate
each word of -d38 where the high word is negative
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
IF(d18 > 0.00, d38, d19) < d38b
predicate, condition
the choice on each word under one condition
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
CASE WHEN d38 < 0.00 THEN d38b END <=> d38
predicate, condition
a missing ELSE is a null in each word
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
coalesce(d38, d19) = d38b
predicate, condition
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
greatest(d38, d38b) > 0.00
predicate, intArithmetic
keeps the running pick where the next operand is null or where both are valid and the pick is not smaller, once per word
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
least(d38, d19) <= 0.00
predicate, intArithmetic
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
DECIMAL arithmetic
Predicate
Switches
Domain
Notes
128-bit lanes
d9 + d9b < d18
predicate
DECIMAL(10, 2), compared at DECIMAL(18, 2): the sum under the rescale-free cast coercion puts over it
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 - d8 >= d9b
predicate
DECIMAL(10, 2) against DECIMAL(9, 2)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d8 * d9 <= d9b
predicate
DECIMAL(18, 4), the widest product of the long lane; d9b is rescaled by 10^2 to meet it
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
try_add(d9, d9b) > d18
predicate
the TRY form is the same kernel: no sum within 18 digits overflows
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 * 0.5 > d9b
predicate
the literal is DECIMAL(1, 1), its unscaled 5 a slot; the product is DECIMAL(11, 3)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 + 1.5 < d9b
predicate
the literal is rescaled to the sum's scale at compile time
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 - d9s4 > 0.00
predicate
DECIMAL(12, 4): d9 is rescaled by 10^2 before the subtract
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
d9 + d16s9 > d9s4
predicate
DECIMAL(17, 9): a rescale of 10^7 under the add
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
-(d9 + d9b) = d9s4
predicate
the negation of a sum, compared at DECIMAL(12, 4)
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
try_multiply(d8, d9) IS NULL
predicate
null only where an operand is: no product within 18 digits overflows, so TRY's null past the precision never fires
not emitted: a filter's condition in a kernel driven at a 64-bit lane (BIGINT, DOUBLE, TIMESTAMP_NTZ, TIME, day-time interval, DECIMAL), on an x86 host whose 64-bit species have two lanes or fewer: C2 lowers no mask there, and the selection would run the Vector API's Java fallback
Time arithmetic
Expression
Switches
Domain
Notes
128-bit lanes
t - t2
time
a day-time interval, the nanosecond difference divided by a thousand
vector
time_diff('HOUR', t, t2)
time
the unit is a literal; a column of units would need a kernel per distinct value
vector
time_diff('microsecond', t2, t)
time
units are read case-insensitively, as DateTimeUtils reads them
vector
time_trunc('MINUTE', t)
time
vector
time_trunc('MILLISECOND', t2)
time
vector
hour(t)
time
an int computed in the 64-bit lane and narrowed at the kernel's store; under another expression it narrows where it is
vector
hour(t) + 1
time, intArithmetic
hour(t) < 2147483647
the extract narrowed inside the tree, under an int add checked under ANSI; the check cannot fire, since an hour is at most 23
per-lane: mask logic, mask broadcast, mask test, load or store
minute(t2)
time
vector
second(t)
time
vector
time_to_millis(t)
time
vector
time_to_micros(t2)
time
vector
time_from_millis(time_to_millis(t2))
time
time_to_millis(t2) BETWEEN 0 AND 86399999
the count is guarded to the day's worth of its unit, where the multiply is exact; a count outside declines the batch and the row engine raises Spark's error, as for t + dt - so the count here is one that is inside the day by construction
per-lane: compare to mask, mask logic, mask broadcast, mask test
time_from_micros(time_to_micros(t))
time
time_to_micros(t) BETWEEN 0 AND 86399999999
the same guard over the microsecond count
per-lane: compare to mask, mask logic, mask broadcast, mask test
t + INTERVAL '0 00:00:00' DAY TO SECOND
time
time_to_micros(t) + 0 BETWEEN 0 AND 86399999999
a zero interval on purpose: this fixture reaches both ends of the day, so any other constant crosses midnight on some row, where Spark raises an error rather than a value. The sum is still guarded to the day - the domain adds the interval's microseconds, 0 here, to the time's; the crossing case, and a column interval, are VarkaTimeArithmeticSuite's
per-lane: compare to mask, mask logic, mask broadcast, mask test
TIME decimal outputs
Expression
Switches
Domain
Notes
128-bit lanes
time_to_seconds(t)
time
a DECIMAL(14, 6), (n + 500) / 1000: the exact quotient by 10^9 rounded half up to six digits, written as the low word and its sign extension
per-lane: compare to mask, mask cast, other, blend
extract(SECOND FROM t)
time
a DECIMAL(8, 6), s * 10^6 + (n % 10^9) / 1000; Spark rounds a Double back to six digits, which lands on the same value for every (s, g)
per-lane: compare to mask, mask cast, other, blend
How each row is verified
Every row above runs in the differential suites, which compare the fused kernel with Spark's
row engine on generated data. Beyond that, each row names how it is verified, in
sql/varka/coverage.json's verified field: a refinement in sql/varka/proofs/refinement.smt2
(the kernel proved equal to the SQL specification, with Spark's departures named), a rendered
refinement in sql/varka/proofs/decimal_refinement.smt2 (the same proof, its kernel printed from
the IR the compiler builds and its specification read from Spark's expression), a lowering
proof under sql/varka/proofs/, a test that sweeps the row's whole input domain, a planned row
that owes it, or differential, the differential suites alone. VarkaCoverageSuite fails a row
whose entry names something that does not exist. The counts, per column type of the row's
operands (a row counts once for each type it reads):
Type
Rows
refinement
rendered
proof
exhaustive
owed
differential
bigint
102
0
0
2
0
2
98
bool
39
0
0
0
13
0
26
byte
57
0
0
0
0
8
49
date
128
17
0
0
1
0
110
dec
85
1
42
12
0
0
30
double
97
0
0
1
0
0
96
dt
36
2
0
4
0
0
30
float
63
0
0
0
0
0
63
int
185
14
0
4
1
1
165
ntz
75
0
0
7
0
0
68
short
55
0
0
0
0
8
47
time
48
6
0
1
1
2
38
ym
40
7
0
2
0
2
29
Glossary
Varka's code and documents lean on about two dozen words that mean something
specific here. Two are worth flagging before the list, because they are ordinary
English elsewhere and technical terms here: a lane is one element of a
vector register, not a code path; and a word is always a 64-bit validity
bitmask, never a machine word or a token of text.
Term
What it means here
lane
One element position in a vector register. A 512-bit register holds 16 int32 lanes, a 256-bit one 8. Nearly every loop in the engine is written per lane group rather than per row.
lane group
The rows one vector register holds - the unit every emitted loop iterates over. Its size is the JVM's preferred species width divided by four bytes, so 16 rows at 512 bits. Not a fixed number: the same kernel runs a different group size on a narrower machine.
lane type
The width a node's value occupies, and a property of its physical representation rather than its Spark type: DATE, INT and a year-month interval are all the same 32-bit lane. Carried by the IR's leaves, derived at every other node, and refused where a node's operands disagree.
species
The Vector API's term for a lane type and width together, e.g. IntVector.SPECIES_512. What -XX:MaxVectorSize ultimately selects.
epilogue
The rows left over when the row count is not a whole number of lane groups. Varka runs them as one more iteration of the same vector body under a partial mask, rather than as a scalar loop - so there is one body to maintain, not two.
word
A 64-bit mask of validity bits, one bit per row, for one lane group: 0L means every row null, -1L means none null, anything else is the row-by-row truth. Each node's word is computed from its children's - AND for operations that a null poisons, OR for greatest/least, a blend for IF. "The word" in this codebase never means anything else.
validity buffer
Arrow's per-column null map: one bit per row, set meaning valid. Bit-packed, so it is read a long at a time and turned into a mask - reading it a byte per lane would be a correctness bug, not a slow path.
morsel
The pair of Panama MemorySegments a kernel reads and writes: an Arrow column's data buffer and its validity buffer, mapped zero-copy, off-heap. No per-row object is ever created on the fast path.
dense body / masked body
The two loop bodies every emitted kernel carries. A batch whose referenced inputs contain no nulls at all runs the dense body, which does no validity bookkeeping; anything else runs the masked body. The choice is one test per batch, not per row.
fused kernel
The class Varka emits at runtime for one projection or filter: a single vector loop computing every output, with intermediates living in registers. It implements VarkaFusedKernel.
shape
A plan's structure with its constants removed - the thing two queries share when they differ only in literal values. Literals travel separately as runtime arguments, so date_add(d, 1) and date_add(d, 7) have one shape and share one emitted class.
shape cache
A bounded LRU of emitted classes keyed by shape, shared across tasks. The cost it saves is not emission - that is about 80 microseconds - but JIT warm-up: a re-defined class is a new class to HotSpot and re-pays the whole tier ladder, 13 to 50 ms per task. Reusing the loaded class is the only thing that avoids it.
literal slot
An index into the kernel's runtime argument array where a folded constant lives. Why the IR carries no literal values: keeping them out is what makes the shape the identity.
selection bitmap
A filter's output: one bit per row, set meaning the predicate is known true. An unknown row - a null under the comparison - reads as false by construction, which is SQL's WHERE semantics for free.
partial eligibility
A projection qualifies when at least one of its entries compiles. The rest are forwarded zero-copy or left to stock Spark, and the results merge. Eligibility is per entry, not all-or-nothing, with one exception: under a consumer that wants rows, a projection whose residual entries outnumber its fused ones is left whole to stock Spark, whose one whole-stage loop is then faster than the kernel and the per-row merge (VARKA-613).
decline
A compile-time refusal: the compiler cannot translate an expression, or the emitter will not build a shape. Declining is a normal outcome, not an error - the query runs on stock Spark instead.
ghost fallback
The run-time counterpart: if an emitted kernel fails on a batch, that batch is recomputed by the ordinary row engine and the query still returns the right answer. The Janino projection behind it is compiled lazily, only if some batch actually needs it.
civil-from-days
The calendar algorithm turning a day count since the epoch into year, month and day (Neri and Schneider's, transcribed in sql/varka/papers). Branch-free and 31 vector operations, which is why several outputs over one date share it.
prefix
The shared front half of civil-from-days. Calendar fields over the same date compute it once per lane group and each take their own tail from it, so year(d) beside month(d) costs barely more than one of them.
range guard
A runtime check that a date lies inside the range the decomposition is exact over. Where it sits matters: it is placed on the producer of a value rather than on each consumer, so one check covers every calendar field downstream.
guarded producer
A node that carries such a check on its own result - typically date_add/date_sub with a column offset, where the shift is not knowable at compile time.
op count
Vector operations in an emitted loop body, as dev/varka_emit.sh --table reports them. The project's unit for "how much work is this expression", used to size methods and to choose benchmark entries.
fixed share
(wall time - executor time) / wall time for a benchmark iteration: the fraction spent scheduling rather than computing. A run is failed above 5%, because below that the number measures the kernel and above it measures Spark's job overhead.
datapath probe
A measurement of lanes per nanosecond at 128, 256 and 512 bits. It answers the only question that matters for a benchmark claim - how many wide operations the machine issues per cycle - which no CPU flag reports: some server parts carry the full AVX-512 flag set and still issue 512-bit work at two thirds the rate.
Architecture
One query's journey
Two things happen at different times, and most confusion about this engine comes
from mixing them up. Plan time decides what Varka will run and builds a
class to run it. Run time executes that class over Arrow buffers, batch by
batch.
PLAN TIME - once per plan shape
===============================================================================
Catalyst physical plan
|
v
VarkaColumnarRule ............ finds a projection or filter over a
| columnar source and asks: is it eligible?
v
VarkaExpressionCompiler ...... translates each entry from Catalyst
| into the IR -- or DECLINES it
|
| declined ------> entry stays on stock Spark. A projection is
| still taken if ANY entry compiled; the rest
| are forwarded zero-copy or left as residual.
v
VarkaVectorIR ................ records over int32 lanes. Literal VALUES
| do not appear - a folded constant becomes
| a slot index, so two queries differing only
| in constants have one shape.
v
VarkaLoopEmitter ............. walks the IR and assembles bytecode with
| the Class-File API. Intermediates stay on
| the operand stack, so they stay in vector
| registers.
v
a class implementing VarkaFusedKernel
|
+--> VarkaShapeCache one class per shape, reused across tasks:
emitting costs ~80us, but re-defining a
class costs a fresh JIT warm-up per task.
RUN TIME - once per batch
===============================================================================
Arrow ColumnarBatch
|
v
VarkaMorsel .................. maps each column's data and validity
| buffers onto Panama MemorySegments.
| Zero-copy: nothing is materialised.
v
the emitted kernel's run(...)
|
| are all referenced inputs null-free for THIS batch?
|
+-- yes --> dense body ...... no validity bookkeeping at all
|
+-- no ---> masked body ..... one 64-bit validity word per lane
| group; each node's word computed
| from its children's
|
| ...both then run the epilogue for the rows past the last
| whole lane group - the same body under a partial mask,
| not a scalar loop.
|
+-- refuses the batch --> the ghost fallback: this batch is
| recomputed by the row engine, and the
| query still returns the right answer.
v
output columns (+ a selection bitmap, for a filter)
|
v
VarkaProjectExec / VarkaFilterExec / VarkaColumnarToRowExec
|
v
back to Spark - columnar to the next columnar operator, or converted to
rows at the boundary. Crossing to rows costs about 25 ns per row, which
is why a cheap predicate feeding COUNT(*) can lose to stock Spark while
the same predicate feeding a columnar consumer wins by an order of
magnitude - the kernel is identical; only the boundary differs.
The one property worth carrying away: every arrow labelled declines or
refuses leads somewhere correct. The compiler can decline an expression, the
emitter can refuse a shape, the kernel can refuse a batch - and each falls back
to stock Spark at that granularity. Nothing in this diagram can produce a wrong
answer by giving up.
Columnar morsels
Spark's DateType columns reach Varka as Arrow DateDayVector (int32 days)
with a bit-packed validity buffer (1 bit per row, bit set = valid); an
IntegerType column arrives as an IntVector and a year-month interval as an
IntervalYearVector, both BaseFixedWidthVectors of width four with the same
buffer layout, which is why the lane code is unaware of the difference. A morsel
maps the data and validity buffers onto zero-copy Panama MemorySegments, so
no heap objects are built per row:
data segment -> bytes of `4 * rowCount`
validity segment -> bytes of `(rowCount + 7) / 8`, only when the column has
neither no nulls nor is fully null
The validity buffer is bit-packed. A byte-per-lane read would be a correctness
bug; the kernels instead load a long and build a VectorMask with
VectorMask.fromLong.
The emitted fused loop
The live compute path since milestone 2. VarkaExpressionCompiler translates
an eligible projection into a small vector IR (VarkaVectorIR - column refs,
literal slots, arithmetic, comparisons, conditionals); VarkaLoopEmitter
assembles a class implementing VarkaFusedKernel from it with the Class-File
API - no Java source, no Janino, no external bytecode library. The emitted
class has a deliberate method anatomy:
A per-batch dispatch picks one of two twin bodies: a dense body with
unmasked loads and stores when every input is null-free (measured 2.3-2.9x
the masked body in VARKA-10), and a masked body that builds a
VectorMask per lane group from the bit-packed validity words otherwise.
Since VARKA-70 the masked driver writes an output's validity bitmap once
per batch wherever it is a pure AND/OR of the input bitmaps - which is every
calendar field, every date arithmetic node, datediff and the picks - and
the loop then neither writes it per group nor, where nothing else reads
them, loads the input words per group; for such a shape the masked loop and
epilogue are the dense ones' bytes. What stays per group is what is not a
function of input bitmaps: a filter's selection bitmap, IF/CASE's blend,
make_date's validity test, and every word a range guard or a comparison
still reads. greatest and least are served for their own validity and
still read both operands' words per group, because that is how the value is
built - the null operand is substituted by the other - so they gain less
than the calendar shapes do. A tree that mixes the two operators, such as
datediff(greatest(d, d2), greatest(d3, d4)), is not served at all and
keeps its per-group write.
The vector walk is split into sibling loop methods, one output group per
method, plus a shared epilogue method for the remainder rows. A group's
outputs are priced by the vector ops their nodes emit, and a group grows up
to FUSED_CEILING (400) while the emit cost model predicts its methods
within the byte and call-site budgets, with the plan's margins (VARKA-254);
where the model cannot bound it, the older rule binds - GROUP_BUDGET (16)
ops a method, or up to the ceiling where the outputs share a calendar prefix
(VARKA-32). The built class is then measured, and a method over a limit has
its group split. Separate methods, not one big loop: each gets its own C2 compilation,
so no method's inlining budget can starve another's intrinsics - VARKA-10
measured 3-4x on exactly that cliff, and VARKA-24 measured the same cliff
from the other side when it tried leaving the epilogue inline in a kernel's
loop method.
Each body's driver - the method that prepares every output's validity,
takes the all-null shortcut and calls the loop and epilogue methods in turn -
does its per-output work in one call reading a table baked into the class,
rather than as code repeated for each output (VARKA-190). So it grows by two
calls per loop-method group, 44 bytes, and not with the outputs, the columns
or the literals: repeated per output it passed the 8000-byte
HugeMethodLimit at about 140 outputs, which capped how wide one kernel
could be. Past about 180 groups even those calls pass the limit, and the
driver then moves them into stage methods, each calling a run of groups,
which it calls in turn; the stages are sized from the driver's measured
bytes, so the class is built once more and no width is capped by its driver.
Interned subtrees (DAG-CSE) are computed once per lane group and reused
across outputs; literals are hoisted to broadcast vectors in the prologue.
Below the node level, the calendar extractions share their civil-from-days
decomposition: year(d), month(d), dayofmonth(d), quarter(d) and
add_months(d, n) are distinct IR nodes, but a method that emits several of
them over one date runs the 29-op decomposition once and gives each output
only its own tail (VARKA-32). The grouping keeps such outputs in one loop
method for exactly that reason - an output that reuses a prefix the method
already computes may join it up to FUSED_CEILING whichever rule bounds the
group - so the hot loop pays the decomposition once: the four-field projection runs at 1762.6 M rows/s against 818.0 with
a method per field (2.15x at AVX-512, 2.51x at 128-bit; the parity file).
The epilogue, the one method every output shares, decomposes once per date
as well, which is what keeps a wide date projection's epilogue small enough
for HotSpot to compile at all.
Caps: chains up to MAX_CHAIN_DEPTH (16) deep, and up to MAX_INPUTS (64)
input columns per kernel. A projection over more columns is served by
several kernels, run in turn over each batch into one output batch: the
compiler compiles the entries one kernel sets aside into a further kernel,
and verbose EXPLAIN names the kernel of each such entry (VARKA-190). A
kernel's size is bounded by the byte budget rather than by ops;
MAX_FUSED_NODES (64 ops) applies only with the budget off. A chain past
its depth falls back.
Date arithmetic wraps on overflow, matching Spark's DateAdd/DateSub,
which check nothing in any mode. The int arithmetic nodes VARKA-63 added are
the exception and carry their evaluation mode instead, described in the
surface list above; where a checked one is emitted, the sign test's mask joins
the same accumulator VARKA-52's range guard uses, so both kinds of refusal
leave the loop through one status bit. The rows past loopBound are one more iteration of the
same lane-group body under the mask VectorSpecies.indexInRange builds for a
partial group (VARKA-24): the loop stays unmasked, only the epilogue's loads and
stores take their masked overloads, and the lane count becomes the remainder so
every validity access stays bounded by the group. This replaced a scalar tail
that lowered every IR node a second time - the half of the emitter that would
otherwise have had to grow with every node type added after it. One invariant
comes with it: lanes outside the mask read 0, so no operation in the walk may
trap on 0.
The milestone-1 per-op kernels (DateVectorOps.vectorAddDays and friends)
remain in the engine as reference code and as the differential oracle for the
emitter's tests. The per-op dispatcher machinery they were once called through -
the ClassFileCodegenSupport trait, the VarkaClassFileGen assembler and the
kernel-shape interfaces - was retired in VARKA-17, along with the
CodeAndComment cache-key field it fed (m2/PLAN.md section 8).
The IR in pictures
Three Graphviz drawings of VarkaVectorIR live under docs/img/varka/, each
as a .dot source and the .svg rendered from it (dot -Tsvg x.dot -o x.svg;
-Tpng/-Tjpg for a raster). They are a snapshot of the node set as of VARKA-61 (5 September 2026) and are re-rendered when a node is added, in the same
change that re-pins the shape hash.
varka-ir-hierarchy.svg: what a node is - the sealed permits lists as a
tree, grouped into the leaves, day arithmetic, the mod-7 family, selection,
AddMonths, the Chrono family and the Cond family, with each record's
components, its output kind (date, int field, mask) and its weight against
GROUP_BUDGET.
varka-ir-dataflow.svg: what a node takes - every operator with one port
per input component, typed edges from the kinds of value that can feed each
port (a date value, an int field, a stored int column, a derived int32
column from a leaf, a literal slot, a condition), and what each operator
produces.
varka-ir-levels.svg: the same data flow in levels, bottom to top - the
kernel's inputs, the leaves, the date producers, the field extractors, the
conditions and selection, and what the user sees - with the SQL that
compiles to each node written on it, and the emitter's two below-the-IR
fragments drawn in as a dashed layer: the civil-from-days prefix that every
calendar tail and AddMonths share within a lane group, and the mod-7
lowering, which is emitted per node.
The shape cache, class loaders and Metaspace
VARKA-14 measured the cost of the original per-task lifecycle: every task
defined a fresh class, so HotSpot re-ran the whole tier ladder - interpreter,
C1 with boxed vectors, C2 OSR - a fixed 13-50 ms per task that emission (~80
us) never was. Since VARKA-18 the loaded class is shared instead:
VarkaShapeCache is a JVM-wide LRU keyed on the kernel's structural shape -
the IR (whose literal slots carry indices, never values), the input count and
the literal count, exactly the inputs the emitted bytes are a function of -
so tasks and sessions computing the same shape reuse one class, C2 code and
all. Each class lives in its own VarkaClassLoader, release()d when the
cache evicts it; once the last running task drops its reference the JVM
unloads the class, so Metaspace is bounded by the cache capacity rather than
by churn (Spark's codegen cache never releases a loader) or by task lifetime
(the pre-task-18 contract, still available at capacity 0). A registry +
findClass mirror Spark's InMemoryClassLoader.
A new shape's first batches
A newly emitted class runs interpreted until HotSpot compiles it, and
interpreted Vector API code is a library call and an allocation per
operation - slower than Spark's own row code. A kernel's methods are called
once per batch, so over a query of ten batches they reach none of HotSpot's
compile thresholds. With spark.sql.codegen.varka.warmup.enabled (the
default), a shape's batches therefore take the node's per-row path until its
kernel is compiled: the first task to meet the new class copies its batch's
kernel inputs and queues a warm-up (VarkaKernelWarmup, one daemon thread per
JVM), which runs the kernel on that copy in short calls until it no longer
allocates, which it does only as C2's code. The calls alternate between the
kernel's two drivers - one for batches whose inputs have no nulls, one for
batches with them - so the verdict covers whichever the later batches need;
the second is left out only when no kernel input is nullable. From then on
every task of the shape runs the kernel. The per-shape state is
VarkaKernelWarmth, kept on the cache entry, and the batches served on the
row path meanwhile are counted in numWarmupBatches - on a Varka node above
another, that includes the batches the node below sends from its own row path
while its kernel warms. The warm-up is per cache entry, so a session with its
own artifact class loader warms its own class. A shape without a verdict a
minute after its warm-up was queued is released and runs its kernel as it is.
A warmed kernel is emitted under a class name of its own
(VarkaFusedProjection_w...), and C1 is kept off those classes by one
compiler directive (VarkaKernelCompileDirective). A kernel's loop methods
are too large for C1's fully profiled tier, and a method that C1 compiled at
the limited-profile tier instead - which HotSpot chooses while C2's queue is
long - would never be recompiled by C2; without C1 every warmed kernel method
goes from the interpreter to C2. The directive reaches warmed classes only,
because it also makes the interpreter start profiling later, which would
delay a kernel fed by its own batches alone: a session with the warm-up off,
or a JVM that cannot warm - no allocation accounting, no C2, or a directive
it did not accept - emits its kernels under the plain name and compiles them
as it did before the warm-up existed.
Null semantics and predication
The vector loop cannot branch per row, so SQL's null and conditional
semantics are implemented in mask algebra; m2/PLAN.md section 2.6
is the normative statement of the rules. In brief:
Arithmetic is null-intolerant: an output row is valid only where every
referenced input is valid, tracked as per-lane-group validity words in the
loop, and written whole by the driver where the word is a pure function of
the input bitmaps (VARKA-70).
Comparisons and AND/OR/NOT follow three-valued logic as a
known-true / known-false mask pair (unknown is neither), so
null AND false = false comes out right without a branch.
IF/CASE WHEN execute all arms and pick per lane with
VectorMask.blend - branch-free, so data-dependent conditions cost the
same as predictable ones (the throughput benchmark prices this).
GREATEST/LEAST skip null operands (Spark semantics) rather than
propagating them.
DAYOFWEEK/WEEKDAY lower Math.floorMod(d, 7) branch-free: two 15-bit
digit-sum folds (2^15 = 1 mod 7) narrow the value until Granlund-Montgomery
magic division by 7 is exact in the low 32 bits, with no final fixup - the
full-range multiply-high the classic trick needs does not exist in the
Vector API, but pre-folding makes the low half sufficient. The VARKA-11
six-fold digit sum and the lanewise-DIV lowering are kept as reference
variants (the parity benchmark's dayofweek section prices all three).
Telemetry and debuggability
Every emitted class is self-describing (VARKA-13, reconciled with sharing in
VARKA-18): a SourceFile attribute named for the shape
(VarkaFusedProjection_<hash>.java, 16 hex chars of the shape's SHA-256), so
stack traces, profilers and heap dumps name the kernel with no mapping table,
and a VarkaDebugInfo custom attribute carrying the vector IR and the shape
identity. The class is shared across tasks, so the per-execution identity -
operator, stage, the projection list - is not in the bytes: the cache records
it per lookup in a bounded side table, and
VarkaShapeCache.executionsFor(hash) joins a shape name seen in a profile
back to the plan nodes that ran it. VARKA-16 extends that to the questions the
attributes alone did not answer:
Bytecode maps back to IR nodes. The class carries a LineNumberTable
whose line n is the n-th IR node in topological order, and
VarkaDebugInfo records the decoding key (<line>=<node> per line). A
stack frame reading VarkaFusedProjection_<hash>.java:7 therefore names the node
that threw, not merely the method - and profilers and crash logs inherit
the same resolution for free.
Fallbacks name their kernel. Every warning on the ghost-fallback path -
emission failure and per-batch kernel failure, in both exec nodes - carries
the kernel's SourceFile name, the IR it computes and the operator/stage it
served, so a log line identifies the plan node without correlating
timestamps.
The class reaches disk.spark.sql.codegen.varka.classDumpDirectory
writes each emitted class under its SourceFile name, so javap -c -p
disassembles a generated loop with no debugger attached. Diagnostics only:
a failed write is logged and never fails the query.
EXPLAIN says why an entry did not fuse. Verbose EXPLAIN on a Varka
projection node lists every projection entry as fused, forwarded (naming the
child column) or residual with the compiler's decline reason - "unsupported
expression", "CASE WHEN without an ELSE branch", "non-date column of
type ..." - in the query's own column names. A column of a type Varka plans
but does not read yet names the type and the task that builds it ("a decimal
column: precision above 18 is row ..."), and the zoned TIMESTAMP the
decision that keeps it out (VARKA-494). Since VARKA-38, a date_add/
date_sub day offset that is neither a foldable literal nor a supported
column gets its own reasons: "non-integer day offset column of type ..."
for a column that is not an integer one (ByteType and ShortType ones
fuse since VARKA-329), "day offset is not a foldable literal,
an integer column or int arithmetic" for anything else (e.g. i % 7, whose
operator no arm lowers). Since VARKA-63, "checked int multiply whose operands
do not rule out overflow" names an ANSI or TRY * the compile-time bound
cannot prove safe - which since VARKA-68 is also how an unbounded ym * k
reports, the interval multiply being that same node - and "day offset
arithmetic that lowers to a node the offset
position does not take" names arithmetic in a date_add/date_sub offset
that lowers to something other than an arithmetic node - weekday(d) + 1,
which is VARKA-57's own node. (intOperand carries a third, "int arithmetic
operand of type ...", which a resolved plan cannot reach: Spark requires both
operands of an Add to share a type, so an IntegerType one has two int
operands by construction.) Since VARKA-59, a next_day whose weekday is neither a literal
nor a stored string column reports "next_day with a weekday that is neither
a literal nor a column"; since VARKA-68, a multiplier that is not an int32
lane reports "interval multiplier of type ... is not an int32 lane", naming
the type rather than reporting it as a bad int operand, so ym * 2.5 cannot
be read as a ym * i; a trunc whose format is neither foldable nor a
stored string column keeps VARKA-35's "trunc with a non-foldable format"
(VARKA-61). Since VARKA-52, a calendar function over arithmetic
that can leave the lowering's range reports "day range [lo, hi] leaves the
calendar lowering's range", with the interval in epoch days, and one over a
producer
the range analysis does not know reports "day producer the calendar range
analysis does not bound"; since VARKA-56, "day interval is not an int column
cast to days" names a day interval that is not CAST(i AS INTERVAL DAY)
over an int column. A Varka filter node (VARKA-21) reports its predicate the same
way, one line per conjunct. The same account goes to the debug log once per
task.
VARKA-22 extends the account to the SQL UI and to JDK Flight Recorder:
Fallback causes are SQL metrics. Every Varka node carries, beside the
row/batch counts and the class-cache hits and misses, cause-keyed
metrics: batches falling back because the input was not Arrow-backed
(empty batches are served trivially and carry no cause), batches the
ghost fallback caught a kernel failure on (a failure in the per-row
machinery beside the kernel is counted, evented and logged under its own
row-path-failure cause instead), batches a kernel declined because a
value fell outside the range one of its lowerings is defined over (the
range-declined cause - a designed outcome rather than a defect, which is
why it is not counted as a kernel failure and is logged at debug, with the
guard that fired named by its status bit, below), tasks
that could not emit or define their kernel class, and - on the projection
nodes - the residual-entry
count (a static plan property, added once driver-side and posted to the
SQL listener; the per-entry reasons stay in verbose EXPLAIN; a
filter's residual is a visible row FilterExec above it rather than a
number, and its numOutputRows counts selected rows). A fallen-back
query is diagnosable from the SQL UI alone: the cause class from the
metrics, the exact reason from EXPLAIN or the log.
Declines by reason, rows and time by path (VARKA-313). Each refusal
reason has its own metric, numDeclinedBatches[<reason>] (day-producer,
month-count, make-date, int-overflow, day-range, value-range,
decimal-slot, divide-by-zero, input-bound, derived-input, forced, and
unrecognised for a status
bit no name covers). A reason reads as a count, 0 included, where every
declined batch that named it named it exactly, and as "not reported" where
a batch named it among others: under the default emit options a loop
method that holds guards of several reasons reports all of them for a
batch any one declined (below), so such a batch cannot be counted against
either, and setting spark.sql.codegen.varka.emit.exactRefusalStatus lets
it be. Where both kinds occurred the cell gives both. numVarkaRows and
numFallbackRows count the input rows each path answered (a projection
that only forwards columns counts with the first), and varkaKernelTime
the time in the kernels of the batches they served, until their output
batch - on a row-out node the residual entries and the row conversion run
lazily after it. fallbackTime, which includes the per-row machinery's
one-time compile, is registered only on the columnar-out nodes, whose
fallback builds its batch before it returns - a row-out node's fallback is
a lazy row iterator, which a bracket around the call would not time. A
Varka filter node's verbose EXPLAIN renders the whole condition when the
rule split it, so a conjunct kept in the row FilterExec above reads as
residual with its reason. Both the EXPLAIN lines and the metrics belong
to the node itself, so they survive adaptive re-planning.
Boxing is sampled. A kernel whose Vector API loop boxes - on HotSpot,
because two vector species of one lane type ran hot in the same JVM -
still answers correctly, several times slower, so no fallback and no
differential test can see it. The evaluator samples the bytes the thread
allocated across the kernel call on a schedule that skips the JIT warm-up
(batch 512, then every power of two and every 4096th batch), counts a
sample above a fixed allowance plus one byte per row under
numSuspectAllocationSamples, and warns once per task on the second
suspect sample in a row, naming the kernel. VarkaAllocationSampler holds
the schedule and the verdict; SKILLS.md's species-pollution section has
the mechanism and the C2 evidence.
JFR events. Four events under the Varka category fire while a JDK
Flight Recorder recording is active - no JVM flag or build change is
needed, jdk.jfr is a default module. Under the shared prefix
org.apache.spark.sql.varka: KernelEmission (timed over emit plus
class define; shape hash, class name, IR sizes, byte count),
ShapeCacheLookup (shape hash, hit, the per-execution identity - the
join a profile needs), Fallback (cause, kernel identity, the emit
options that differ from the defaults, exception class, and for a
declined batch its status word; the cause vocabulary is
the constants on VarkaFallbackEvent), and
KernelAllocation (one per allocation sample, suspect or not: kernel
identity, batch index, rows, allocated bytes, verdict).
Record with a programmatic jdk.jfr.Recording, jcmd JFR.start, or
-XX:StartFlightRecording.
A declined batch names its guard. Each runtime refusal reason has its
own status bit (VarkaFusedKernel: day producer, month count,
make_date, int overflow, re-armed day range, value range), above them
the evaluator's own (input bound, derived input), and the debug line and
the Fallback event carry the word. A loop method whose guards share one
reason reports exactly it; one that holds guards of several reasons folds
them into one mask and reports all of their bits, a candidate set, since a
mask per reason would hold another vector register in the loop. The emit
option exactRefusalStatus gives each reason its own mask, for exact
attribution when diagnosing; a session sets it with
spark.sql.codegen.varka.emit.exactRefusalStatus=true (internal, off by
default), and the kernels it emits are cached apart from the default ones. It is off by
default because it costs a guarded kernel 2.5 to 3.9 percent of its rate on the measured case
(VARKA-313); set it for the session that diagnoses and pay for the exact reasons there.
VARKA-315 leaves a reproduction file behind a kernel failure, as the JVM leaves
an hs_err file behind a crash:
What writes one. A kernel class that fails to verify or define, an
exception thrown inside a kernel, and a memory-sanitizer violation. Each
writes from the catch that already handles it and then falls back or fails
exactly as before; a file that cannot be written is a warning.
What it holds. The failure's signature (VarkaFailureSignature: its kind
and its message with the numbers taken out), the context record of the
warning, the shape key the class is built from - each output's canonical IR,
the counts, the emit options that differ from the defaults by name - the
literal values, the batch as the kernel read it (each input's values,
validity, null count and buffer capacity), and the class bytes. A batch over
spark.sql.codegen.varka.reproduction.maxBatchBytes keeps its shape and not
its values.
Where it goes.varka-repro-<shape hash>-<kind>-pid<pid>-<token>.txt
(the token is the JVM's own, since containers often run every executor as
pid 1) under spark.sql.codegen.varka.reproduction.directory, by default
varka-reproductions under the failing JVM's java.io.tmpdir, owner-only
since a batch is the query's data. One file per shape and kind per JVM, at
most 32 per JVM and 256 in the directory from all JVMs, and the warning
names the file. A projection's kernel and a filter's both write one.
Replaying it.dev/varka_emit.sh --replay <file> rebuilds the kernel from
the file's IR and options (refusing a file whose IR does not hash to its
shape hash), walks the failing path - verification, definition, or a run over
the batch under the sanitizer if the file says it was on - and exits 0 when
the failure reproduces with the same signature. It rebuilds the class rather
than running the bytes the file carries, so a fixed emitter stops reproducing.
All of it is metadata or diagnostics: the emitted methods are byte-identical
with and without the attributes, which the JVM ignores by specification.
VarkaDebugInfoReader turns captured class bytes back into those strings.
Troubleshooting
Start from the symptom. Every branch begins with the same step, which also tells you whether
Varka is involved at all: set spark.sql.codegen.varka.enabled=false and run the query again.
That switches off all of Varka. When Varka is involved, narrow it to one expression family: set
the family's switch, spark.sql.codegen.varka.family.<name>.enabled=false (Configuration lists
them and what each covers), and run again. The switch keeps that family's expressions on the
row engine and the rest of Varka on, so it is also what to leave set while a fault is reported.
symptom
|-- a wrong answer
| Varka off gives the right answer? no -> not Varka; stop
| yes -> A1 which rows, A2 what it compiled to, A3 hand over
|-- a slow query
| Varka off is fast? no -> not Varka; stop
| yes -> B1 counters, B2 reasons, B3 EXPLAIN, B4 change
`-- a crash or an error
INTERNAL_ERROR at planning -> C1 read the context, report it
"failed on this batch" warning -> C2 the file, C3 replay it, C4 read the class
A wrong answer. The row engine is the oracle.
Run the query with Varka off and on and compare the rows; cut the query to the one expression
and the few rows that differ. On the planted fault (a guard removed, so a far date offset
wraps) the on run reads [56782, 49698, 2023, null, 1970, null] against
[56782, -52735, ...] off, and numFallbackBatchesDeclined is 0: nothing declined, the
kernel answered.
dev/varka_emit.sh "year(date_add(d, off))" --columns d:date,off:int prints the IR, the shape
hash and, per emitted method, the VectorMask count. A guard is a mask. The default emits 4 to
7 masks per method; with --options guardDayProducers=false every method shows 0.
The fuzzers' shrinker works on a case a fuzzer drew, not on a query: no command takes your
query and shrinks it. A developer writes the expression and the failing rows as a case for
VarkaIrFuzzSuite (sql/catalyst), which shrinks every failure it finds. On a planted emitter
bug it printed shrunk to lane=int roots=[(isNotNull col:0)] options={misdescribeWordLiveness=true} length=1 from a tree of three conjuncts. Hand over the expression, the
rows and the spark.sql.codegen.varka.* settings you ran with. Until it is fixed, set the
switch of the expression's family to false (Configuration): its entries run on the row engine,
the verbose EXPLAIN names the switch on each, and the rest of Varka stays on.
A slow query. A batch Varka cannot run goes to the row engine, so slowness is declined
batches, an entry that did not fuse, or a slow kernel.
Read the Varka node's metrics in the SQL UI (or metrics on the node). numVarkaBatches and
numFallbackBatchesDeclined count batches by path, numVarkaRows and numFallbackRows rows,
varkaKernelTime the time in the kernels. On the planted query: 1 batch on the kernel, 1
declined, 3 rows each way.
numDeclinedBatches[<reason>] says why: day-producer = 1, the other nine 0. A reason can
read "not reported" when a loop method holds guards of several reasons and reports them
together; spark.sql.codegen.varka.emit.exactRefusalStatus=true (internal, off by default)
gives each reason its own count, and its kernels are cached apart.
EXPLAIN FORMATTED shows what did not fuse at planning: Varka [2]: [a: fused, b: residual (unsupported expression: length(CAST(varka_dates.i AS STRING)))]; a filter has one line per
conjunct. It does not show a decline at run time: the planted query reads y: fused, and
step 2 is the only record.
What to change. A residual entry is an expression Varka does not cover (the coverage table
lists them): rewrite it or accept the row path for it. A decline names a value the kernel is
not defined over (day-range, int-overflow, value-range...): the cure is the data or the
query, not a setting. A slow query with nothing declined is a developer's: a JFR recording
(the Varka events) or the VM flags SKILLS.md records (-XX:+PrintCompilation,
dev/varka_c2_report.py).
A crash or an error.
At planning the query fails with [INTERNAL_ERROR] Varka's compiler failed while planning.
and a Varka context: block: kind: planning, the entries being compiled, the options that
differ from the defaults, the cause. It is a bug in Varka: report the whole message. With
Varka off the query runs.
At run time a kernel that throws does not fail the query. The batch goes to the row engine and
the executor logs "The Varka SIMD kernels VarkaFusedProjection_.java [...] failed on
this batch; falling back to the per-row path.", the same Varka context: block (kind: kernel-failure, shape hash, options, the batch's rows and nulls, the cause) and "Wrote a
reproduction of this Varka failure (...) to ; replay it with dev/varka_emit.sh --replay
". The warning comes once per kernel in each task's evaluator: a kernel that fails on
every batch logs the rest at debug, and the fallback metrics count every batch.
On a checkout, dev/varka_emit.sh --replay <file> rebuilds the kernel from the file's IR and
options, runs it over the recorded batch and prints REPRODUCED: the same signature with exit
0 when it fails the same way. It exits 1 when it does not (a fixed emitter, or an edited
file) and 2 when it could not run (no such file, no report). A file can hold the query's data, so it is owner-only; ...reproduction.maxBatchBytes=0
keeps values out of it and ...reproduction.enabled=false writes none.
To read the class, set spark.sql.codegen.varka.classDumpDirectory=<dir> before the run and
javap -c -p <dir>/VarkaFusedProjection_<hash>.class. javap -v shows the LineNumberTable
(line n is the n-th IR node) and the VarkaDebugInfo decoding key.
Who reads each thing, and what they do:
What you see
Reader
What they do
INTERNAL_ERROR, kind: planning
user, then developer
User: set the switch the message names (the families: line), or turn Varka off, to unblock the query, and report the message whole. Developer: the context names the entries and options; reproduce with dev/varka_emit.sh on the expression
"failed on this batch" warning
operator
Count them per shape hash in the executor logs. The answers are right (the row engine served the batch), so it is a cost and a bug report, not an outage. Collect the file the warning names; a kernel failing on every batch is worked around by the switch on the families: line
the reproduction file
developer
Replay it; the exit status is the verdict. Handle it as data
numDeclinedBatches[...], rows per path
user, operator
A declined batch is slow, not wrong: read the reason, change the data or the query, or turn Varka off for the query
a residual entry in EXPLAIN
user
The expression is not fused: rewrite it or accept the row path for that entry. A reason naming spark.sql.codegen.varka.family.<name>.enabled=false is a switch the session set
java.lang.VerifyError at planning
user, developer
Not yet an INTERNAL_ERROR with a context block (open work); the reproduction file is written and replays
a memory violation (sanitizer on, -Dvarka.sanitizeMemory=true)
developer
A diagnostic JVM property: the violation fails the task by design and writes a file; replay it
VarkaRunbookSuite runs each branch on a planted fault and asserts the reason counts, the EXPLAIN
lines and the warning text quoted above, so a step that stops being true fails a build.
When Varka falls back, and when it fails
Varka answers a batch it cannot run on the row engine, and the answer is still right. Each such
batch has a cause, the tag on the Fallback JFR event (VarkaFallbackEvent), and each cause has a
metric on the Varka node:
Cause
When
What it leaves
What to do
non-arrow-batch
the batch's columns are not Arrow vectors, such as vectorized Parquet's
numFallbackBatchesNonArrow
nothing: a property of the source; the Arrow cache serializer is what produces Arrow batches (Limitations)
range-declined
a value lies outside the range a lowering is exact over
nothing, or change the data or query (Troubleshooting B2)
emission-failure
the task could not build or load the kernel class
numEmissionFailures (tasks), the warning "Failed to emit the Varka fused kernel ...", once per task, a reproduction file
report it with the warning and the file
kernel-failure
the kernel threw on the batch
numFallbackBatchesKernel, the warning "... failed on this batch", a reproduction file
report it with the warning and the file
row-path-failure
the per-row machinery beside the kernel threw
numFallbackBatchesRowPath, the warning "The per-row machinery beside the Varka kernel ..."
report it with the warning
The emitter's designed decline of a shape over its method budget logs "The Varka emitter
declined ..." once per JVM and is not a failure. Every warning of the last three causes ends with
the Varka context: block: the kind (the cause tag), the kernel's identity (its source file, the
IR of each output, the operator and stage), the shape hash, the emit options that differ from the
defaults by name, the families whose nodes the kernel holds, each with its switch (families:),
the batch's rows and nulls per input where a batch was involved, and the original exception. The event's options field carries the same options.
Internal errors. An invariant Varka checks in the compiler, the IR, the emitters, the
options, the runner or the exec nodes raises Spark's INTERNAL_ERROR (SQLSTATE XX000) with the
check's own text and "This is a bug in Varka, Spark's vectorized code generator. Please report it
with this message and the full stack trace." Varka adds no error condition of its own. The
exception is a SparkIllegalArgumentException, SparkIllegalStateException or
SparkUnsupportedOperationException, the JDK type the check raised before, so code that catches
IllegalArgumentException still does. Outside it: the engine module's own checks and the check
inside an emitted kernel raise plain JDK exceptions, which the fallback catches answer. Where an internal error surfaces:
At planning it fails the query. The compiler's catch puts the Varka context: block
around it (kind: planning, the entries being compiled, the options), with the check's
message on the cause: line (Troubleshooting C1). A failure inside one family's lowering also
names that family on the families: line and ends its sentence with the setting that works
around it: "To plan the query with Varka's calendar family on Spark's row engine, set
spark.sql.codegen.varka.family.calendar.enabled to false and retry."; an argument check stays an
IllegalArgumentException, any other becomes an IllegalStateException. Raised on the driver it arrives as it is;
raised by an evaluator's compile in a task, it arrives inside Spark's "Job aborted" error.
While building or running a kernel it does not fail the query: it is one of the fallback
causes above, and the warning's block names it on the cause: line. A kernel that fails on
every batch runs every batch on the row engine; the switch of a family on its families: line
keeps that family's entries off the kernel until the failure is fixed.
Under test, a fallback over a failure no test declared fails the task with
INTERNAL_ERROR and the same block (VarkaColumnarToRowExec.setFailureFallbackExpectedForTesting).
The one user setting with a range, spark.sql.codegen.varka.emit.useAVX, rejects a value out of
range with INVALID_CONF_VALUE.REQUIREMENT, as any Spark setting does. A
spark.sql.codegen.varka.classDumpDirectory that cannot be written is a warning naming the
setting, and the query runs.
Execution integration
VarkaColumnarRule (a ColumnarRule) rewrites a Varka-eligible projection
(at least one fusable entry) over a columnar source when
spark.sql.codegen.varka.enabled is set.
It works in two stages, on either side of Spark's transition insertion, because
which node belongs in the plan depends on what the consumer above wants:
// preColumnarTransitions: columnar in, columnar out
ProjectExec(projectList, columnarChild)
-> VarkaProjectExec(projectList, columnarChild)
// postColumnarTransitions: a to-row transition that was inserted anyway is fused in
ColumnarToRowExec(VarkaProjectExec(projectList, child))
-> VarkaColumnarToRowExec(projectList, child)
A consumer that takes batches - a DSv2 write whose connector declares
supportsColumnarWrite, such as noop - therefore receives the kernels' own
Arrow batches with no transition at all, while a row consumer gets the single
fused node. The rule is registered on every SparkSession but is inert while
the config is off.
Since VARKA-21 the same two-stage rewrite serves filters - the engine's first
plan-shape change. An eligible predicate's compilable conjuncts fuse into a
mask kernel (one fused loop whose single output root is the condition; the
selection bitmap lands in the output-validity slot, a set bit meaning known
true - SQL's null-as-false WHERE rule by construction), and the remaining
conjuncts stay in a row FilterExec above the Varka node, which then sees
only the surviving rows:
The two filter nodes implement the v1 selected-batch contract (the milestone's
open question 2): VarkaFilterExec compacts the selected rows into a fresh
dense batch - an ordinary ColumnarBatch, so every consumer's invariants hold
and a Varka projection stacks directly on top - while
VarkaFilterColumnarToRowExec consumes the selection bitmap at the row
boundary, emitting only the selected rows during row conversion with no
compaction at all. Compaction copies date/int columns Arrow-to-Arrow (keeping
them kernel-servable) and everything else through the standard row-to-column
converter; a selection vector never travels to a non-Varka consumer, because
no Spark operator understands one. Output nullability follows FilterExec's
tightening rule exactly.
Both nodes run the same kernels through VarkaKernelEvaluator, and differ only
in what they do with its output batch and in how they fall back:
VarkaColumnarToRowExec converts to rows and, when the kernels cannot serve a
batch, projects the input's rows one by one; VarkaProjectExec passes the batch
on and has to materialise its fallback into a writable batch instead.
Per task and Arrow-supported batch:
Bind the projection and compile it with VarkaExpressionCompiler into
fused entries (the IR), forwarded entries (bare input columns, passed
through zero-copy) and residual entries (everything else).
Look the fused shape up, lazily, in the JVM-wide class cache
(VarkaShapeCache, VARKA-18): a miss emits and defines the class - named
by its shape hash - in its own VarkaGeneratedClassLoader, and every
task (or session) computing the same shape reuses the loaded class, C2
code and all, skipping the fixed per-task JIT warm-up. The literals never
enter the shape, they travel as runtime arguments - so one class serves
every batch of every task of the shape.
Guard per batch that every referenced column is an ArrowColumnVector
backed by a DateDayVector; otherwise the batch takes the per-row path.
While the shape's class is new and not yet compiled by C2, the batch
takes the per-row path too, and a background thread gets the kernel
compiled (see "A new shape's first batches" below).
Run the kernel: one vector loop writes every fused output into freshly
allocated Arrow vectors. Forwarded columns are re-wrapped, not copied.
Residual entries are evaluated per row and merged - at-row on the
row-consumer node (the escape hatch VARKA-12 measured both ways), into a
writable batch on the columnar one.
Track numVarkaBatches, which only counts batches where the kernels
succeeded, and the class-cache hit/miss per task. A class's loader is
released when the bounded cache
(spark.sql.codegen.varka.cache.maxEntries, default 100) evicts it, so
Metaspace is bounded by cache capacity; running tasks keep their instance
until they finish. The Janino fallback projection is compiled lazily,
only if a batch actually needs it (VARKA-15).
Neither node is CodegenSupport; whole-stage codegen splits at the boundary
with the columnar producer. They depend on the engine only by kernel
descriptors (strings), so a missing engine jar degrades to the fallback.
Key design decisions
Java 25 baseline and a self-contained engine. The Vector API and the
Class-File API require a recent JDK. sql/varka/engine is a module of the
Spark reactor, so a plain ./build/mvn install builds it, but it keeps its
own pom rather than inheriting spark-parent so its sources and tests can use
the incubator-vector and native-access flags the Spark build does not set;
catalyst uses java.lang.classfile on the Java 25 baseline.
Arrow-only fast path. Arrow-backed batches (for example the Arrow cache
serializer) map directly to segments. Vectorized Parquet produces
OnHeapColumnVector/OffHeapColumnVector, not Arrow, so those batches fall
back per batch.
Plan-level interception. The rewrite happens in a ColumnarRule rather
than by editing ColumnarToRowExec itself, and it straddles Spark's
transition insertion: the projection becomes columnar-out before transitions,
and a transition inserted above it is fused back in afterwards. That way the
decision of whether rows are needed at all stays Spark's.
Ghost fallback and caching. Any assembly or load failure lazily routes to
Janino; the winning path is cached under the same key so a failed assembly is
never retried and the job never crashes.
Extreme-offset oracle. At INT overflow (Int.MaxValue - 1,
Int.MinValue) the differential oracle is the plain int32 day wrap that
DateAdd.eval and the kernels implement; Spark's end-to-end row engine adds a
calendar-day rebase for out-of-range DATE results.
One value-range lattice. The compiler's two range questions - can a
calendar node's input leave the range the calendar lowering is exact in, and
can a checked int operation overflow - are queries on one analysis
(VarkaRangeAnalysis over VarkaValueRange), asked with the kind the
parent's slot gives a node and a guard policy that says whether a calendar
consumer above has armed the runtime guards; every operation on the lattice
saturates to unknown rather than wrapping, so no caller can prove a check
away by overflowing.
No unused configuration. Every spark.sql.codegen.varka.* entry must be
consumed. Today enabled, classDumpDirectory, cache.maxEntries,
compilationWatch.enabled, emit.useAVX and warmup.enabled exist, and
each is read on the execution path that documents it.
Module and file layout
Location
Responsibility
sql/varka/engine
Standalone Java 25 module (varka-engine, Arrow 19.0.0): VarkaMorsel, DateVectorOps, VarkaClassLoader and their tests.
sql/catalyst
The vector IR, loop emitter, emit options, shape cache and telemetry attribute under codegen/varka/, all Java; VarkaGeneratedClassLoader, VarkaExpressionCompiler and the compiler families it chains, also Java; DateVarkaSupport's day-offset folding; the Varka configs.
sql/core
VarkaColumnarRule, VarkaColumnarToRowExec, end-to-end test suites and benchmarks.
sql/varka
VISION.md, ADDING_AN_EXPRESSION.md (the contributor path for a new expression), Varka_MVP.md, and plans/ with the milestone plans (m1/PLAN.md is the MVP) and per-task plans.
Configuration
All Varka configurations are internal. The family.<name>.enabled switches, in their own table
after the others, are the compiler's expression families (VarkaFamily): the families of the
chain VarkaNodeCompiler dispatches every node through, and the predicate family, which lowers
the comparisons and connectives of a filter and of a conditional's condition. A family that is
off declines every node it claims, with the reason
Varka's <family> family is switched off (<switch>=false) in the verbose EXPLAIN, and the entry
holding that node runs on the row engine while the rest of the projection or filter still fuses.
Each node is under exactly one switch, wherever it sits: a comparison inside a CASE WHEN
branch's condition is the predicate family's, so with that switch off the CASE WHEN declines
too, and the CASE WHEN itself is the condition family's. A column or literal is never declined
by a switch, so a bigint comparison, or a TIME(3) column relabelled to TIME(6) for one,
still fuses with the time family off. A node of one family that another's lowering builds
directly, such as the negated interval in d - ym, asks its own family's switch; helper code two
families share, such as the overflow decision or the pick fold greatest borrows, runs under the
switch of the node it serves. The date leaves (a date column, a date literal, the identity date
cast) have no switch. The coverage table's Switches column names each row's.
Config
Default
Description
spark.sql.codegen.varka.enabled
false
When true, an eligible projection (at least one fusable entry) over Arrow DateDayVector columns runs the fused SIMD kernel instead of per-row codegen - as VarkaProjectExec where the consumer takes batches, and as VarkaColumnarToRowExec where it wants rows; ineligible entries run the row path per row and merge, and non-Arrow batches fall back entirely.
spark.sql.codegen.varka.classDumpDirectory
(none)
Diagnostics (VARKA-16). When set, every emitted kernel class is written to this directory under its SourceFile name, for javap. A failed write is logged and never fails the query; every task of a shape holds identical bytes and overwrites one file.
spark.sql.codegen.varka.reproduction.enabled
true
VARKA-315. A kernel class that fails to verify or define, an exception inside a kernel, or a memory-sanitizer violation writes one reproduction file, which dev/varka_emit.sh --replay runs again outside Spark (Telemetry and debuggability). The failure is handled as without it.
spark.sql.codegen.varka.reproduction.directory
(none)
Where reproduction files go on the failing JVM; unset, varka-reproductions under its java.io.tmpdir. Created owner-only, since a file can hold a batch of the query's data.
The most bytes of a failing batch's values a reproduction file holds; a larger batch keeps its row count, null counts and buffer sizes, and a replay runs a synthetic batch of that shape. 0 never writes values.
spark.sql.codegen.varka.emit.useAVX
-2
The -XX:UseAVX level the emitter lowers for where a lowering depends on it (VARKA-121): 3 or above takes a 64-bit division through double lanes, 2 the magic-number form, because the converts do not become instructions without AVX512DQ. -2 resolves it from the driver's JVM (VARKA-538): level 2 where HotSpot's feature list lacks AVX512DQ and the preferred LongVector species, which -XX:MaxVectorSize caps, is at least 256 bits wide (on the EPYC 7763 the magic form was ten to twenty times faster at 256 bits and about half as fast at 128), 3 on an x86 host whose list holds AVX512DQ and on an aarch64 host, whose matcher lowers both 64-bit conversions to instructions (VARKA-584), the emitter's default otherwise or where the list cannot be read (it needs --add-exports=java.base/jdk.internal.vm.vector=ALL-UNNAMED, which Spark's module options carry); the driver's host decides for the whole plan, and on a mixed cluster both forms are correct. -1 leaves the emitter's own default, which is deliberately not the host's level so the shape hashes and the committed bytes describe no one machine; the Varka test sessions pin it. An explicit level wins over the host, and the level is part of the shape hash, so a session at a level emits and caches its own classes.
spark.sql.codegen.varka.cache.maxEntries
100
Static (VARKA-18). Capacity of the JVM-wide cache of loaded fused-kernel classes, keyed on the kernel's structural shape; the least recently used class is released on eviction, bounding Metaspace by this size. 0 restores the per-task emit-and-unload lifecycle.
spark.sql.codegen.varka.warmup.enabled
true
VARKA-212. When true, a newly emitted kernel serves no batch until C2 has compiled it: the shape's batches take the per-row path while a background thread runs the kernel on a copy of the first batch, and every task of the shape switches to the kernel once it runs without allocating. When false, a new kernel serves batches from the first and runs interpreted until enough batches have gone through it.
spark.sql.codegen.varka.math.ulpContract.enabled
(none)
Opt-in. Unset or false, every math function Varka fuses returns Spark's answer bit for bit. When true, a math function may compute with the JDK's vector math library where its bound is contracted for the host's library: faster, and within that many representable doubles of Spark's answer rather than equal to it, so a value grouped, joined on, sorted or written as a partition key above the kernel may fall on the other side of a threshold. No function has a contracted bound yet and none computes under it, so it changes no plan today (What fuses, by type). True is part of the shape hash, so such a session emits and caches classes of its own.
The family switches (VARKA-318), generated from VarkaFamily by VarkaCoverageSuite with the
coverage table, and regenerated by the same command:
Config
Default
Covers
spark.sql.codegen.varka.family.calendar.enabled
true
The calendar family: day arithmetic (date_add, date_sub, datediff, unix_date, date_from_unix_date), the calendar fields (year to weekofyear), make_date, last_day, next_day, trunc, add_months and a date plus a year-month interval, and the same fields and month shifts of a TIMESTAMP_NTZ through its date, its sum with a year-month interval and timestampadd of months, quarters or years.
spark.sql.codegen.varka.family.interval.enabled
true
The interval family: year-month and day-time interval arithmetic, negation and abs, make_ym_interval, the year and month extractions, extract(DAY) of a day-time interval, the multiply by an int and the casts between year-month intervals and ints.
spark.sql.codegen.varka.family.time.enabled
true
The time family: the TIME functions (hour, minute, second, time_trunc, time_diff, the conversions to and from micros and millis, a time plus a day-time interval), the casts to TIME and to a day-time interval, hour, minute and second of a TIMESTAMP_NTZ, make_timestamp_ntz(date, time) and the cast of a TIME to TIMESTAMP_NTZ, TIMESTAMP_NTZ minus TIMESTAMP_NTZ, a TIMESTAMP_NTZ plus or minus a day-time interval, and timestampadd of a TIMESTAMP_NTZ by a unit from a microsecond to a week.
spark.sql.codegen.varka.family.predicate.enabled
true
The predicate family: the comparisons, IN over dates and year-month intervals, IS NULL and IS NOT NULL, AND, OR and NOT, wherever they sit: a filter's predicates, so that no filter fuses, and the conditions of IF and CASE WHEN.
spark.sql.codegen.varka.family.condition.enabled
true
The condition family: the conditionals IF, CASE WHEN and coalesce (the comparisons in their conditions are the predicate family's).
The int arithmetic family: +, -, * and unary minus over int, bigint, tinyint and smallint operands and abs over bigint and the narrow two, checked under ANSI, greatest and least, the casts between int and bigint, and a tinyint or smallint widened to int.
The floating arithmetic family: +, -, *, unary minus and abs over double and float operands, and /, try_divide, sqrt, signum, degrees and radians over double ones, signum over year-month and day-time intervals too, a zero divisor null under LEGACY and TRY and raised by the row engine under ANSI, and the canonicalisation of a double or float key (NormalizeNaNAndZero: -0.0 to 0.0, every NaN to the canonical NaN).
The floating casts family: the casts to float from tinyint, smallint, int, bigint and boolean, to double from tinyint, smallint, int, bigint and boolean, and between float and double; bigint to either at the default emit level, and the casts from a floating type to an integral one, are left to the row engine: a session naming a level fuses the bigint ones (level 3 in one instruction, below it by exact AVX2 forms), as does one asking for the host's on a CPU whose features are read: aarch64, or x86 with AVX512DQ or a long species of 256 bits or more.
The integral cast family: the casts among tinyint, smallint, int, bigint and boolean that the int arithmetic family does not hold: the narrowings to tinyint and smallint (wrapping, or checked under ANSI), a tinyint or smallint widened to smallint or bigint, a number cast to boolean and a boolean cast to a number.
spark.sql.codegen.varka.family.rounding.enabled
true
The rounding family: rint over a double; floor, ceil and ceiling over bigint and int operands; and round, bround and truncate over tinyint, smallint and int at a constant scale, and over bigint at a scale of zero or more.
spark.sql.codegen.varka.family.math.enabled
true
The math family: the math functions over double operands (sin, cos, tan, asin, acos, atan, atan2, sec, csc, cot, sinh, cosh, tanh, asinh, acosh, atanh, exp, expm1, ln, log, log10, log1p, log2, pow, hypot and cbrt), each bit for bit Spark's unless spark.sql.codegen.varka.math.ulpContract.enabled is true; none fuses yet, and each declines naming the row of the plan that fuses it.
The rule is registered on every SparkSession but does nothing while the
config is off, so enabling the config is all that is needed:
valspark=SparkSession.builder()
.appName("app")
.config("spark.sql.codegen.varka.enabled", "true")
// Arrow cache is the recommended production source of DateDayVector batches.
.config("spark.sql.cache.serializer",
"org.apache.spark.sql.execution.columnar.ArrowCachedBatchSerializer")
.getOrCreate()
The Arrow fast path reads cached batches through the in-memory columnar
vectorized reader (spark.sql.inMemoryColumnarStorage.enableVectorizedReader,
true by default), so caching with the Arrow serializer produces
ArrowColumnVectorDateDayVector batches. Without an Arrow-backed source
Varka uses the row engine for every batch and results stay correct; where a
setting would give it batches - the vectorized reader off, another cache
serializer, or a query reading more than spark.sql.codegen.maxFields columns -
it logs the reason at INFO. With Varka on, an Arrow cache counts that limit over
the columns a query reads rather than the whole table.
The VISION draft also describes spark.sql.codegen.varka.patch.threshold and
spark.sql.codegen.varka.fallback.ghost.enabled. They are design intentions,
not configuration entries in this MVP: per the project rule ("no unused
config"), they will be added to SQLConf only when the code paths they gate
exist.
Testing and benchmarks
Engine differential tests cross-check every kernel against Arrow's own
vector accessors, including null patterns, empty batches and offsets near
Integer.MAX_VALUE.
Catalyst tests check bytecode shape by disassembly, the loader
define/release lifecycle, and ghost-fallback injection.
They are ScalaTest suites or, for a suite whose helpers are Java,
JUnit 5 classes under @VarkaSuite; both run under the same option
matrix, skip list and per-test watchdog, and a JUnit test is printed and
matched by its @DisplayName sentence as a ScalaTest test is by its name.
Random kernels, in the code users run (VarkaIrFuzzSuite,
VarkaTierWitnessSuite): the IR fuzzer compares random trees with a reference
evaluator row by row, each kernel once in the interpreter and the first 20
draws a lane again over eight batch histories - warmed until C2 has compiled
every loop, warmed on calls that never leave a remainder or a null column and
then given one (a trap back to the interpreter), recompiled after that trap,
and run cold with C1 on through on-stack replacements at both tiers. A JFR
stream and the code cache's method list say which JIT tier served each
compared call (VARKA-274).
sql/core harness tests (VarkaCoverageHarnessSuite,
VarkaDifferentialHarnessSuite, VarkaTimeHarnessSuite, VarkaHarnessParitySuite)
hold the kernels' answers to Spark's own evaluation of the optimized expression with
no session, through the production evaluators over the Arrow cache's batches.
sql/core tests (VarkaColumnarToRowExecSuite, VarkaProjectExecSuite,
VarkaFilterExecSuite, VarkaColumnarWriteSuite, VarkaEndToEndSuite,
VarkaDifferentialSuite, VarkaCoverageDifferentialSuite,
VarkaAutoRegistrationSuite) prove plan fusion,
checkAnswer equality over a query matrix - re-run warm so a cache hit is
differentially checked too - numVarkaBatches > 0 on fused plans,
Metaspace bounds, and config-driven activation.
Four stronger forms over every coverage row. The kernel checks
poison every null lane, put a fixed batch with a poisoned lane in the loop
and the epilogue in front of each row's masked body, and run every
compared batch with the output validity pre-filled with zeros, as
production's Arrow buffers are, and with ones, so a kernel that fails to
set a bit fails as surely as one that fails to clear it.
VarkaCoverageDifferentialSuite checks each predicate row's three
partitions: WHERE p, WHERE NOT (p) and WHERE (p) IS NULL on Varka are
each Spark's, compared as rows, share no row and leave none out, under
the default optimizer and with BooleanSimplification,
NullDownPropagation and InferFiltersFromConstraints excluded so
NOT (p) and (p) IS NULL reach Varka as written; the two null tests also
run as the condition of a CASE over every predicate row. And under ANSI, on a fixture of the
types' extremes, each row runs alone and where Spark skips it - the
untaken arm of a CASE, a later COALESCE argument, the right side of a false
AND or a true OR: both engines raise the same error, compared by condition,
SQLSTATE and message parameters, or both answer the same rows. A skipped
position must be served by a kernel or be on the suite's declined list
with its reason. And each row that names a domain runs over a fixture that
straddles every guard's bound, cut as TLP cuts a table into the rows inside
the domain, outside it and where it is unknown, as a projection and as a
filter: inside and under IS NULL the kernels serve every batch and nothing
declines; outside, every batch declines with exactly the status
VarkaGuardSpec's verdict calls for, read off the JFR fallback event, and
the answer is Spark's, rows or the same error (VARKA-279).
Spark's own date tests (VarkaGoldenCorpusSuite) run the select
statements of the golden-file inputs (date.sql, interval.sql,
extract.sql, the timestamp and datetime files) on both engines, each
literal of a type Varka reads turned into a column of an Arrow-cached
fixture, as a projection and as a filter. sql/varka/golden_corpus.json
records every statement's rewrite, plan verdict and outcome, and the counts
of what fuses per file.
Spark's whole golden-file suite (VarkaSQLQueryTestSuite,
dev/varka_golden_suite.sh) runs every SQLQueryTestSuite file with
Varka on, Spark's committed .sql.out files the oracle. A test-only
extension puts an Arrow-cached copy under every relation with a column
Varka reads, except under a command or a hidden metadata column, so the
queries reach the kernels, and lifts a SELECT with no FROM into a
relation of seventeen equal rows where the compiler fuses its literals as
columns; a second arm runs the same source with Varka off,
so a failure in both is the harness's and one only with Varka on is
Varka's. sql/varka/spark_suites/excluded.tsv says what the cache itself
changes: the files whose EXPLAIN output prints plans, which then compare
every other statement, and the tests that may fail and why; an entry that
no longer applies fails as stale. served.json records per test how many
query executions Varka served a batch in, and a test that served one when
it was written must still serve one. It needs a JVM of its own, since it
fixes the process-wide cache serializer, never writes golden files, and
runs in dev/varka_nightly.sh.
Metaspace proof (VarkaGeneratedClassLoaderSuite,
VarkaShapeCacheSuite) verifies with weak references that a released
loader is collected, that a batch of 1000 loaders is fully collected, and -
since VARKA-18 - that a 10k-distinct-shape stress stays at cache capacity
with every evicted loader collected.
Benchmark highlights from the committed runs - the throughput file from
VARKA-19's run, which extended the row-consumer matrix with heavy-op twins;
cold start and class generation from VARKA-18 (AMD Ryzen AI 9 HX PRO 370,
JDK 25, Linux, machine otherwise idle; every number below is the best of at
least five two-second-windowed iterations and lives in the committed results
files, which are the source of truth as the code moves):
End-to-end columnar throughput over 2M Arrow-cached rows
(VarkaThroughputBenchmark): 3.6-6.0x Janino for single ops and small
trees (date_add 3.6x, datediff 4.8x, the nested
datediff(date_add(d, 1), d2) 5.6x, the two-output shared subchain 6.0x),
2.5x for a mixed projection where only one entry fuses. Before the class
cache these read 1.7-2.3x: the per-task JIT warm-up was most of the gap
between the buffer-level kernels and the end-to-end numbers.
CASE WHEN by mask blend: 7.0x on data where the condition flips
pseudo-randomly, 5.8x where it is perfectly predictable. The varka side
costs the same on both within a millisecond (branch-free execution is
data-oblivious, 8-9 ms best in the committed cases); the gap is Janino's
branch misprediction on the unpredictable data.
Chain depth (alternating date_add/date_sub, columnar consumer):
6.4-6.9x, flat from depth 1 to depth 8. VARKA-14 committed this curve as
2.2x eroding to 1.3x and diagnosed the erosion as the fixed per-task JIT
warm-up that grew with the loop method's op count (VARKA-14.md 7.5);
VARKA-18's cross-task class cache removed exactly that term - every task
now runs the C2-compiled loop from its first row - and the end-to-end
curve became what the buffer-level numbers always predicted (depth 8
within 10% of depth 1).
The row-consumer cost, stated plainly: assemble-then-read costs a
flat ~25 ns/row on an all-fused single-output projection, whatever the
fused work - VARKA-19's extended matrix pinned the floor (the ~16 ns/row
previously quoted was contaminated by the pre-cache JIT warm-up). Fusion
through rows wins exactly where Janino's own per-row cost exceeds that
floor: dayofweek 1.2x and unpredictable CASE WHEN 1.1x, against the
cheap chains at 0.8x (Janino ~20 ns/row) and residual-heavy at 0.6x.
There is no break-even depth, and no plan-time cost gate separates the
winners from the losers - an 8-op chain loses while the ~6-op CASE WHEN
wins, because the differencer is Janino's cost, not Varka's - so the rule
keeps fusing row consumers: VARKA-19's recorded decision.
dayofweek: 8.8x - the largest committed
win, and the shape that pays even through a row consumer (1.2x there). This case shipped as the honest loss of the original VARKA-14 run
(0.9x, the magic-multiply lowering of 7.7 took it to 1.2x): its ~12-op
loop method paid the heaviest per-task warm-up (~50 ms), so removing the
ladder moved it furthest.
Filters (VarkaFilterBenchmark, VARKA-21 and VARKA-24, d < DATE over 2M
rows at a 0-100% selectivity ladder): the compacting VarkaFilterExec wins
2.5x at 0% selected, rising to 5.4x at 100%. The rise is VARKA-24's
compress(mask) compaction and it is the interesting part: the typed
scalar copy it replaced was one Arrow call per selected row, so its cost
grew across the ladder (5.4 ns/row at 15% selected to 8.6 at 100%), while
IntVector.compress is one instruction per lane group whatever the group
holds and stays flat at 3.8-4.2 ns/row. Compaction has stopped being a
function of selectivity, which is why there is still no compaction
threshold - there is now less reason for one than when VARKA-21 declined it.
The mask-skip row node wins 2.3x at low selectivity, decaying to 1.1x at
all-selected as the task-19 read-back floor takes over. The stacked
filter-then-fused-projection shape holds 3.5x-4.7x, and the
previously-parity WHERE d IN (5 literals) anchor runs 2.0x. The honest
loss is unchanged: COUNT(*) over an 85%-selective filter is 0.8x (1.8x at
15%) - nearly every row crosses the row boundary into the aggregate.
Cold start (VarkaColdStartBenchmark, a fresh plan shape of 16 entries
over 100K rows, on the milestone 7 build): the first run takes the row path
while the warm-up compiles the kernel, 137 ms against stock's 119 ms; once
the kernel is in, 1.6x - 31 ms vs 49 ms best, 40 ms vs 54 ms average - and
the warm-up's verdict comes in about two seconds. A fresh shape misses the
class cache, and the benchmark enforces that by invalidating the cache
before each timed iteration - its column-and-literal freshness is invisible
to the structural shape key. The Varka side pays emission plus the class
define here; only repeated shapes get the cache's win.
Class generation in isolation (VarkaCodegenBenchmark): emitting,
defining, loading and instantiating a fused two-output kernel takes
~99 us against ~6.5 ms for one Janino projection compile - 66x. (The
milestone-1 single-op dispatcher case that used to sit beside it, at
~420x, went with the dispatchers in VARKA-17.)
Deployment and requirements
JDK 25 with the incubator Vector API module:
--add-modules jdk.incubator.vector--enable-native-access=ALL-UNNAMED
The engine jar in the repo is a test-scoped dependency; at runtime supply it
with --jars (its absence only falls back to per-row execution).
Arrow DateDayVector and IntVector buffers come from Arrow-backed
producers; the Arrow cache serializer is the recommended source.
Limitations
The real current edges, stated with their numbers where they have one:
Thirteen types, and not the rest. Varka reads BOOLEAN, TINYINT,
SMALLINT, INT, BIGINT, FLOAT, DOUBLE, DECIMAL to precision 38,
DATE, TIMESTAMP_NTZ, TIME and both interval types, and What fuses, by
type says how much of each fuses. STRING and its casts, TIMESTAMP with
the local time zone and decimal division are out of scope by the owner's
decision of 14 October 2026, and CalendarInterval and nested types have no
representation. A day offset is a foldable integer literal, an INT,
SMALLINT or TINYINT column, or int arithmetic over those.
A SIMD lane cannot throw row-accurately, which shapes how ANSI overflow
works rather than excluding it. VARKA-63 fuses integer arithmetic over a
datediff result and over the calendar fields; where the operands' ranges do
not rule overflow out, the kernel marks the overflowing lanes and declines the
batch, and the row engine recomputes it and raises. So the error is Spark's
own, from the engine that can attribute it to a row - at the cost of one
fallback for the batch that contains it.
The row-consumer read-back can cost more than fusion saves: cheap
chains commit at 0.8x and residual-heavy at 0.6x, while heavy shapes win
through rows (dayofweek 1.2x, CASE WHEN 1.1x) - the ~25 ns/row
assemble-then-read floor decides which (VarkaThroughputBenchmark).
VARKA-19 measured both sides and recorded the acceptance: no decline rule,
because no plan-time number separates the shapes and VARKA-21's filters
keep more output columnar.
Vectorized Parquet falls back: OnHeap/OffHeapColumnVector batches
are not Arrow. The Arrow cache serializer is the production source of
eligible batches.
No whole-stage codegen integration. The Varka nodes are not
CodegenSupport; whole-stage codegen splits at the boundary.
Emitter caps: chain depth 16, 64 distinct ops, 64 input columns per
kernel, and 16 literals per fused IN list. Since VARKA-20 the compiler
mirrors the depth and op budgets and demotes an overflowing entry to
residual with a recorded reason, instead of the whole kernel silently
falling back per batch at emission. A capped IN still lands in one
loop method (the emitter never splits inside an output): 33 vector ops
in the benchmarked cap shape - 16 EQ + 15 OR + the blend + the branch
arithmetic, about twice the per-method GROUP_BUDGET - so a fresh IN
shape's first execution pays a one-time C2 compile of roughly 1 ms per
vector op; the class cache amortizes it across every later task of that
shape, and the exception is registered with the GROUP_BUDGET rule in
sql/varka/AGENTS.md.
Two dozen scripts under dev/ support this engine. They exist because Varka's
correctness and its performance claims are both checked mechanically rather
than by review, and most of them encode a lesson learned the expensive way.
Every one answers --help with its own usage; what follows is what each is
for, so you can tell which one you want.
Everyday checks
Tool
What it is for
varka_precommit.sh
The house rules that slip most often - a non-ASCII byte outside a string, a source line over 100 columns, a TODO marker under a Varka directory, the quote check when a document changed, SKILLS.md's generated index, ruff on Python - over the files about to be committed. Install once with --install-hook.
varka_gate.sh
The full standing gate in one command: everything a task plan's "Verification" section lists, in order, each step logged. Run before proposing a change.
varka_toc.py
Regenerates SKILLS.md, the index over the lesson files under sql/varka/skills/, from their headings; --check reports a stale one and the pre-commit hook runs it whenever either side changes. Without --from it lists a single document's own headings instead.
varka_errorprone.sh
Error Prone and NullAway over Varka's Java, in their own javac pass apart from the build, -Werror (VARKA-266). NullAway checks every Varka class but those listed in dev/varka_nullaway_pending.txt, a list the script lets only shrink; every @SuppressWarnings must say why on its line or the line above. The gate's lint step runs it; the jars are pinned by sha256 and fetched into build/ on first use.
varka_quote_check.py
Does every performance number quoted in the plans, the lesson files, the docs and the README trace to a committed results file? Numbers that predate the tool live in varka_quote_allowlist.txt with a reason each, and that list only shrinks.
varka_worktree.sh
Lists the task worktrees this repository accumulates and removes the merged ones (list, gc).
varka_pr_sweep.sh
Dry-merges every open pull request against master, and every pair of open pull requests against each other, without touching the working tree - so a conflict between two in-flight branches is found before one of them merges.
varka_task_new.sh
Starts a task the way they all start: worktree and branch off master, a plan file from the template, the pre-commit hook installed.
check_varka_arrow_version.py
Guards that the engine module's Arrow version still matches the one Spark ships, since the morsel maps Arrow's buffers directly.
Understanding what the compiler did
Tool
What it is for
varka_emit.sh
The main introspection tool. Give it SQL expressions and it prints what they compile to - the IR, the shape hash, and per emitted method the bytecode size and vector-op counts. --asm adds C2's assembly for the dense loop, --table prints the op-count table a plan registers, --options k=v selects an emitter variant, --repeat N re-emits the shape N times and reports the median, a loop a profiler can sample. Start here when asking "why did this not fuse" or "how expensive is this shape".
varka_jfr_frames.py
Where the time goes inside one code path: reads a JFR recording's execution samples (jfr print --events jdk.ExecutionSample --stack-depth 64) and attributes each to the emitter phase whose frame the stack holds and to the nearest Varka frame to the top, so the JDK's work on Varka's behalf is charged to the method that asked for it. VARKA-191's admission check is its first use.
varka_hsdis_build.sh
Builds hsdis, the disassembler plugin -XX:+PrintAssembly needs and no JDK ships, in seconds from the JDK's own source and the distribution's capstone library. Needed by varka_emit.sh --asm.
varka_trap_census.py
Splits HotSpot's LogCompilation output into the two different things called uncommon_trap and reports per-method deoptimisation and compile counts - for when a kernel is fast in isolation and slow in a query.
varka_c2_report.py
What the JIT made of one class's methods, from -XX:+LogCompilation: per compilation, which compiler made it or failed, the bytes of callees inlined, the intrinsics applied and the calls left in the graph, the allocations and boxes escape analysis eliminated, and the inlines refused with their reasons; then a per-method summary with the traps and discards that hit its C2 code - for when the same generated code allocates on one path and not on another (VARKA-228.md 7), or is compiled again and again (VARKA-209.md 9).
varka_inlining_cliff.sh, varka_inlining_cliff.py
VARKA-209's census: fresh JVMs of VarkaInliningCliffProbe, the cheap-tail kernel at a given output count and fused ceiling, under -XX:+LogCompilation and PrintInlining/PrintIntrinsics scoped to the emitted class; the reader gives every fork a fast-or-slow verdict, the second it settled, and what C1 and C2 made of its loop method, and splits C2's words by verdict - for the cliff a loop method meets past C1's limit (VARKA-209.md 9).
varka_word_census.sh
Reports what validity word each IR value root produces, over the whole corpus - the audit behind the null-handling algebra.
varka_deopt_cycle.sh
Does a kernel's dense loop compile once, or enter the C2 deoptimization cycle (VARKA-189)? Forks fresh JVMs of the make_date ladder's kernel at a width and in an epilogue form under -XX:+PrintCompilation and -Xlog:deoptimization=debug, since the cycle is decided at a method's first C2 compile and then stable for the JVM's life, so forks are the sample.
varka_deopt_cycle.py
Reads those logs and gives the verdict per fork from the JVM's own words - a loop method made not entrant three or more times and trapped at profile_predicate more than four times - never from a rate. With --fail-on-cycle it exits non-zero when any fork cycles, fails to finish, or no fork is read; VarkaDeoptCycleSuite holds the rule against recorded logs.
Refactoring and porting
A change that moves code between files, or ports a file from Scala to Java, starts from an
inventory and ends with imports to clean up. These three do both from the source and the
build's own reports, so the plan names members that exist.
Tool
What it is for
varka_members.py
The member map: every member of each top-level type in the files given, with its line range, doc comment's first sentence, and, with --callees, which other listed members it calls. The inventory a refactor's plan lists, generated rather than written from memory.
varka_callgraph.py
The calls that cross between named groups of members (--group NAME=REGEX), or between files (--by-file): before a split, the seam with the fewest crossings is the one to cut; after it, what still crosses.
varka_unused_imports.py
Reads a build log's unused-import reports - scalac's, which Spark's build makes errors, and checkstyle's from dev/lint-java - and removes every one in a pass, down to the one selector of a brace import. A moved file inherits all its source's imports, and the build otherwise reports them one per multi-minute run.
Measuring, and not fooling yourself
The benchmark tooling is built around one observation: the same code has
measured its memory-bound kernels 20-27% apart on different days with every
compute-bound row flat. So the machine's state is checked before a number is
believed, and a number is compared against a committed baseline rather than
remembered.
Tool
What it is for
varka_bench_canary.sh
Is this machine in the state the committed files were measured in? Runs three fixed loops - a compute-bound control, a cache-resident vector add, a memory-bound one - and compares them against this host's committed baseline. The regeneration script runs it first and stops if the machine has drifted.
varka_bench_regen.sh
Regenerates one benchmark's committed results at both vector widths, with a provenance sidecar, and ends by diffing against what was committed. The normal way to update a results file.
varka_bench_diff.py
Reads that diff on its own: before/after between two files or against a git revision, or A/B pairs inside one file. Scalar control rows are listed first, because if they moved the machine moved and nothing else in the file can be read. --requote turns a diff into the list of document lines still quoting the old numbers.
varka_bench_gate.py
Asserts the invariants a results file must satisfy whatever its numbers are - no duplicate case ids, no missing provenance, no impossible rate.
varka_bench_band.py
How far apart do repeated runs of one benchmark land, per case? --split-half asks whether that spread itself reproduces. Use it before believing a small win.
varka_bench_repeat.sh
Runs one benchmark N times so varka_bench_band.py has something to read.
varka_bench_ids.sh
Which benchmark case ids are taken and which is the next free one - the ids must be unique per file and picking one by eye gets it wrong.
varka_nightly.sh
The checks that need volume or an idle machine, into a dated log: the canary, the IR fuzzer at ten thousand iterations, the exhaustive sweeps, every small IR tree to size 5, the deoptimization-cycle guard (ten forks per width of the default twelve-output kernel), optionally the full gate.
varka_series.sh
Every IR tree the fuzzer's grammar could draw up to a size, counted in grammar productions, through the emitter against the reference evaluator, one JVM per core (VARKA-269): size 5 is 3.76 million trees at both lanes, about twelve minutes on the laptop; the gate runs size 3, and size 4 runs at night: at the narrow width in the nightly fuzz job and under every emitter configuration in the weekly option matrix. --variants runs each tree again in eight variants whose answers follow from its own - beside a child or an unrelated tree, duplicated, copied, its literals in columns, its columns renumbered, an untaken arm replaced (VARKA-278) - size 3 in the gate and size 4 at night.
The cross-distribution surface benchmark
These four run the public comparison against stock Apache Spark - the numbers
in the README - and are described from a user's side in that file's
"Reproducing it" section.
Tool
What it is for
varka_bench_surface.sh
Runs the date surface, or the chained expressions, against several Spark distributions one after another and prints the comparison. Refuses a busy machine, records the datapath probe and host in every file, and fails a run whose cached table did not stay in memory or whose per-job fixed cost exceeded 5% of a Varka row's wall time.
varka_datapath.sh
Describes the machine and measures its vector datapath, exiting non-zero if it is not what the caller asked for. It reports lanes per nanosecond at three widths, because "has AVX-512" does not tell you whether 512-bit operations issue at full rate - some server parts read 1.33x where a full-width one reads 2x. Used as the gate on CI benchmark jobs and runnable on a laptop to see what it has.
varka_surface_shards.py
Runs one sharded surface across CI runners and re-dispatches the shards that miss, for when the whole list does not fit one job's time limit.
varka_bench_merge.py
Joins those shard files back into one file per distribution.
varka_post_page.py
Renders a post's Markdown and the SVGs its figure scripts produce into the standalone page that gets published, inlining each figure so the page carries its own drawings and fonts.