Supported Spark Expressions

The following Spark expressions are currently available. Any known compatibility issues are noted in the following tables.

Literal Values

ExpressionNotes
Literal values of supported data types

Unary Arithmetic

ExpressionNotes
UnaryMinus (-)

Binary Arithmetic

ExpressionNotes
Add (+)
Subtract (-)
Multiply (*)
Divide (/)
IntegralDivide (div)
Remainder (%)

Conditional Expressions

ExpressionNotes
CaseWhen
If

Comparison

ExpressionNotes
EqualTo (=)
EqualNullSafe (<=>)
GreaterThan (>)
GreaterThanOrEqual (>=)
LessThan (<)
LessThanOrEqual (<=)
IsNull (IS NULL)
IsNotNull (IS NOT NULL)
In (IN)

String Functions

ExpressionNotes
Ascii
BitLength
Chr
ConcatWs
Contains
EndsWith
InitCap
Instr
Length
Like
Lower
OctetLength
RepeatNegative argument for number of times to repeat causes exception
Replace
Reverse
StartsWith
StringRPad
StringSpace
StringTrim
StringTrimBoth
StringTrimLeft
StringTrimRight
Substring
Translate
Upper

Date/Time Functions

ExpressionNotes
DatePartOnly year is supported
ExtractOnly year is supported
Hour
Minute
Second
TruncDate
TruncTimestamp
Year

Math Expressions

ExpressionNotes
Abs
Acos
Asin
Atan
Atan2
Ceil
Cos
Exp
Floor
IsNaN
Log
Log2
Log10
Pow
Round
Signum
Sin
Sqrt
Tan

Hashing Functions

ExpressionNotes
Md5
Hash
Sha2
XxHash64

Boolean Expressions

ExpressionNotes
And
Or
Not

Bitwise Expressions

ExpressionNotes
ShiftLeft (<<)
ShiftRight (>>)
BitAnd (&)
BitOr (|)
BitXor (^)
BitwiseNot (~)
BoolAnd (bool_and)
BoolOr (bool_or)

Aggregate Expressions

ExpressionNotes
Avg
BitAndAgg
BitOrAgg
BitXorAgg
Corr
Count
CovPopulation
CovSample
First
Last
Max
Min
StddevPop
StddevSamp
Sum
VariancePop
VarianceSamp

Arrays

ExpressionNotes
ArrayAppendExperimental
ArrayCompactExperimental
ArrayContainsExperimental
ArrayDistinctExperimental: behaves differently than spark. Datafusion first sorts then removes duplicates while spark preserves the original order.
ArrayExceptExperimental
ArrayInsertExperimental
ArrayIntersectExperimental
ArrayJoinExperimental
ArrayMaxExperimental
ArrayRemove
ArrayRepeatExperimental
ArraysOverlapExperimental
ArrayUnionExperimental: behaves differently than spark. Datafusion sorts the input arrays before performing the union, while spark preserves the order of the first array and appends unique elements from the second.
ElementAtArrays only
GetArrayItem

Structs

ExpressionNotes
CreateNamedStruct
GetStructField
StructsToJson

Other

ExpressionNotes
CastSee compatibility guide for list of supported cast expressions and known issues
BloomFilterMightContain
ScalarSubquery
Coalesce
NormalizeNaNAndZero
ToPrettyString