luis4a0 commented on code in PR #13282:
URL: https://github.com/apache/gluten/pull/13282#discussion_r4582877076


##########
cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc:
##########
@@ -152,6 +152,19 @@ bool SubstraitToVeloxPlanValidator::validateRound(
     return false;
   }
 
+  const auto& scale = arguments[1].value().literal();
+  if (scale.has_null() && scale.null().has_i32()) {
+    if (params.empty() || !params[0]) {
+      LOG_VALIDATION_MSG("Round value expression is unavailable.");
+      return false;
+    }
+    const auto& valueType = params[0]->type();
+    if (!valueType->isDecimal() &&
+        (valueType->isTinyint() || valueType->isSmallint() || 
valueType->isInteger() || valueType->isBigint())) {
+      return true;
+    }
+  }

Review Comment:
   Addressed in 
https://github.com/luis4a0/gluten/commit/8d62196023c3473cdcf207846e9ba3052d4c7091.
 `validateRound` now rejects an empty or null converted value immediately after 
the arity check, before every scale-specific path. The public validator 
regression covers both NULL and nonnegative literal scales, and the complete 
25-test native function binary passes.



##########
docs/backends/velox/velox-backend-scalar-function-support.md:
##########
@@ -2,6 +2,8 @@
 
 **Out of 433 scalar functions in Spark 4.1, Gluten currently fully supports 
262 functions and partially supports 32 functions.**

Review Comment:
   Addressed in 
https://github.com/luis4a0/gluten/commit/8d62196023c3473cdcf207846e9ba3052d4c7091.
 The headline now reports 261 fully supported and 33 partially supported 
functions, matching ROUND moving from `S` to `PS`. 
`tools/scripts/diff-function-support-docs.py` confirms the one-function 
category shift.



##########
docs/backends/velox/velox-backend-scalar-function-support.md:
##########
@@ -297,7 +299,7 @@ The status applies to `spark.sql.ansi.enabled=false`. When 
ANSI mode is enabled,
 | randn             | Randn                  | S        |                |
 | random            | Rand                   | S        |                |
 | rint              | Rint                   | S        |                |
-| round             | Round                  | S        |                |
+| round             | Round                  | PS       | Integral inputs 
support nonnegative literal scales and NULL. Negative or nonliteral scales fall 
back to Spark; disabling native validation bypasses this guard. |

Review Comment:
   Addressed in 
https://github.com/luis4a0/gluten/commit/8d62196023c3473cdcf207846e9ba3052d4c7091.
 The headline now reports 261 fully supported and 33 partially supported 
functions, matching ROUND moving from `S` to `PS`. 
`tools/scripts/diff-function-support-docs.py` confirms the one-function 
category shift.



##########
cpp/velox/tests/SparkFunctionTest.cc:
##########
@@ -125,6 +126,80 @@ TEST_F(SparkFunctionTest, roundWithDecimal) {
   runRoundWithDecimalTest<int8_t>(testRoundWithDecIntegralData<int8_t>());
 }
 
+TEST_F(SparkFunctionTest, integralRoundUsesSessionAnsi) {
+  const auto input = makeRowVector({makeNullableFlatVector<int8_t>({127, -128, 
25, -25, std::nullopt})});
+  for (const auto ansi : {false, true}) {
+    queryCtx_->testingOverrideConfigUnsafe({{sparkAnsiEnabledConfigKey(), ansi 
? "true" : "false"}});
+    const auto expression = "round(c0, cast(-1 as integer))";
+    if (ansi) {
+      VELOX_ASSERT_USER_THROW(evaluate(expression, input), "Arithmetic 
overflow: round(");

Review Comment:
   I retained this focused substring assertion intentionally. 
`/root/worktrees/gluten-oss-integral-round/AGENTS.md` requires tests to assert 
informative error-message text rather than only the exception type. `Arithmetic 
overflow: round(` verifies the stable actionable diagnosis without binding the 
test to dynamic argument values. The complete 25-test native function binary 
passes on 
https://github.com/luis4a0/gluten/commit/8d62196023c3473cdcf207846e9ba3052d4c7091.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to