Copilot commented on code in PR #13282:
URL: https://github.com/apache/gluten/pull/13282#discussion_r4561758848
##########
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:
With the new signature, `validateRound` can still potentially return true
for non-NULL scales even when the converted value argument is missing/null
(i.e., `params` is empty or `params[0]` is null). That contradicts the header
comment about rejecting missing/unavailable converted args and can lead to
later crashes or inconsistent fallback behavior. Consider adding an early guard
(before any scale-specific logic) that requires `params.size() >= 1` and
`params[0]` to be non-null whenever validation might succeed, and optionally
log a validation message when the value expression is unavailable.
##########
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:
The summary counts at the top appear inconsistent with changing `round` from
`S` to `PS` (this would typically reduce the fully-supported count by 1 and
increase partially-supported by 1). Please update the headline counts (or
document that they are generated/approximate) so the overview matches the table.
##########
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:
This assertion depends on a specific substring of the error message, which
can be brittle across Velox/Spark error text changes. If available in the test
utilities, prefer asserting on a stable error category/code/type (or a
less-specific message fragment) to reduce flaky failures when upstream wording
changes.
##########
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:
The summary counts at the top appear inconsistent with changing `round` from
`S` to `PS` (this would typically reduce the fully-supported count by 1 and
increase partially-supported by 1). Please update the headline counts (or
document that they are generated/approximate) so the overview matches the table.
--
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]