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 e73cf12f79..f4cc0e19c0 100644 --- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala +++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala @@ -122,6 +122,8 @@ object QueryPlanSerde extends Logging with CometExprShim with CometTypeShim { classOf[Subtract] -> CometSubtract, classOf[Tan] -> CometScalarFunction("tan"), classOf[Tanh] -> CometScalarFunction("tanh"), + classOf[ToDegrees] -> CometScalarFunction("degrees"), + classOf[ToRadians] -> CometScalarFunction("radians"), classOf[Cot] -> CometScalarFunction("cot"), classOf[UnaryMinus] -> CometUnaryMinus, classOf[Unhex] -> CometUnhex, diff --git a/spark/src/test/resources/sql-tests/expressions/math/degrees.sql b/spark/src/test/resources/sql-tests/expressions/math/degrees.sql new file mode 100644 index 0000000000..3bcb005d05 --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/math/degrees.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_degrees(d double) USING parquet + +statement +INSERT INTO test_degrees VALUES (0.0), (3.141592653589793), (1.5707963267948966), (-3.141592653589793), (6.283185307179586), (NULL), (cast('NaN' as double)) + +query tolerance=1e-6 +SELECT degrees(d) FROM test_degrees + +-- literal arguments +query tolerance=1e-6 +SELECT degrees(0.0), degrees(3.141592653589793), degrees(NULL) diff --git a/spark/src/test/resources/sql-tests/expressions/math/radians.sql b/spark/src/test/resources/sql-tests/expressions/math/radians.sql new file mode 100644 index 0000000000..e29dbd4f01 --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/math/radians.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_radians(d double) USING parquet + +statement +INSERT INTO test_radians VALUES (0.0), (90.0), (180.0), (360.0), (-180.0), (NULL), (cast('NaN' as double)) + +query tolerance=1e-6 +SELECT radians(d) FROM test_radians + +-- literal arguments +query tolerance=1e-6 +SELECT radians(0.0), radians(90.0), radians(180.0), radians(NULL)