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.

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 approx_count_distinct, median, and mode are planned: they are mainstream (median and mode are exact aggregates). approx_percentile / percentile_approx are not currently planned because their approximate results cannot be made bit-identical to Spark.

The tables below list every Spark built-in expression with its current status.

agg_funcs#

Function

Status

Notes

any

โœ…

any_value

โœ…

approx_count_distinct

๐Ÿ”œ

tracking #4098

array_agg

๐Ÿ”œ

Array aggregate (related to collect_list, #2524)

avg

โœ…

Interval types fall back

bit_and

โœ…

bit_or

โœ…

bit_xor

โœ…

bool_and

โœ…

bool_or

โœ…

collect_list

๐Ÿ”œ

#2524

collect_set

โœ…

corr

โœ…

count

โœ…

count_if

โœ…

covar_pop

โœ…

covar_samp

โœ…

every

โœ…

first

โœ…

first_value

โœ…

grouping

๐Ÿ”œ

Grouping indicator for ROLLUP/CUBE/GROUPING SETS

grouping_id

๐Ÿ”œ

Grouping indicator for ROLLUP/CUBE/GROUPING SETS

kurtosis

๐Ÿ”œ

tracking #4098

last

โœ…

last_value

โœ…

listagg

๐Ÿ”œ

String aggregation

max

โœ…

max_by

๐Ÿ”œ

#3841

mean

โœ…

median

๐Ÿ”œ

tracking #4098

min

โœ…

min_by

๐Ÿ”œ

#3841

mode

๐Ÿ”œ

#3970

percentile

๐Ÿ”œ

#4542

percentile_cont

๐Ÿ”œ

Percentile aggregate

percentile_disc

๐Ÿ”œ

Percentile aggregate

regr_avgx

โœ…

Native: Spark rewrites to Average (tests in #4551)

regr_avgy

โœ…

Native: Spark rewrites to Average (tests in #4551)

regr_count

โœ…

Native: Spark rewrites to Count (tests in #4551)

regr_intercept

๐Ÿ”œ

Falls back; can reuse covar_pop/var_pop accumulators (#4552)

regr_r2

๐Ÿ”œ

Falls back; can reuse the corr accumulator (#4552)

regr_slope

๐Ÿ”œ

Falls back; can reuse covar_pop/var_pop accumulators (#4552)

regr_sxx

๐Ÿ”œ

Falls back; can reuse var_pop accumulator (#4552)

regr_sxy

๐Ÿ”œ

Falls back; can reuse covar_pop accumulator (#4552)

regr_syy

๐Ÿ”œ

Falls back; can reuse var_pop accumulator (#4552)

skewness

๐Ÿ”œ

tracking #4098

some

โœ…

std

โœ…

stddev

โœ…

stddev_pop

โœ…

stddev_samp

โœ…

string_agg

๐Ÿ”œ

String aggregation (alias of listagg)

sum

โœ…

try_avg

๐Ÿ”œ

tracking #4098

try_sum

๐Ÿ”œ

tracking #4098

var_pop

โœ…

var_samp

โœ…

variance

โœ…


array_funcs#

Function

Status

Notes

array

โœ…

array_append

โœ…

array_compact

โœ…

array_contains

โœ…

NaN/signed-zero handling may differ (details)

array_distinct

โœ…

NaN/signed-zero handling may differ (details)

array_except

โœ…

Routes through the JVM codegen dispatcher by default; the incompatible native path is opt-in via allowIncompatible (details)

array_insert

โœ…

array_intersect

โœ…

Routes through the JVM codegen dispatcher by default; the incompatible native path is opt-in via allowIncompatible (details)

array_join

โœ…

Routes through the JVM codegen dispatcher by default; the incompatible native path is opt-in via allowIncompatible (details)

array_max

โœ…

NaN ordering may differ (details)

array_min

โœ…

NaN ordering may differ (details)

array_position

โœ…

Binary/struct/map/null elements fall back

array_prepend

๐Ÿ”œ

Sibling of array_append

array_remove

โœ…

array_repeat

โœ…

array_union

โœ…

NaN/signed-zero handling may differ (details)

arrays_overlap

โœ…

arrays_zip

โœ…

element_at

โœ…

MapType input falls back

flatten

โœ…

Binary/struct/map elements fall back

get

โœ…

sequence

โœ…

shuffle

๐Ÿ”œ

Random array shuffle

slice

โœ…

Native (#4149)

sort_array

โœ…

Nested struct/null arrays fall back


bitwise_funcs#

Function

Status

Notes

&

โœ…

<<

โœ…

>>

โœ…

>>>

โœ…

Operator alias for shiftrightunsigned (Spark 4.0+)

^

โœ…

bit_count

โœ…

bit_get

โœ…

getbit

โœ…

shiftright

โœ…

shiftrightunsigned

โœ…

|

โœ…

~

โœ…


collection_funcs#

Function

Status

Notes

array_size

โœ…

cardinality

โœ…

MapType input falls back

concat

โœ…

Binary/array children fall back

reverse

โœ…

Binary-element arrays fall back (Incompatible) (details)

size

โœ…

MapType input falls back


conditional_funcs#

Function

Status

Notes

coalesce

โœ…

if

โœ…

ifnull

โœ…

nanvl

โœ…

nullif

โœ…

nullifzero

โœ…

Lowers to if/= (Spark 4.0+)

nvl

โœ…

nvl2

โœ…

when

โœ…

zeroifnull

โœ…

Lowers to coalesce (Spark 4.0+)


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

Notes

cast

โœ…

Some casts fall back; float-to-decimal is opt-in (details)


csv_funcs#

Function

Status

Notes

from_csv

โœ…

schema_of_csv

โœ…

to_csv

โœ…


datetime_funcs#

Function

Status

Notes

add_months

โœ…

convert_timezone

โœ…

Routes through the JVM codegen dispatcher by default (handles all timezone forms); the native path is opt-in via allowIncompatible (details)

curdate

โœ…

Constant-folded to a literal (alias of current_date)

current_date

โœ…

Constant-folded to a literal before Comet sees the plan

current_time

๐Ÿ”œ

Blocked on Spark 4.1 TIME type support (#4288)

current_timestamp

โœ…

Constant-folded to a literal before Comet sees the plan

current_timezone

โœ…

date_add

โœ…

date_diff

โœ…

date_format

โœ…

date_from_unix_date

โœ…

date_part

โœ…

date_sub

โœ…

date_trunc

โœ…

dateadd

โœ…

datediff

โœ…

datepart

โœ…

day

โœ…

dayname

โœ…

Abbreviated day name (Spark 4.0+)

dayofmonth

โœ…

dayofweek

โœ…

dayofyear

โœ…

extract

โœ…

from_unixtime

โœ…

from_utc_timestamp

โœ…

Routes through the JVM codegen dispatcher by default (handles all timezone forms); the native path is opt-in via allowIncompatible (details)

hour

โœ…

last_day

โœ…

localtimestamp

โœ…

make_date

โœ…

make_dt_interval

๐Ÿ”œ

#4541

make_interval

๐Ÿ”œ

Produces legacy CalendarInterval; tracked by #4540

make_time

๐Ÿ”œ

Spark 4.1 TIME type; tracked by #4288

make_timestamp

โœ…

make_timestamp_ltz

โœ…

2-arg TIME form falls back

make_timestamp_ntz

โœ…

2-arg TIME form falls back

make_ym_interval

๐Ÿ”œ

#4541

minute

โœ…

month

โœ…

monthname

โœ…

Abbreviated month name (Spark 4.0+)

months_between

โœ…

next_day

โœ…

now

โœ…

Constant-folded to a literal (alias of current_timestamp)

quarter

โœ…

second

โœ…

session_window

๐Ÿ”œ

Time-window grouping; tracked by #4553

time_diff

๐Ÿ”œ

Spark 4.1 TIME type; tracked by #4288

time_trunc

๐Ÿ”œ

Spark 4.1 TIME type; tracked by #4288

timestamp_micros

โœ…

timestamp_millis

โœ…

timestamp_seconds

โœ…

to_date

โœ…

Rewrites to Cast (or Cast(GetTimestamp) with a format) before Comet sees the plan

to_time

๐Ÿ”œ

Spark 4.1 TIME type; tracked by #4288

to_timestamp

โœ…

Rewrites to Cast (or GetTimestamp with a format) before Comet sees the plan

to_timestamp_ltz

โœ…

Rewrites to to_timestamp (TimestampType)

to_timestamp_ntz

โœ…

Rewrites to to_timestamp (TimestampNTZType)

to_unix_timestamp

โœ…

to_utc_timestamp

โœ…

Routes through the JVM codegen dispatcher by default (handles all timezone forms); the native path is opt-in via allowIncompatible (details)

trunc

โœ…

try_make_interval

๐Ÿ”œ

Produces legacy CalendarInterval; tracked by #4540

try_make_timestamp

โœ…

try_to_date

๐Ÿ”œ

Rewrites to Cast/GetTimestamp but currently falls back; tracked by #4556

try_to_time

๐Ÿ”œ

Spark 4.1 TIME type; tracked by #4288

try_to_timestamp

๐Ÿ”œ

Rewrites to Cast/GetTimestamp but currently falls back; tracked by #4556

unix_date

โœ…

unix_micros

โœ…

unix_millis

โœ…

unix_seconds

โœ…

unix_timestamp

โœ…

weekday

โœ…

weekofyear

โœ…

window

๐Ÿ”œ

Time-window grouping; tracked by #4553

window_time

๐Ÿ”œ

Time-window grouping; tracked by #4553

year

โœ…


generator_funcs#

explode and posexplode are supported via CometExplodeExec (operator-level, not expression-level). The outer variants are wired but marked Incompatible; they require spark.comet.exec.explode.enabled=true and allowIncompatible.

Function

Status

Notes

explode

โœ…

via CometExplodeExec

explode_outer

โœ…

outer=true falls back (Incompatible) (audit)

inline

๐Ÿ”œ

Operator-level generator (like explode)

inline_outer

๐Ÿ”œ

Operator-level generator (like explode)

posexplode

โœ…

via CometExplodeExec

posexplode_outer

โœ…

outer=true falls back (Incompatible) (audit)

stack

๐Ÿ”œ

Operator-level generator


hash_funcs#

Function

Status

Notes

crc32

โœ…

hash

โœ…

md5

โœ…

sha

โœ…

sha1

โœ…

sha2

โœ…

xxhash64

โœ…


json_funcs#

Function

Status

Notes

from_json

โœ…

Falls back by default; opt-in via allowIncompatible (audit)

get_json_object

โœ…

Some inputs need allowIncompatible (audit)

json_array_length

โœ…

Single-quoted/trailing JSON needs allowIncompatible (audit)

json_object_keys

โœ…

json_tuple

๐Ÿ”œ

#3160

schema_of_json

โœ…

to_json

โœ…

Options and map/array inputs fall back (audit)


lambda_funcs#

Function

Status

Notes

aggregate

โœ…

array_sort

โœ…

exists

โœ…

filter

โœ…

General lambda routed through the JVM codegen dispatcher; the array_compact form runs natively

forall

โœ…

map_filter

โœ…

map_zip_with

โœ…

reduce

โœ…

transform

โœ…

transform_keys

โœ…

transform_values

โœ…

zip_with

โœ…


map_funcs#

Function

Status

Notes

element_at

โœ…

MapType input falls back

map

โœ…

Routed through the JVM codegen dispatcher

map_concat

โœ…

map_contains_key

โœ…

map_entries

โœ…

map_from_arrays

โœ…

map_from_entries

โœ…

BinaryType key/value falls back (Incompatible) (details)

map_keys

โœ…

map_values

โœ…

str_to_map

โœ…

try_element_at

โœ…

Lowers to element_at; array input (MapType falls back)


math_funcs#

Function

Status

Notes

%

โœ…

*

โœ…

Interval multiplication falls back

+

โœ…

-

โœ…

/

โœ…

abs

โœ…

Interval types fall back

acos

โœ…

acosh

โœ…

asin

โœ…

asinh

โœ…

atan

โœ…

atan2

โœ…

atanh

โœ…

bin

โœ…

bround

โœ…

cbrt

โœ…

ceil

โœ…

Two-arg form falls back

ceiling

โœ…

conv

โœ…

cos

โœ…

cosh

โœ…

cot

โœ…

csc

โœ…

degrees

โœ…

div

โœ…

e

โœ…

Folds to a literal (like pi)

exp

โœ…

expm1

โœ…

factorial

โœ…

floor

โœ…

Two-arg form falls back

greatest

โœ…

hex

โœ…

hypot

โœ…

least

โœ…

ln

โœ…

log

โœ…

log10

โœ…

log1p

โœ…

log2

โœ…

mod

โœ…

negative

โœ…

pi

โœ…

pmod

โœ…

positive

โœ…

pow

โœ…

power

โœ…

radians

โœ…

rand

โœ…

randn

โœ…

random

โœ…

Alias for rand (Spark 4.0+); seed must be a literal

randstr

๐Ÿ”œ

Random string (Spark 4.0+)

rint

โœ…

round

โœ…

Float/double inputs fall back

sec

โœ…

shiftleft

โœ…

sign

โœ…

signum

โœ…

sin

โœ…

sinh

โœ…

sqrt

โœ…

tan

โœ…

tanh

โœ…

try_add

โœ…

Datetime/interval form falls back

try_divide

โœ…

try_mod

โœ…

try_multiply

โœ…

try_subtract

โœ…

unhex

โœ…

uniform

โœ…

Constant-folded; literal arguments only (Spark 4.0+)

width_bucket

โœ…


misc_funcs#

Function

Status

Notes

aes_decrypt

โœ…

Routed through the JVM codegen dispatcher

aes_encrypt

โœ…

Routed through the JVM codegen dispatcher; nondeterministic IV by default

assert_true

๐Ÿ”œ

Lowers to RaiseError, which falls back

current_catalog

โœ…

Resolved to a literal by the analyzer (ReplaceCurrentLike)

current_database

โœ…

Resolved to a literal by the analyzer (ReplaceCurrentLike)

current_schema

โœ…

Alias of current_database; resolved to a literal by the analyzer

current_user

โœ…

Resolved to a literal by the analyzer; same as user

equal_null

โœ…

Lowers to <=> (EqualNullSafe)

is_variant_null

๐Ÿ”œ

tracking #4098

monotonically_increasing_id

โœ…

parse_json

๐Ÿ”œ

tracking #4098

raise_error

๐Ÿ”œ

Raises a runtime error

rand

โœ…

Seed must be a literal

randn

โœ…

Seed must be a literal

schema_of_variant

๐Ÿ”œ

tracking #4098

schema_of_variant_agg

๐Ÿ”œ

tracking #4098

session_user

โœ…

Alias of current_user; resolved to a literal by the analyzer

spark_partition_id

โœ…

to_variant_object

๐Ÿ”œ

tracking #4098

try_aes_decrypt

โœ…

Routed through the JVM codegen dispatcher

try_parse_json

๐Ÿ”œ

tracking #4098

try_variant_get

๐Ÿ”œ

tracking #4098

typeof

โœ…

Foldable; resolved to a literal before Comet sees the plan

user

โœ…

Resolved to a literal by the Spark analyzer before reaching Comet

uuid

๐Ÿ”œ

Nondeterministic random UUID

variant_get

๐Ÿ”œ

tracking #4098


predicate_funcs#

Function

Status

Notes

!

โœ…

<

โœ…

<=

โœ…

<=>

โœ…

=

โœ…

==

โœ…

>

โœ…

>=

โœ…

and

โœ…

between

โœ…

ilike

โœ…

in

โœ…

isnan

โœ…

isnotnull

โœ…

isnull

โœ…

like

โœ…

not

โœ…

or

โœ…

regexp

โœ…

Falls back by default; opt-in via allowIncompatible (details)

regexp_like

โœ…

Falls back by default; opt-in via allowIncompatible (details)

rlike

โœ…

Falls back by default; opt-in via allowIncompatible (details)


string_funcs#

Function

Status

Notes

ascii

โœ…

base64

๐Ÿ”œ

Lowers to StaticInvoke(encode) (not allowlisted); falls back

bit_length

โœ…

btrim

โœ…

char

โœ…

char_length

โœ…

character_length

โœ…

chr

โœ…

collate

๐Ÿ”œ

Spark collation (umbrella #2190)

collation

โœ…

Constant-folded to a literal (Spark 4.0+)

concat_ws

โœ…

contains

โœ…

decode

โœ…

elt

โœ…

encode

๐Ÿ”œ

Lowers to StaticInvoke(encode) (not allowlisted); falls back

endswith

โœ…

find_in_set

โœ…

format_number

โœ…

format_string

โœ…

initcap

โœ…

instr

โœ…

lcase

โœ…

left

โœ…

len

โœ…

length

โœ…

levenshtein

โœ…

locate

โœ…

lower

โœ…

lpad

โœ…

ltrim

โœ…

luhn_check

โœ…

Native via StaticInvoke (tests: luhn_check.sql)

mask

โœ…

Routed through the JVM codegen dispatcher

octet_length

โœ…

overlay

โœ…

position

โœ…

printf

โœ…

regexp_count

โœ…

Runs natively (rewrites to size(regexp_extract_all(...)))

regexp_extract

โœ…

regexp_extract_all

โœ…

regexp_instr

โœ…

Routed through the JVM codegen dispatcher

regexp_replace

โœ…

regexp_substr

โœ…

Runs natively (rewrites to nullif(regexp_extract(...), ''))

repeat

โœ…

replace

โœ…

right

โœ…

rpad

โœ…

rtrim

โœ…

soundex

โœ…

space

โœ…

split

โœ…

split_part

๐Ÿ”œ

Lowers to element_at(StringSplitSQL(...)); StringSplitSQL falls back (#4561)

startswith

โœ…

substr

โœ…

substring

โœ…

substring_index

โœ…

to_binary

โœ…

Hex form accelerated; other formats fall back

to_char

โœ…

to_number

โœ…

to_varchar

โœ…

translate

โœ…

Falls back by default; opt-in via allowIncompatible (#4463)

trim

โœ…

try_to_binary

โœ…

Runs natively (rewrites to try_eval(to_binary(...)))

try_to_number

โœ…

Routed through the JVM codegen dispatcher

ucase

โœ…

unbase64

โœ…

upper

โœ…


struct_funcs#

Function

Status

Notes

named_struct

โœ…

Duplicate field names fall back

struct

โœ…


url_funcs#

Function

Status

Notes

parse_url

โœ…

try_url_decode

โœ…

url_decode

โœ…

url_encode

โœ…


window_funcs#

Window functions run via CometWindowExec. Window support is disabled by default due to known correctness issues (tracking #2721). When enabled, lag and lead are explicitly wired; aggregate window functions (count, min, max, sum) are also supported. Ranking functions (rank, dense_rank, row_number, ntile, percent_rank, cume_dist, nth_value) are not yet wired in the window serde and fall back to Spark.

Function

Status

Notes

cume_dist

๐Ÿ”œ

Window function; tracked by #2721

dense_rank

๐Ÿ”œ

Window function; tracked by #2721

lag

โœ…

via CometWindowExec

lead

โœ…

via CometWindowExec

nth_value

๐Ÿ”œ

Window function; tracked by #2721

ntile

๐Ÿ”œ

Window function; tracked by #2721

percent_rank

๐Ÿ”œ

Window function; tracked by #2721

rank

๐Ÿ”œ

Window function; tracked by #2721

row_number

๐Ÿ”œ

Window function; tracked by #2721


xml_funcs#

Function

Status

Notes

from_xml

โœ…

Spark 4.0+

schema_of_xml

โœ…

Spark 4.0+

to_xml

โœ…

Spark 4.0+

xpath

โœ…

xpath_boolean

โœ…

xpath_double

โœ…

xpath_float

โœ…

xpath_int

โœ…

xpath_long

โœ…

xpath_number

โœ…

Alias of xpath_double

xpath_short

โœ…

xpath_string

โœ…


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), optimized IN sets (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, and UnscaledValue, 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#