From b7bb47d383e897ae50ece7ff706a5dce336de0ea Mon Sep 17 00:00:00 2001 From: comphead Date: Wed, 20 May 2026 10:01:20 -0700 Subject: [PATCH 1/2] chore: wire `rint` --- .../spark_expressions_support.md | 2 +- docs/source/user-guide/latest/expressions.md | 1 + native/core/src/execution/jni_api.rs | 2 + .../apache/comet/serde/QueryPlanSerde.scala | 1 + .../sql-tests/expressions/math/rint.sql | 60 +++++++++++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 spark/src/test/resources/sql-tests/expressions/math/rint.sql diff --git a/docs/source/contributor-guide/spark_expressions_support.md b/docs/source/contributor-guide/spark_expressions_support.md index 9c19926a7c..9b27f2a1f3 100644 --- a/docs/source/contributor-guide/spark_expressions_support.md +++ b/docs/source/contributor-guide/spark_expressions_support.md @@ -411,7 +411,7 @@ - [x] randn - [ ] random - [ ] randstr -- [ ] rint +- [x] rint - [x] round - [x] sec - [x] shiftleft diff --git a/docs/source/user-guide/latest/expressions.md b/docs/source/user-guide/latest/expressions.md index 37440980ef..a610a83cea 100644 --- a/docs/source/user-guide/latest/expressions.md +++ b/docs/source/user-guide/latest/expressions.md @@ -174,6 +174,7 @@ of expressions that be disabled. | Rand | `rand` | | Randn | `randn` | | Remainder | `%` | +| Rint | `rint` | | Round | `round` | | Sec | `sec` | | Signum | `signum` | diff --git a/native/core/src/execution/jni_api.rs b/native/core/src/execution/jni_api.rs index a19d1ee368..b56f9fa8ec 100644 --- a/native/core/src/execution/jni_api.rs +++ b/native/core/src/execution/jni_api.rs @@ -60,6 +60,7 @@ use datafusion_spark::function::map::str_to_map::SparkStrToMap; 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::rint::SparkRint; use datafusion_spark::function::math::trigonometry::SparkCsc; use datafusion_spark::function::math::trigonometry::SparkSec; use datafusion_spark::function::math::width_bucket::SparkWidthBucket; @@ -601,6 +602,7 @@ fn register_datafusion_spark_function(session_ctx: &SessionContext) { 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())); + session_ctx.register_udf(ScalarUDF::new_from_impl(SparkRint::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 9c80f33d39..4c3cc05ffd 100644 --- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala +++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala @@ -125,6 +125,7 @@ object QueryPlanSerde extends Logging with CometExprShim with CometTypeShim { classOf[Rand] -> CometRand, classOf[Randn] -> CometRandn, classOf[Remainder] -> CometRemainder, + classOf[Rint] -> CometScalarFunction("rint"), classOf[Round] -> CometRound, classOf[Sec] -> CometScalarFunction("sec"), classOf[Signum] -> CometScalarFunction("signum"), diff --git a/spark/src/test/resources/sql-tests/expressions/math/rint.sql b/spark/src/test/resources/sql-tests/expressions/math/rint.sql new file mode 100644 index 0000000000..7af2d1e7e0 --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/math/rint.sql @@ -0,0 +1,60 @@ +-- 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 + +-- Spark's Rint extends UnaryMathExpression with inputTypes = Seq(DoubleType). +-- It returns the double value closest to the argument equal to a mathematical integer +-- (Java's Math.rint, IEEE 754 round-half-to-even / banker's rounding). + +statement +CREATE TABLE test_rint(v double) USING parquet + +statement +INSERT INTO test_rint VALUES + (0.0), + (-0.0), + (1.0), + (-1.0), + (0.4), + (0.5), + (0.6), + (1.5), + (2.5), + (3.5), + (-0.4), + (-0.5), + (-0.6), + (-1.5), + (-2.5), + (-3.5), + (12.3456), + (-12.3456), + (1.7976931348623157E308), + (-1.7976931348623157E308), + (4.9E-324), + (cast('NaN' as double)), + (cast('Infinity' as double)), + (cast('-Infinity' as double)), + (NULL) + +query +SELECT rint(v) FROM test_rint + +-- column with arithmetic +query +SELECT rint(v + 0.5) FROM test_rint From 8d5bffb2c1f4bc46f5af5311cf0ab6dd8300293a Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Thu, 21 May 2026 15:29:39 +0300 Subject: [PATCH 2/2] Add AI config files --- .cursor/rules.md | 5 +++++ .gemini/rules.md | 5 +++++ AGENTS.md | 5 +++++ CLAUDE.md | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 .cursor/rules.md create mode 100644 .gemini/rules.md create mode 100644 CLAUDE.md diff --git a/.cursor/rules.md b/.cursor/rules.md new file mode 100644 index 0000000000..00385e6f5f --- /dev/null +++ b/.cursor/rules.md @@ -0,0 +1,5 @@ +The AI agents should never link to any issue or a pull request +in any GitHub repository in the code reviews! + +The AI agents should not review AI agents' config files like CLAUDE.md or AGENTS.md! + diff --git a/.gemini/rules.md b/.gemini/rules.md new file mode 100644 index 0000000000..00385e6f5f --- /dev/null +++ b/.gemini/rules.md @@ -0,0 +1,5 @@ +The AI agents should never link to any issue or a pull request +in any GitHub repository in the code reviews! + +The AI agents should not review AI agents' config files like CLAUDE.md or AGENTS.md! + diff --git a/AGENTS.md b/AGENTS.md index 683dcbe3ee..700161034b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,3 +33,8 @@ Relevant entry points: When opening a pull request, use the [PR template](.github/pull_request_template.md) and fill in every section. +The AI agents should never link to any issue or a pull request +in any GitHub repository in the code reviews! + +The AI agents should not review AI agents' config files like CLAUDE.md or AGENTS.md! + diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000000..00385e6f5f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +The AI agents should never link to any issue or a pull request +in any GitHub repository in the code reviews! + +The AI agents should not review AI agents' config files like CLAUDE.md or AGENTS.md! +