From 56684c0615728eba6358a8911e8c0f19d1e6be9c Mon Sep 17 00:00:00 2001 From: brijrajk <22271048+brijrajk@users.noreply.github.com> Date: Sat, 30 May 2026 07:27:05 +0530 Subject: [PATCH] [GLUTEN-12157][VL] Fix silently-skipped math/scalar test suites; add Velox native tests for sin, tan, tanh, radians, ln MathFunctionsValidateSuite and ScalarFunctionsValidateSuite were left as abstract classes after PR #11756 (RAS removal) deleted their only concrete subclasses, causing all tests in those suites to silently not run. Promote both to concrete classes and disable ANSI mode (enabled by default in Spark 4) so checkGlutenPlan[ProjectExecTransformer] works correctly. Add Scala integration tests for sin, tan, tanh, radians, and ln. The ln test includes an edge-case check that ln(0) and ln(-1) return null, not -Infinity/NaN, matching Spark's Hive-inherited semantics. The native registrations for these five functions are provided by facebookincubator/velox#17648 (sparksql::registerMathFunctions). Set UPSTREAM_VELOX_PR_ID=17648 to validate the full pipeline on CI while that Velox PR is in flight. This will be cleared before merge once the Velox change lands in Gluten. --- .../MathFunctionsValidateSuite.scala | 41 ++++++++++++++++++- .../ScalarFunctionsValidateSuite.scala | 3 +- ep/build-velox/src/get-velox.sh | 2 +- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/backends-velox/src/test/scala/org/apache/gluten/functions/MathFunctionsValidateSuite.scala b/backends-velox/src/test/scala/org/apache/gluten/functions/MathFunctionsValidateSuite.scala index 9fa0d336a45..6f4ea376c92 100644 --- a/backends-velox/src/test/scala/org/apache/gluten/functions/MathFunctionsValidateSuite.scala +++ b/backends-velox/src/test/scala/org/apache/gluten/functions/MathFunctionsValidateSuite.scala @@ -66,7 +66,7 @@ class MathFunctionsValidateSuiteAnsiOn extends FunctionsValidateSuite { } } -abstract class MathFunctionsValidateSuite extends FunctionsValidateSuite { +class MathFunctionsValidateSuite extends FunctionsValidateSuite { disableFallbackCheck import testImplicits._ @@ -248,6 +248,17 @@ abstract class MathFunctionsValidateSuite extends FunctionsValidateSuite { } } + test("ln") { + runQueryAndCompare("SELECT ln(l_orderkey) from lineitem limit 1") { + checkGlutenPlan[ProjectExecTransformer] + } + // Verify null semantics: ln(0) and ln(-1) must return null, not -Infinity/NaN + compareResultsAgainstVanillaSpark( + "SELECT ln(0), ln(-1), ln(cast(null as double))", + true, + { _ => }) + } + test("log") { runQueryAndCompare("SELECT log(10, l_orderkey) from lineitem limit 1") { checkGlutenPlan[ProjectExecTransformer] @@ -295,6 +306,12 @@ abstract class MathFunctionsValidateSuite extends FunctionsValidateSuite { } } + test("radians") { + runQueryAndCompare("SELECT radians(l_orderkey) from lineitem limit 1") { + checkGlutenPlan[ProjectExecTransformer] + } + } + test("rint") { withTempPath { path => @@ -332,6 +349,24 @@ abstract class MathFunctionsValidateSuite extends FunctionsValidateSuite { } } + test("sin") { + runQueryAndCompare("SELECT sin(l_orderkey) from lineitem limit 1") { + checkGlutenPlan[ProjectExecTransformer] + } + } + + test("tan") { + runQueryAndCompare("SELECT tan(l_orderkey) from lineitem limit 1") { + checkGlutenPlan[ProjectExecTransformer] + } + } + + test("tanh") { + runQueryAndCompare("SELECT tanh(l_orderkey) from lineitem limit 1") { + checkGlutenPlan[ProjectExecTransformer] + } + } + test("try_add") { runQueryAndCompare( "select try_add(cast(l_orderkey as int), 1), try_add(cast(l_orderkey as int), 2147483647)" + @@ -414,7 +449,9 @@ abstract class MathFunctionsValidateSuite extends FunctionsValidateSuite { } } - test("decimal arithmetic respects allowPrecisionLoss captured at view analysis time") { + testWithMinSparkVersion( + "decimal arithmetic respects allowPrecisionLoss captured at view analysis time", + "4.1") { // Regression test for GLUTEN-11917: in Spark 4.1, arithmetic expressions embed // allowPrecisionLoss in their evalContext at analysis time. Gluten must read from // the expression rather than SQLConf.get, which can differ when querying a view diff --git a/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala b/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala index cd49c23029b..8c343890bd0 100644 --- a/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala +++ b/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala @@ -26,7 +26,8 @@ import org.apache.spark.sql.execution.ProjectExec import org.apache.spark.sql.internal.SQLConf import org.apache.spark.sql.types._ -abstract class ScalarFunctionsValidateSuite extends FunctionsValidateSuite { +class ScalarFunctionsValidateSuite extends FunctionsValidateSuite { + disableFallbackCheck import testImplicits._ diff --git a/ep/build-velox/src/get-velox.sh b/ep/build-velox/src/get-velox.sh index 3b1b3abcc9a..37cd06223ce 100755 --- a/ep/build-velox/src/get-velox.sh +++ b/ep/build-velox/src/get-velox.sh @@ -25,7 +25,7 @@ RUN_SETUP_SCRIPT=ON ENABLE_ENHANCED_FEATURES=OFF # Developer use only for testing Velox PR. -UPSTREAM_VELOX_PR_ID="" +UPSTREAM_VELOX_PR_ID="17648" OS=`uname -s`