This is an automated email from the ASF dual-hosted git repository.

agrove pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git


The following commit(s) were added to refs/heads/main by this push:
     new 2829ce8a9 feat: add support `crc32` expression (#3498)
2829ce8a9 is described below

commit 2829ce8a94cb8f77e3ea95170d83175bf2ffd722
Author: Rafael Fernández <[email protected]>
AuthorDate: Thu Feb 19 11:04:37 2026 +0100

    feat: add support `crc32` expression (#3498)
---
 docs/spark_expressions_support.md                  |  2 +-
 native/core/src/execution/jni_api.rs               |  2 ++
 .../org/apache/comet/serde/QueryPlanSerde.scala    |  1 +
 .../resources/sql-tests/expressions/hash/crc32.sql | 32 ++++++++++++++++++++++
 .../org/apache/comet/CometExpressionSuite.scala    |  2 ++
 5 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/docs/spark_expressions_support.md 
b/docs/spark_expressions_support.md
index 2c18cbd08..547489410 100644
--- a/docs/spark_expressions_support.md
+++ b/docs/spark_expressions_support.md
@@ -234,7 +234,7 @@
 
 ### hash_funcs
 
-- [ ] crc32
+- [x] crc32
 - [ ] hash
 - [x] md5
 - [ ] sha
diff --git a/native/core/src/execution/jni_api.rs 
b/native/core/src/execution/jni_api.rs
index c2cb1d910..436e5e99c 100644
--- a/native/core/src/execution/jni_api.rs
+++ b/native/core/src/execution/jni_api.rs
@@ -46,6 +46,7 @@ use 
datafusion_spark::function::datetime::date_add::SparkDateAdd;
 use datafusion_spark::function::datetime::date_sub::SparkDateSub;
 use datafusion_spark::function::datetime::last_day::SparkLastDay;
 use datafusion_spark::function::datetime::next_day::SparkNextDay;
+use datafusion_spark::function::hash::crc32::SparkCrc32;
 use datafusion_spark::function::hash::sha1::SparkSha1;
 use datafusion_spark::function::hash::sha2::SparkSha2;
 use datafusion_spark::function::map::map_from_entries::MapFromEntries;
@@ -375,6 +376,7 @@ fn register_datafusion_spark_function(session_ctx: 
&SessionContext) {
     session_ctx.register_udf(ScalarUDF::new_from_impl(SparkHex::default()));
     
session_ctx.register_udf(ScalarUDF::new_from_impl(SparkWidthBucket::default()));
     
session_ctx.register_udf(ScalarUDF::new_from_impl(MapFromEntries::default()));
+    session_ctx.register_udf(ScalarUDF::new_from_impl(SparkCrc32::default()));
 }
 
 /// Prepares arrow arrays for output.
diff --git a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala 
b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
index 6f399fa9f..9d13ccd9e 100644
--- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
+++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
@@ -139,6 +139,7 @@ object QueryPlanSerde extends Logging with CometExprShim {
     classOf[StructsToCsv] -> CometStructsToCsv)
 
   private val hashExpressions: Map[Class[_ <: Expression], 
CometExpressionSerde[_]] = Map(
+    classOf[Crc32] -> CometScalarFunction("crc32"),
     classOf[Md5] -> CometScalarFunction("md5"),
     classOf[Murmur3Hash] -> CometMurmur3Hash,
     classOf[Sha2] -> CometSha2,
diff --git a/spark/src/test/resources/sql-tests/expressions/hash/crc32.sql 
b/spark/src/test/resources/sql-tests/expressions/hash/crc32.sql
new file mode 100644
index 000000000..64b401c98
--- /dev/null
+++ b/spark/src/test/resources/sql-tests/expressions/hash/crc32.sql
@@ -0,0 +1,32 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+-- ConfigMatrix: parquet.enable.dictionary=false,true
+
+-- crc32 function
+statement
+CREATE TABLE test(col string, a int, b float) USING parquet
+
+statement
+INSERT INTO test VALUES ('Spark SQL  ', 10, 1.2), (NULL, NULL, NULL), ('', 0, 
0.0), ('苹果手机', NULL, 3.999999), ('Spark SQL  ', 10, 1.2), (NULL, NULL, NULL), 
('', 0, 0.0), ('苹果手机', NULL, 3.999999)
+
+query
+SELECT crc32(col), crc32(cast(a as string)), crc32(cast(b as string)) FROM test
+
+-- literal arguments
+query
+SELECT crc32('Spark SQL')
diff --git a/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala 
b/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala
index 415d8c3a1..f0f022868 100644
--- a/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala
+++ b/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala
@@ -1987,6 +1987,7 @@ class CometExpressionSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
               |md5(col), md5(cast(a as string)), md5(cast(b as string)),
               |hash(col), hash(col, 1), hash(col, 0), hash(col, a, b), hash(b, 
a, col),
               |xxhash64(col), xxhash64(col, 1), xxhash64(col, 0), 
xxhash64(col, a, b), xxhash64(b, a, col),
+              |crc32(col), crc32(cast(a as string)), crc32(cast(b as string)),
               |sha2(col, 0), sha2(col, 256), sha2(col, 224), sha2(col, 384), 
sha2(col, 512), sha2(col, 128), sha2(col, -1),
               |sha1(col), sha1(cast(a as string)), sha1(cast(b as string))
               |from test
@@ -2097,6 +2098,7 @@ class CometExpressionSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
               |md5(col), md5(cast(a as string)), --md5(cast(b as string)),
               |hash(col), hash(col, 1), hash(col, 0), hash(col, a, b), hash(b, 
a, col),
               |xxhash64(col), xxhash64(col, 1), xxhash64(col, 0), 
xxhash64(col, a, b), xxhash64(b, a, col),
+              |crc32(col), crc32(cast(a as string)),
               |sha2(col, 0), sha2(col, 256), sha2(col, 224), sha2(col, 384), 
sha2(col, 512), sha2(col, 128), sha2(col, -1),
               |sha1(col), sha1(cast(a as string))
               |from test


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to