From e3be6b7c0da6e169f84a1eb6cfd0723a298514cb Mon Sep 17 00:00:00 2001 From: Rafael Fernandez Date: Wed, 25 Mar 2026 01:08:03 +0100 Subject: [PATCH 1/2] feat: Add support for Spark Cbrt math expression Add cube root function (cbrt) by delegating to DataFusion's built-in implementation via CometScalarFunction. --- spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala | 1 + 1 file changed, 1 insertion(+) 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 02a76f69f0..a4cc2e97d9 100644 --- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala +++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala @@ -92,6 +92,7 @@ object QueryPlanSerde extends Logging with CometExprShim { classOf[Asin] -> CometScalarFunction("asin"), classOf[Atan] -> CometScalarFunction("atan"), classOf[Atan2] -> CometAtan2, + classOf[Cbrt] -> CometScalarFunction("cbrt"), classOf[Ceil] -> CometCeil, classOf[Cos] -> CometScalarFunction("cos"), classOf[Cosh] -> CometScalarFunction("cosh"), From 3415ad4460c78730815e99c0a884000e2c06e347 Mon Sep 17 00:00:00 2001 From: Rafael Fernandez Date: Wed, 25 Mar 2026 07:15:42 +0100 Subject: [PATCH 2/2] test: Add SQL test for cbrt math expression --- .../sql-tests/expressions/math/cbrt.sql | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spark/src/test/resources/sql-tests/expressions/math/cbrt.sql diff --git a/spark/src/test/resources/sql-tests/expressions/math/cbrt.sql b/spark/src/test/resources/sql-tests/expressions/math/cbrt.sql new file mode 100644 index 0000000000..2a618fe45b --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/math/cbrt.sql @@ -0,0 +1,31 @@ +-- 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 + +statement +CREATE TABLE test_cbrt(d double) USING parquet + +statement +INSERT INTO test_cbrt VALUES (0.0), (1.0), (-1.0), (8.0), (27.0), (-27.0), (NULL), (cast('NaN' as double)), (cast('Infinity' as double)) + +query tolerance=1e-6 +SELECT cbrt(d) FROM test_cbrt + +-- literal arguments +query tolerance=1e-6 +SELECT cbrt(0.0), cbrt(8.0), cbrt(-27.0), cbrt(NULL)