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

comphead 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 41d2e0cfd feat: adding math sec expression (#4371)
41d2e0cfd is described below

commit 41d2e0cfd3e978bcf04cc2781a0482eced2df6ce
Author: Krishna Sudarshan J <[email protected]>
AuthorDate: Wed May 20 23:51:05 2026 +0530

    feat: adding math sec expression (#4371)
---
 .../contributor-guide/spark_expressions_support.md |  2 +-
 docs/source/user-guide/latest/expressions.md       |  1 +
 native/core/src/execution/jni_api.rs               |  2 ++
 .../org/apache/comet/serde/QueryPlanSerde.scala    |  1 +
 .../resources/sql-tests/expressions/math/sec.sql   | 25 ++++++++++++++++++++++
 5 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/docs/source/contributor-guide/spark_expressions_support.md 
b/docs/source/contributor-guide/spark_expressions_support.md
index 24422b7a6..9c19926a7 100644
--- a/docs/source/contributor-guide/spark_expressions_support.md
+++ b/docs/source/contributor-guide/spark_expressions_support.md
@@ -413,7 +413,7 @@
 - [ ] randstr
 - [ ] rint
 - [x] round
-- [ ] sec
+- [x] sec
 - [x] shiftleft
 - [x] sign
 - [x] signum
diff --git a/docs/source/user-guide/latest/expressions.md 
b/docs/source/user-guide/latest/expressions.md
index 40d2154e8..37440980e 100644
--- a/docs/source/user-guide/latest/expressions.md
+++ b/docs/source/user-guide/latest/expressions.md
@@ -175,6 +175,7 @@ of expressions that be disabled.
 | Randn          | `randn`        |
 | Remainder      | `%`            |
 | Round          | `round`        |
+| Sec            | `sec`          |
 | Signum         | `signum`       |
 | Sin            | `sin`          |
 | Sinh           | `sinh`         |
diff --git a/native/core/src/execution/jni_api.rs 
b/native/core/src/execution/jni_api.rs
index b1f2ccf02..a19d1ee36 100644
--- a/native/core/src/execution/jni_api.rs
+++ b/native/core/src/execution/jni_api.rs
@@ -61,6 +61,7 @@ use datafusion_spark::function::math::expm1::SparkExpm1;
 use datafusion_spark::function::math::factorial::SparkFactorial;
 use datafusion_spark::function::math::hex::SparkHex;
 use datafusion_spark::function::math::trigonometry::SparkCsc;
+use datafusion_spark::function::math::trigonometry::SparkSec;
 use datafusion_spark::function::math::width_bucket::SparkWidthBucket;
 use datafusion_spark::function::string::char::CharFunc;
 use datafusion_spark::function::string::concat::SparkConcat;
@@ -599,6 +600,7 @@ fn register_datafusion_spark_function(session_ctx: 
&SessionContext) {
     
session_ctx.register_udf(ScalarUDF::new_from_impl(SparkTryUrlDecode::default()));
     session_ctx.register_udf(ScalarUDF::new_from_impl(SparkCsc::default()));
     
session_ctx.register_udf(ScalarUDF::new_from_impl(SparkFactorial::default()));
+    session_ctx.register_udf(ScalarUDF::new_from_impl(SparkSec::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 5ecf14db3..9c80f33d3 100644
--- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
+++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
@@ -126,6 +126,7 @@ object QueryPlanSerde extends Logging with CometExprShim 
with CometTypeShim {
     classOf[Randn] -> CometRandn,
     classOf[Remainder] -> CometRemainder,
     classOf[Round] -> CometRound,
+    classOf[Sec] -> CometScalarFunction("sec"),
     classOf[Signum] -> CometScalarFunction("signum"),
     classOf[Sin] -> CometScalarFunction("sin"),
     classOf[Sinh] -> CometScalarFunction("sinh"),
diff --git a/spark/src/test/resources/sql-tests/expressions/math/sec.sql 
b/spark/src/test/resources/sql-tests/expressions/math/sec.sql
new file mode 100644
index 000000000..4a9494fe0
--- /dev/null
+++ b/spark/src/test/resources/sql-tests/expressions/math/sec.sql
@@ -0,0 +1,25 @@
+-- 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.
+
+statement
+CREATE TABLE test_sec(d double) USING parquet
+
+statement
+INSERT INTO test_sec VALUES (0.0), (-0.0), (1.5707963267948966), 
(-1.5707963267948966), (3.141592653589793), (NULL), (cast('NaN' as double)), 
(cast('Infinity' as double)), (cast('-Infinity' as double))
+
+query tolerance=1e-6
+SELECT sec(d) FROM test_sec


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

Reply via email to