Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/contributor-guide/spark_expressions_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@
- [ ] randstr
- [ ] rint
- [x] round
- [ ] sec
- [x] sec
- [x] shiftleft
- [x] sign
- [x] signum
Expand Down
1 change: 1 addition & 0 deletions docs/source/user-guide/latest/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ of expressions that be disabled.
| Randn | `randn` |
| Remainder | `%` |
| Round | `round` |
| Sec | `sec` |
| Signum | `signum` |
| Sin | `sin` |
| Sinh | `sinh` |
Expand Down
2 changes: 2 additions & 0 deletions native/core/src/execution/jni_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
25 changes: 25 additions & 0 deletions spark/src/test/resources/sql-tests/expressions/math/sec.sql
Original file line number Diff line number Diff line change
@@ -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
Loading