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


##########
cpp/velox/tests/SparkFunctionTest.cc:
##########
@@ -125,6 +126,88 @@ 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 is tightly coupled to the exact error message text (prefix 
and formatting), which can change across Velox versions and make the test 
brittle. Prefer asserting on a stable signal (e.g., error category/code if 
available in the test utilities, or a less specific substring) so the test 
continues to validate overflow behavior without depending on the full message 
wording.



##########
cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc:
##########
@@ -141,17 +141,30 @@ bool 
SubstraitToVeloxPlanValidator::flattenDualLevel(const TypePtr& type, std::v
 
 bool SubstraitToVeloxPlanValidator::validateRound(
     const ::substrait::Expression::ScalarFunction& scalarFunction,
-    const RowTypePtr& inputType) {
+    const std::vector<core::TypedExprPtr>& params) {
   const auto& arguments = scalarFunction.arguments();
   if (arguments.size() < 2) {
     return false;
   }
+  if (params.empty() || !params[0]) {
+    LOG_VALIDATION_MSG("Round value expression is unavailable.");
+    return false;
+  }
 
   if (!arguments[1].value().has_literal()) {
     LOG_VALIDATION_MSG("Round scale is expected.");

Review Comment:
   The validation message is misleading for the actual failure mode: the scale 
argument may be present but non-literal (e.g., expression), and the 
implementation is specifically requiring a literal scale for native execution. 
Consider rewording to explicitly state the requirement (e.g., 'Round scale must 
be a literal integer for native execution') to make debugging validation 
failures easier.



-- 
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