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 cast) or, when the expression has a Spark-compatible
codegen-dispatch implementation, runs through that instead (for example 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 1.0 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_*,hll_*,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): 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 scan compatibility guide.
Note that median and mode are planned: they are mainstream exact aggregates. approx_count_distinct is supported because Comet ports Sparkβs HyperLogLogPlusPlus exactly, so its result is bit-identical to Spark.
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 |
|
β |
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 |
|
π |
β |
Not yet implemented natively |
|
β |
Native |
|
|
β |
Native |
|
|
π |
β |
String aggregation |
|
β |
Native |
|
|
π |
β |
|
|
β |
Native |
|
|
β |
β |
Rewrites to |
|
β |
Native |
|
|
π |
β |
|
|
π |
β |
|
|
β |
Native |
Single literal percentage on numeric input runs natively; array of percentages and a frequency argument fall back to Spark |
|
β |
β |
Spark 4.0+ |
|
π |
β |
Percentile aggregate |
|
β |
β |
Native: Spark rewrites to |
|
β |
β |
Native: Spark rewrites to |
|
β |
β |
Native: Spark rewrites to |
|
π |
β |
Falls back; can reuse |
|
π |
β |
Falls back; can reuse the |
|
π |
β |
Falls back; can reuse |
|
π |
β |
Falls back; can reuse |
|
π |
β |
Falls back; can reuse |
|
π |
β |
Falls back; can reuse |
|
π |
β |
Not yet implemented natively |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
π |
β |
String aggregation (alias of |
|
β |
Native |
|
|
β |
β |
Interval types fall back |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
array_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
NaN/signed-zero handling may differ (details) |
|
β |
Native |
NaN/signed-zero handling may differ (details) |
|
β |
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 |
Routes through the JVM codegen dispatcher by default; the incompatible native path is opt-in via allowIncompatible (details) |
|
β |
Native |
NaN ordering may differ (details) |
|
β |
Native |
NaN ordering may differ (details) |
|
β |
Native |
Binary/struct/map/null elements fall back |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
NaN/signed-zero handling may differ (details) |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Binary/struct/map elements fall back |
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
Binary/struct/map elements fall back |
|
β |
Native |
Native (#4149) |
|
β |
Hybrid |
Nested struct/null arrays fall back |
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 fall back |
|
β |
Hybrid |
Binary-element arrays fall back (Incompatible) (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 |
Some casts fall back; float-to-decimal is opt-in (details) |
csv_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
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 |
|
π |
β |
Blocked on Spark 4.1 TIME type support (#4288) |
|
β |
β |
Constant-folded to a literal before Comet sees the plan |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
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 |
|
|
β |
Codegen dispatch |
|
|
π |
β |
Produces legacy CalendarInterval; tracked by #5061 |
|
π |
β |
Spark 4.1 TIME type; tracked by #4288 |
|
β |
β |
|
|
β |
β |
2-arg TIME form falls back |
|
β |
β |
2-arg TIME form falls back |
|
β |
Codegen dispatch |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
β |
Abbreviated month name (Spark 4.0+) |
|
β |
Codegen dispatch |
|
|
β |
Native |
|
|
β |
β |
Constant-folded to a literal (alias of |
|
β |
Native |
|
|
β |
β |
|
|
π |
β |
Batch session-window grouping falls back ( |
|
π |
β |
Spark 4.1 TIME type; tracked by #4288 |
|
π |
β |
Spark 4.1 TIME type; tracked by #4288 |
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
|
|
β |
β |
Rewrites to |
|
π |
β |
Spark 4.1 TIME type; tracked by #4288 |
|
β |
β |
Rewrites to |
|
β |
β |
Rewrites to |
|
β |
β |
Rewrites to |
|
β |
Hybrid |
|
|
β |
Hybrid |
Routes through the JVM codegen dispatcher by default (handles all timezone forms); the native path is opt-in via allowIncompatible (details) |
|
β |
Hybrid |
|
|
π |
β |
Produces legacy CalendarInterval; tracked by #5061 |
|
β |
β |
|
|
β |
β |
Rewrites to |
|
π |
β |
Spark 4.1 TIME type; tracked by #4288 |
|
β |
β |
Rewrites to |
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
|
|
β |
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). 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 |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
json_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Hybrid |
Falls back by default; opt-in via allowIncompatible (audit) |
|
β |
Hybrid |
Some inputs need allowIncompatible (audit) |
|
β |
Hybrid |
Single-quoted/trailing JSON needs allowIncompatible (audit) |
|
β |
Codegen dispatch |
|
|
π |
β |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
Options and map/array inputs fall back (audit) |
lambda_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
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 |
|
|
β |
Native |
|
|
β |
Hybrid |
BinaryType key/value falls back (Incompatible) (details) |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
β |
Lowers to |
math_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
Native |
Interval multiplication falls back |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
Interval types fall back |
|
β |
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 |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Native |
|
|
β |
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 |
|
|
β |
Native |
Float/double inputs fall back |
|
β |
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 |
|
π |
β |
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 |
Falls back by default; opt-in via allowIncompatible (details) |
|
β |
Hybrid |
Falls back by default; opt-in via allowIncompatible (details) |
|
β |
Hybrid |
Falls back by default; opt-in via allowIncompatible (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+) |
|
β |
Native |
|
|
β |
β |
|
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
π |
β |
Lowers to |
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
β |
Native via |
|
β |
β |
Routed through the JVM codegen dispatcher |
|
β |
Native |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
Codegen dispatch |
|
|
β |
β |
Runs natively (rewrites to |
|
β |
Native |
|
|
β |
Native |
|
|
β |
Codegen dispatch |
Routed through the JVM codegen dispatcher |
|
β |
Hybrid |
|
|
β |
β |
Runs natively (rewrites to |
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
Native |
|
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Hybrid |
|
|
β |
β |
Spark 4.0+ |
|
β |
β |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
Native |
|
|
β |
β |
Hex form accelerated; other formats fall back |
|
β |
β |
|
|
β |
Codegen dispatch |
|
|
β |
β |
|
|
β |
Native |
DataFusionβs |
|
β |
Native |
|
|
β |
β |
Runs natively (rewrites to |
|
β |
Codegen dispatch |
Routed through the JVM codegen dispatcher |
|
β |
Hybrid |
|
|
β |
Codegen dispatch |
|
|
β |
Hybrid |
struct_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
Duplicate field names fall back |
|
β |
Native |
url_funcs#
Function |
Status |
Implementation |
Notes |
|---|---|---|---|
|
β |
Native |
|
|
β |
β |
|
|
β |
β |
|
|
β |
β |
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.User-defined functions: Scala UDFs registered through the DataFrame or SQL API.
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.
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.