Spark Expression Support#
This page is the complete reference for how Apache Comet handles each Spark built-in expression. Comet accelerates expressions either with a native (Rust) implementation or by dispatching to a Spark-compatible codegen path. When an expression is not supported, Comet transparently falls back to Spark for that part of the plan; results are unaffected.
Expressions marked β Supported are enabled by default and produce Spark-compatible results.
Some β
Supported expressions have specific incompatible cases that are not run by default.
Those cases must be opted into per expression with
spark.comet.expression.EXPRNAME.allowIncompatible=true (where EXPRNAME is the Spark
expression class name, for example Cast). There is no global opt-in. By default such a case
either falls back to Spark (for example the mode aggregate) or, when the expression has a
Spark-compatible codegen-dispatch implementation, runs through that instead (for example cast
and the regex and JSON families). See Native and codegen-dispatch implementations
for how Comet chooses.
Most expressions can also be disabled with spark.comet.expression.EXPRNAME.enabled=false, where
EXPRNAME is the Spark expression class name (for example Length or StartsWith). See the
Comet Configuration Guide for the full list.
Status legend#
Status |
Meaning |
|---|---|
β Supported |
Comet produces Spark-compatible results by default. Some inputs or forms may fall back to Spark, and any incompatible behavior is opt-in (off by default). |
π Planned |
Intended; tracked by an open issue or pull request. |
Implementation legend#
The Implementation column records how Comet executes each expression when it is not falling back to Spark:
Implementation |
Meaning |
|---|---|
Native |
Cometβs Rust engine evaluates the expression end to end. |
Codegen dispatch |
Sparkβs own generated JVM code is evaluated inside the Comet pipeline. Used when a byte-exact match to Spark matters more than the native speedup, or when no native path exists. |
Hybrid |
Both paths exist. Comet picks between them based on input, and the user can override with |
β |
No direct wire-up: the row is either planned, is rewritten to another expression before Comet sees it (for example |
The Implementation column is auto-generated from the serde definitions in QueryPlanSerde; do not edit it by hand.
Not currently planned#
Comet focuses acceleration on mainstream relational, string, datetime, math, and collection expressions. The following function families are not currently planned for native acceleration (they are not on the current roadmap): specialized functionality with narrow real-world analytics use and high implementation cost. They fall back to Spark and may be reconsidered based on demand:
Probabilistic sketches and approximate top-k (
kll_sketch_*,theta_*,count_min_sketch,bitmap_*,approx_top_k*): specialized data structures with exact-correctness traps.Geospatial (
st_*): brand-new Spark 4.1 functionality, specialized.Avro / Protobuf codecs (
from_avro,to_avro,from_protobuf,to_protobuf,schema_of_avro): format conversion belongs at the IO layer, not expression evaluation.JVM reflection (
java_method,reflect,try_reflect): niche, and they invoke arbitrary JVM methods (a security concern).UTF-8 validation (
is_valid_utf8,make_valid_utf8,validate_utf8,try_validate_utf8): niche Spark 4.x string-validation helpers.Miscellaneous niche (
histogram_numeric,version,sentences,quote): low-value or specialized functions with little benefit from native acceleration.
The file-metadata functions input_file_name, input_file_block_start, and input_file_block_length depend on scan-internal per-row file information rather than the expression layer; their support status is covered in the Parquet page.
Note that median and mode are supported: they are mainstream exact aggregates. mode runs natively only with spark.comet.expression.Mode.allowIncompatible=true. approx_count_distinct is supported because Comet ports Sparkβs HyperLogLogPlusPlus exactly, so its result is bit-identical to Spark.
The Apache DataSketches HLL functions (hll_sketch_agg, hll_union_agg, hll_sketch_estimate, hll_union) are the one sketch family Comet does accelerate, on Spark 4.0+. The sketches are mutually readable with Sparkβs, but the point estimate can differ slightly after a merge, so the native path is off by default and opt-in per expression via allowIncompatible β see the rows below.
The tables below list every Spark built-in expression with its current status.
agg_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
β |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
Byte, short, int, long, float, and double input; other input types fall back to Spark |
|
β |
Native |
Alias for |
|
β |
Native |
Interval types fall back. For |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
Grouping indicator for ROLLUP/CUBE/GROUPING SETS |
|
β |
β |
Grouping indicator for ROLLUP/CUBE/GROUPING SETS |
|
β |
Native |
Spark 4.0+ only; falls back by default, the native path is opt-in via allowIncompatible (details) |
|
β |
Native |
Spark 4.0+ only; falls back by default, the native path is opt-in via allowIncompatible (details) |
|
π |
β |
Not yet implemented natively |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Spark 4.0+. |
|
β |
Native |
|
|
β |
Native |
Value and ordering must be fixed-length types |
|
β |
Native |
Interval types fall back. For |
|
β |
β |
Rewrites to |
|
β |
Native |
|
|
β |
Native |
Value and ordering must be fixed-length types |
|
β |
β |
|
|
β |
Native |
Single literal percentage on numeric input runs natively; array of percentages and a frequency argument fall back to Spark |
|
β |
Native |
Alias of |
|
β |
β |
Spark 4.0+ |
|
π |
β |
Percentile aggregate |
|
β |
β |
Internal aggregate for the optimized |
|
β |
β |
Native: Spark rewrites to |
|
β |
β |
Native: Spark rewrites to |
|
β |
β |
Native: Spark rewrites to |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
β |
|
|
π |
β |
Not yet implemented natively |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Alias of |
|
β |
Native |
|
|
β |
β |
Interval types fall back. For |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
array_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Hybrid |
Flat float/double element arrays use a native kernel with Sparkβs equality; nested float elements, non-default string collations, and a value that is not a literal or column over a nullable array, route through the JVM codegen dispatcher |
|
β |
Native |
Floating-point elements fall back on Spark versions before 4.0.5, 4.1.4, and 4.2; signed-zero results may differ with native opt-in (details). Non-default string collations fall back |
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default; the incompatible native path is opt-in via allowIncompatible (details) |
|
β |
Native |
|
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default; the incompatible native path is opt-in via allowIncompatible (details) |
|
β |
Hybrid |
Native for literal or column delimiter and null replacement; other cases and non-UTF8_BINARY collations use the JVM codegen dispatcher (details) |
|
β |
Hybrid |
Native Spark-compatible floating-point and nested ordering; non-default string collations use the JVM codegen dispatcher (details) |
|
β |
Hybrid |
Native Spark-compatible floating-point and nested ordering; non-default string collations use the JVM codegen dispatcher (details) |
|
β |
Native |
Binary/struct/map/null elements fall back |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Floating-point elements fall back on Spark versions before 4.0.5, 4.1.4, and 4.2; signed-zero results may differ with native opt-in (details). Non-default string collations fall back |
|
β |
Hybrid |
Non-default string collations use the JVM codegen dispatcher |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Binary/struct/map elements fall back |
|
β |
β |
|
|
β |
Hybrid |
Integral types run natively; date/timestamp sequences use codegen dispatch |
|
β |
Native |
Binary/struct/map elements fall back |
|
β |
Native |
Native (#4149) |
|
β |
Hybrid |
Struct, nested-array, floating-point, and null elements run natively; other element types (for example intervals) route through the JVM codegen dispatcher |
bitwise_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Operator alias for |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
collection_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
β |
|
|
β |
Native |
|
|
β |
Hybrid |
Binary/array children and non-UTF8_BINARY collations route through the JVM codegen dispatcher |
|
β |
Hybrid |
Binary input (Spark 4.2), arrays with binary, struct, or map elements, and collated strings, route through the JVM codegen dispatcher (details) |
|
β |
Native |
conditional_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
β |
β |
|
|
β |
β |
Lowers to |
|
β |
β |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
β |
Lowers to |
conversion_funcs#
The type-name conversion functions (bigint, binary, boolean, date, decimal, double, float, int, smallint, string, timestamp, tinyint) are SQL aliases for CAST(... AS <type>) and share the support and caveats of cast.
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Hybrid |
Casts without a native path (for example boolean to decimal) route through the JVM codegen dispatcher (details) |
csv_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Codegen dispatch by default; the native path is opt-in via allowIncompatible |
datetime_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default (handles all timezone forms); the native path is opt-in via allowIncompatible (details) |
|
β |
β |
Constant-folded to a literal (alias of |
|
β |
β |
Constant-folded to a literal before Comet sees the plan |
|
β |
β |
Spark 4.1+; requires |
|
β |
β |
Constant-folded to a literal before Comet sees the plan |
|
β |
β |
|
|
β |
Native |
The 2-argument form is native; the |
|
β |
Native |
The 2-argument form is native; the |
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
Native |
The 2-argument form is native; the |
|
β |
Native |
The 2-argument form is native; the |
|
β |
β |
|
|
β |
Native |
|
|
β |
β |
Abbreviated day name (Spark 4.0+) |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default (handles all timezone forms); the native path is opt-in via allowIncompatible (details) |
|
β |
β |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
Computed arguments preserve year β month β day NULL checks. Expressions fall back when shared subexpressions or a parent could change which arguments Spark evaluates. IN probes stay native for literal/column candidates and array/struct constructors of those values; other computed candidates require Spark evaluation. Operator-level safeguards and their opt-out are described in make_date evaluation. |
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default; intervals outside Arrowβs nanosecond range are tracked by #5279; the native path is opt-in via allowIncompatible (details) |
|
β |
β |
Spark 4.1+; requires |
|
β |
β |
|
|
β |
β |
The 2-argument |
|
β |
β |
The 2-argument |
|
β |
Codegen dispatch |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
β |
Abbreviated month name (Spark 4.0+) |
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Non-UTF8_BINARY collated |
|
β |
β |
Constant-folded to a literal (alias of |
|
β |
Native |
|
|
β |
β |
|
|
π |
β |
Batch session-window grouping falls back ( |
|
β |
β |
Spark 4.1+; requires |
|
β |
β |
Spark 4.1+; requires |
|
β |
β |
Spark 4.0+ grammar alias that parses to |
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Integer, long, float and double inputs run natively; decimal, byte and short inputs route through the JVM codegen dispatcher |
|
β |
β |
Reached through the grammar rather than the function registry; runs through codegen dispatch |
|
β |
β |
Reached through the grammar rather than the function registry; runs through codegen dispatch |
|
β |
β |
Rewrites to |
|
β |
β |
Spark 4.1+; requires |
|
β |
β |
Rewrites to |
|
β |
β |
Rewrites to |
|
β |
β |
Rewrites to |
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default (handles all timezone forms); the native path is opt-in via allowIncompatible (details) |
|
β |
Hybrid |
|
|
β |
β |
Rewrites to |
|
β |
β |
|
|
β |
β |
Same support as |
|
β |
β |
Same support as |
|
β |
β |
Rewrites to |
|
β |
β |
Same support as |
|
β |
β |
Rewrites to |
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
String parsing uses Sparkβs codegen and honors the time parser policy, ANSI mode, and session time zone. Date and timestamp inputs ignore the format and use native execution. |
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
Batch tumbling and sliding time-window grouping runs natively |
|
β |
β |
Batch time-window grouping runs natively |
|
β |
Native |
generator_funcs#
explode, explode_outer, posexplode, and posexplode_outer are supported via
CometExplodeExec (operator-level, not expression-level) for array input; map input falls back
to Spark (#2837). Enabled by default via
spark.comet.exec.explode.enabled.
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
β |
via |
|
β |
β |
via |
|
π |
β |
Operator-level generator (like |
|
π |
β |
Operator-level generator (like |
|
β |
β |
via |
|
β |
β |
via |
|
π |
β |
Operator-level generator |
hash_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Native |
Includes decimals with precision 19β38 and nested decimals |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Includes decimals with precision 19β38 and nested decimals |
json_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default; the native path (supported schemas only) is opt-in via allowIncompatible (audit) |
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default; the native path is opt-in via allowIncompatible (audit) |
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default; the native path, which differs for single-quoted JSON, unescaped control characters, and trailing content, is opt-in via allowIncompatible (audit) |
|
β |
Codegen dispatch |
|
|
π |
β |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default, including options and map/array inputs; the native path is opt-in via allowIncompatible (audit) |
lambda_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Codegen dispatch |
|
|
β |
Native |
The default comparator runs natively; custom comparators and arrays with non-default string collations use the JVM codegen dispatcher |
|
β |
Codegen dispatch |
|
|
β |
Native |
General lambda routed through the JVM codegen dispatcher; the |
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
map_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Codegen dispatch |
Routed through the JVM codegen dispatcher |
|
β |
Codegen dispatch |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
BinaryType keys/values, |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
β |
Lowers to |
math_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Native |
YearMonth and DayTime interval multiplication routes through the JVM codegen dispatcher; Calendar interval multiplication falls back |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
DayTime interval division routes through the JVM codegen dispatcher; YearMonth and Calendar interval division fall back |
|
β |
Hybrid |
Interval types route through the JVM codegen dispatcher; numeric types run natively |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
|
|
β |
β |
Two-arg form falls back |
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
Folds to a literal (like |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
Two-arg form falls back |
|
β |
Hybrid |
Non-UTF8_BINARY collated input routes through the JVM codegen dispatcher; other input runs natively |
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Non-UTF8_BINARY collated input routes through the JVM codegen dispatcher; other input runs natively |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Alias for |
|
β |
Native |
Random string (Spark 4.0+); length and seed must be literals |
|
β |
Native |
|
|
β |
Hybrid |
Float/double inputs route through the JVM codegen dispatcher; other types run natively |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
Datetime/interval form falls back |
|
β |
β |
|
|
β |
β |
|
|
β |
β |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
β |
Constant-folded; literal arguments only (Spark 4.0+) |
|
β |
Codegen dispatch |
misc_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
β |
Routed through the JVM codegen dispatcher |
|
β |
β |
Routed through the JVM codegen dispatcher; nondeterministic IV by default |
|
π |
β |
Lowers to |
|
β |
β |
Resolved to a literal by the analyzer ( |
|
β |
β |
Resolved to a literal by the analyzer ( |
|
β |
β |
Alias of |
|
β |
β |
Resolved to a literal by the analyzer; same as |
|
β |
β |
Lowers to |
|
β |
Native |
Spark 4.0+ only; falls back by default, the native path is opt-in via allowIncompatible (details) |
|
β |
Native |
Spark 4.0+ only; falls back by default, the native path is opt-in via allowIncompatible (details) |
|
π |
β |
Requires |
|
β |
Native |
|
|
π |
β |
Requires |
|
π |
β |
Raises a runtime error |
|
β |
Native |
Seed must be a literal |
|
β |
Native |
Seed must be a literal |
|
π |
β |
Requires |
|
π |
β |
Requires |
|
β |
β |
Alias of |
|
β |
Native |
|
|
π |
β |
Requires |
|
β |
β |
Routed through the JVM codegen dispatcher |
|
π |
β |
Requires |
|
π |
β |
Requires |
|
β |
β |
Foldable; resolved to a literal before Comet sees the plan |
|
β |
β |
Resolved to a literal by the Spark analyzer before reaching Comet |
|
β |
Native |
|
|
π |
β |
Requires |
predicate_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
β |
|
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
In-subset literal patterns run natively; other patterns route through the JVM codegen dispatcher (details) |
|
β |
Hybrid |
In-subset literal patterns run natively; other patterns route through the JVM codegen dispatcher (details) |
|
β |
Hybrid |
In-subset literal patterns run natively; other patterns route through the JVM codegen dispatcher (details) |
string_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
π |
β |
Spark collation (umbrella #2190) |
|
β |
β |
Constant-folded to a literal (Spark 4.0+) |
|
β |
Hybrid |
Mixed string and array arguments run natively; all-foldable arguments use codegen dispatch |
|
β |
β |
|
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
β |
β |
|
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
Non-UTF8_BINARY collated input routes through the JVM codegen dispatcher; other input runs natively |
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
Non-UTF8_BINARY collated input routes through the JVM codegen dispatcher; other input runs natively |
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
|
|
β |
Hybrid |
String inputs use the native kernel with a column string and literal padding; literal strings and column padding use codegen dispatch. Binary inputs use codegen dispatch. |
|
β |
Hybrid |
Non-UTF8_BINARY collated input with a trim string routes through the JVM codegen dispatcher; other input runs natively |
|
β |
β |
Native via |
|
β |
β |
Routed through the JVM codegen dispatcher |
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
β |
Rewrites to |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Codegen dispatch |
Routed through the JVM codegen dispatcher |
|
β |
Hybrid |
|
|
β |
β |
Rewrites to |
|
β |
Native |
|
|
β |
Hybrid |
Native by default for a direct string column with a non-empty, valid UTF-8 search literal and either a replacement literal (both at most 64 KiB) or a replacement column (search at most 256 bytes and at most 8 MiB when broadcast per batch), under UTF8_BINARY collation; other cases use the JVM codegen dispatcher by default |
|
β |
Native |
|
|
β |
Hybrid |
String inputs use the native kernel with a column string and literal padding; literal strings and column padding use codegen dispatch. Binary inputs use codegen dispatch. |
|
β |
Hybrid |
Non-UTF8_BINARY collated input with a trim string routes through the JVM codegen dispatcher; other input runs natively |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
β |
Spark 4.0+ |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
Non-UTF8_BINARY collated input routes through the JVM codegen dispatcher; other input runs natively |
|
β |
β |
The hex form runs natively; the base64 and |
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
β |
β |
|
|
β |
Hybrid |
Codegen dispatch by default: DataFusionβs |
|
β |
Hybrid |
Non-UTF8_BINARY collated input with a trim string routes through the JVM codegen dispatcher; other input runs natively |
|
β |
β |
Rewrites to |
|
β |
Codegen dispatch |
Routed through the JVM codegen dispatcher |
|
β |
Hybrid |
|
|
β |
Hybrid |
Column or literal input runs natively; other child expressions, and the strict form used by |
|
β |
Hybrid |
struct_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
Duplicate field names fall back |
|
β |
Native |
url_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
β |
Spark 4.0+; runs natively and returns NULL for an invalid URL |
|
β |
β |
|
|
β |
β |
|
|
β |
β |
window_funcs#
Window functions run via CometWindowExec, which is enabled by default.
Aggregate window functions (count, min, max, sum, avg,
first_value, last_value), ranking functions (row_number, rank,
dense_rank, percent_rank, cume_dist, ntile), and value-shift
functions (lag, lead, nth_value) are all wired in the window serde
and execute natively. Statistical aggregates such as stddev, var_pop,
corr, and covar_pop run natively as plain aggregations but fall back
to Spark when used as window functions. A handful of frame shapes also
fall back. See window function compatibility
for the full list of supported functions, frames, and fallback cases.
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
β |
via |
|
β |
β |
via |
|
β |
β |
via |
|
β |
β |
via |
|
β |
β |
via |
|
β |
β |
via |
|
β |
β |
via |
|
β |
β |
via |
|
β |
β |
via |
xml_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
β |
Spark 4.0+ |
|
β |
β |
Spark 4.0+ |
|
β |
β |
Spark 4.0+ |
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
Alias of |
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
Beyond SQL functions#
Comet also accelerates a number of Catalyst expressions that have no Spark SQL function name and therefore do not appear in the tables above. These arise from the DataFrame API, from SQL syntax other than function calls, or from the query optimizer. They include:
Operator and optimizer-injected expressions: runtime bloom-filter join probes (
BloomFilterMightContain,BloomFilterAggregate), optimizedINsets (InSet), scalar subqueries (ScalarSubquery), and floating-point normalization (KnownFloatingPointNormalized).Accessor expressions (subscript and field access, not functions): struct field access (
col.field), array element access (arr[i]), and map value access (map[key]).Internal decimal arithmetic:
CheckOverflow,MakeDecimal, andUnscaledValue, which the analyzer inserts around decimal operations.Missing-data predicates:
AtLeastNNonNulls, used byDataFrame.na.drop, counts non-null and non-NaN values natively.User-defined functions: Scala UDFs registered through the DataFrame or SQL API.
DataSource V2 catalog functions: Icebergβs system functions
bucket,truncate,years,months,days, andhours(for examplesystem.bucket(16, id)) run natively; see Iceberg system functions. Other DataSource V2 catalog functions run in Spark.Lowered built-ins: Spark lowers some built-in functions to
StaticInvokeorInvokecalls. Those without a native mapping run through the JVM codegen dispatcher when their input and output types are supported.Structural expressions: aliases, attribute references, literals, sort orders, and
CASE WHEN.
This list is illustrative, not exhaustive: the per-function tables are not the complete set of expressions Comet can accelerate.
make_date evaluation#
With ANSI mode enabled, make_date(2024, 13, 1) raises an invalid-date error. If an
input iterator yields a valid row followed by that invalid row, a LIMIT 1 can stop
before evaluating the second date. A native projection can evaluate a whole batch
before the consuming operator decides which rows it needs.
By default, Comet keeps affected operators in Spark to preserve skipped date evaluation.
This applies to date projections below LIMIT, SAMPLE, FILTER, joins,
mapPartitions, and Dataset.rdd consumers; date expressions inside joins, aggregates,
and ordered limits; and projections below a window group limit. A parent projection can
also defer a date output when an IF, COALESCE, or NULL-skipping operand does not need
it. Comet preserves that evaluation across projections while allowing eager date consumers,
such as YEAR(dt), to remain native when their operands are safe to evaluate. An enclosing
conditional can still defer the extractorβs date input. These safeguards also preserve
NULL short-circuiting when a date argument is computed in an earlier projection, including
across the streamed side of a broadcast join. The materialized build side remains independent.
These safeguards also cover required arguments, such as a computed year, on input rows that
the join rejects before producing an output row.
Selecting the date eagerly does not force conditionally used sibling expressions; those
computations also retain Spark evaluation when needed.
With ANSI disabled, a direct date projection can remain native below these consumers when
all its computations are safe to evaluate early. This includes make_date(2024, month, day)
over input columns and years widened from TINYINT or SMALLINT. An unrestricted integer
year still needs the safeguard: Sparkβs conversion to Date32 can overflow independently of
ANSI mode. Computed arguments, their deferred producers, and throwing sibling expressions
retain their safeguards. Expression-level parent guards remain in effect.
For example, if dt is a nullable date alias, unix_date(dt) + element_at(values, i)
keeps its consuming operator in Spark when a NULL date can skip an invalid array index.
The safe date-producing projection can remain native.
An unfiltered COUNT(make_date(...)) can remain native when its sole argument is nullable,
because Spark checks that argument on every input row. Filtered counts and counts with
multiple arguments retain the safeguard when they can skip date evaluation.
Only affected parts of the plan fall back. An ordinary native scan can remain native. An adjacent collect limit and date projection can also stay native: Comet caps the projectionβs input before evaluating dates, so unread rows cannot raise errors. This requires a supported native local limit; otherwise the Spark safeguard remains. The cap does not bypass safeguards for a lower argument-producing projection or intervening filters and joins. Exchanges materialize their inputs and partition keys independently, so an outer limit does not force an eager date partition key to Spark. Local sorts and aggregates can also separate date evaluation from an outer limit.
Users who accept eagerly evaluating dates, projected arguments, and sibling expressions can set
spark.comet.exec.makeDate.operatorFallback.enabled=false to allow native operators for
these shapes. The default is true. Disabling it can expose invalid-date or argument errors
that Spark would skip under ANSI mode. This setting does not change
make_dateβs invalid-date handling or the expression-level safeguards for skipped
arguments and operands. For example, an empty IN predicate containing make_date
still falls back when needed.
See also#
Comet Compatibility Guide - known incompatibilities and edge cases for supported expressions.
Expression Audits (contributor guide) - per-version (Spark 3.4 / 3.5 / 4.0 / 4.1) audit notes for audited expressions.