hash_funcs Expression Audits#
Audit notes for expressions in this category that have been audited. Absence of an entry means the expression has not been audited yet, not that it is unsupported. See the user guide Spark Expression Support for current support status.
crc32#
Spark 3.4.3 (audited 2026-05-27): identical to 3.5.8.
Spark 3.5.8 (audited 2026-05-27): baseline.
Crc32(child) extends UnaryExpression;inputTypes = Seq(BinaryType) -> LongType. Wired asCometScalarFunction("crc32").Spark 4.0.1 (audited 2026-05-27): semantics unchanged;
NullIntoleranttrait replaced bynullIntolerant: Booleanoverride.Spark 4.1.1 (audited 2026-05-27): identical to 4.0.1.
hash#
Spark 3.4.3 (audited 2026-05-27): identical to 3.5.8.
Spark 3.5.8 (audited 2026-05-27): baseline.
Murmur3Hash(children, seed) extends HashExpression[Int]; produces a Murmur3 hash with a configurable Int seed andIntegerTyperesult. Comet routes viaCometMurmur3Hashto the nativemurmur3_hashUDF.Spark 4.0.1 (audited 2026-05-27): semantics unchanged; some inner helper refactors only.
Spark 4.1.1 (audited 2026-05-27): identical to 4.0.1.
Decimals with precision 19–38, including nested decimals, hash natively using the minimal signed big-endian bytes of the unscaled value, matching Spark’s
BigInteger.toByteArray(). Precision ≤18 retains unscaled-long hashing.TimeTyperemains unsupported through the sharedHashUtils.Performance (tuned 2026-09-28, issue #5994): typed wide-decimal list scans avoid per-element Arrow slices and recursive dispatch. Local Criterion measurements were 5.0–14.2x faster across 8,192-row
decimal(38,0)List, LargeList and FixedSizeList inputs with 2/32 elements and no/sparse/dense nulls; paired scalar remeasurement found no significant slowdown. Benchmark:benches/decimal_hash.rs.
md5#
Spark 3.4.3 (audited 2026-05-27): identical to 3.5.8.
Spark 3.5.8 (audited 2026-05-27): baseline.
Md5(child) extends UnaryExpression;inputTypes = Seq(BinaryType) -> StringType. Wired asCometScalarFunction("md5").Spark 4.0.1 (audited 2026-05-27): semantics unchanged; trait set gains
DefaultStringProducingExpressionand thenullIntolerant: Booleanrefactor.Spark 4.1.1 (audited 2026-05-27): identical to 4.0.1.
sha#
Spark 3.4.3 (audited 2026-05-27): registry alias of
Sha1. Same support assha1.Spark 3.5.8 (audited 2026-05-27): identical to 3.4.3.
Spark 4.0.1 (audited 2026-05-27): identical to 3.4.3.
Spark 4.1.1 (audited 2026-05-27): identical to 3.4.3.
sha1#
Spark 3.4.3 (audited 2026-05-27): identical to 3.5.8.
Spark 3.5.8 (audited 2026-05-27): baseline.
Sha1(child) extends UnaryExpression with NullIntolerant;inputTypes = Seq(BinaryType) -> StringType. Comet routes viaCometSha1to the nativesha1UDF.Spark 4.0.1 (audited 2026-05-27): trait set gains
DefaultStringProducingExpressionandNullIntolerantis replaced bynullIntolerant: Boolean. Runtime unchanged.Spark 4.1.1 (audited 2026-05-27): identical to 4.0.1.
sha2#
Spark 3.4.3 (audited 2026-05-27): identical to 3.5.8.
Spark 3.5.8 (audited 2026-05-27): baseline.
Sha2(left, right) extends BinaryExpression;inputTypes = Seq(BinaryType, IntegerType) -> StringType. ThenumBitsargument selects SHA-224/256/384/512 (0 is treated as 256); other values return NULL. Comet routes viaCometSha2to the nativesha2UDF; non-foldablenumBitsfalls back to Spark.Spark 4.0.1 (audited 2026-05-27): trait set gains
DefaultStringProducingExpressionand thenullIntolerant: Booleanrefactor. Runtime unchanged.Spark 4.1.1 (audited 2026-05-27): identical to 4.0.1.
xxhash64#
Performance (tuned 2026-09-28, issue #5994): the shared typed wide-decimal list path was 2.1–15.8x faster in local Criterion measurements across 8,192-row
decimal(38,0)List, LargeList and FixedSizeList inputs with 2/32 elements and no/sparse/dense nulls; paired scalar remeasurement found no significant slowdown. Benchmark:benches/decimal_hash.rs.Spark 3.4.3 (audited 2026-05-27): identical to 3.5.8.
Spark 3.5.8 (audited 2026-05-27): baseline.
XxHash64(children, seed) extends HashExpression[Long]; produces an xxHash64 hash with a configurable Long seed andLongTyperesult. Comet routes viaCometXxHash64to the nativexxhash64UDF.Spark 4.0.1 (audited 2026-05-27): semantics unchanged.
Spark 4.1.1 (audited 2026-05-27): identical to 4.0.1.
Native routing: Comet’s native
xxhash64UDF delegates compatible arguments at Spark’s default seed (42) todatafusion-spark::SparkXxhash64. Differential tests innative/spark-expr/src/hash_funcs/xxhash64_diff.rscompare Comet’s kernel againstSparkXxhash64for primitives, narrow decimals, dictionaries, lists, maps, and nested combinations, and record where the two differ on a NaN whose bits are not canonical. Wide-decimal tests verify that the expression stays on Comet’s kernel: the pinned DataFusion implementation uses fixed-width little-endian bytes rather than Spark’s minimal signed big-endian bytes. The Comet kernel is retained for wide decimals (also within nested types), a non-default seed (SparkXxhash64hardcodes 42),Struct(upstream does not push a parent null mask into children; see #5753), aDictionarynested in a list/map (upstream restarts those hashes from 42),Time64, andFloat32/Float64, including values nested in lists and maps (upstream hashes the raw bits of a NaN, where Spark hashes every NaN as the canonical NaN; see apache/datafusion#25913).create_xxhash64_hashesremains forapprox_count_distinctand the non-delegated native path.