This is an automated email from the ASF dual-hosted git repository.
zhztheplayer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git
The following commit(s) were added to refs/heads/main by this push:
new fc827df514 [VL] Support randn scalar function (#12896)
fc827df514 is described below
commit fc827df5140fa783fc72bb2999a6c6c50385e0f3
Author: Kaifei Yi <[email protected]>
AuthorDate: Wed Aug 26 12:13:18 2026 +0800
[VL] Support randn scalar function (#12896)
---
.../main/scala/org/apache/gluten/utils/CHExpressionUtil.scala | 3 ++-
.../apache/gluten/functions/MathFunctionsValidateSuite.scala | 10 ++++++++++
docs/velox-backend-scalar-function-support.md | 4 ++--
.../org/apache/gluten/expression/ExpressionMappings.scala | 1 +
.../org/apache/gluten/utils/velox/VeloxTestSettings.scala | 4 ++++
.../org/apache/gluten/utils/velox/VeloxTestSettings.scala | 4 ++++
.../scala/org/apache/gluten/expression/ExpressionNames.scala | 1 +
7 files changed, 24 insertions(+), 3 deletions(-)
diff --git
a/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala
b/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala
index 1a7dc3aa13..71505eaf74 100644
---
a/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala
+++
b/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala
@@ -215,6 +215,7 @@ object CHExpressionUtil {
REGEXP_INSTR -> DefaultValidator(),
DAY_NAME -> DefaultValidator(),
MONTH_NAME -> DefaultValidator(),
- FORMAT_NUMBER -> DefaultValidator()
+ FORMAT_NUMBER -> DefaultValidator(),
+ RANDN -> DefaultValidator()
)
}
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 81a9ad5cdb..5fa0833426 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
@@ -299,6 +299,16 @@ class MathFunctionsValidateSuite extends
FunctionsValidateSuite {
}
}
+ test("randn") {
+ // randn draws from the standard normal distribution, so only verify
native execution.
+ runQueryAndCompare("SELECT randn() from lineitem limit 100", compareResult
= false) {
+ checkGlutenPlan[ProjectExecTransformer]
+ }
+ runQueryAndCompare("SELECT randn(0) from lineitem limit 100",
compareResult = false) {
+ checkGlutenPlan[ProjectExecTransformer]
+ }
+ }
+
testWithMinSparkVersion("randstr", "4.0") {
// randstr generates random strings, so we only verify native execution,
not result equality.
runQueryAndCompare("SELECT randstr(5, 0) from lineitem limit 100",
compareResult = false) {
diff --git a/docs/velox-backend-scalar-function-support.md
b/docs/velox-backend-scalar-function-support.md
index 4436caeac9..744b4365d6 100644
--- a/docs/velox-backend-scalar-function-support.md
+++ b/docs/velox-backend-scalar-function-support.md
@@ -1,6 +1,6 @@
# Scalar Functions Support Status
-**Out of 357 scalar functions in Spark 3.5, Gluten currently fully supports
245 functions and partially supports 28 functions.**
+**Out of 357 scalar functions in Spark 3.5, Gluten currently fully supports
246 functions and partially supports 28 functions.**
**Gluten also fully supports 2 additional functions introduced in Spark 4.0.**
@@ -275,7 +275,7 @@
| power | Pow | S | |
| radians | ToRadians | | |
| rand | Rand | S | |
-| randn | Randn | | |
+| randn | Randn | S | |
| random | Rand | S | |
| rint | Rint | S | |
| round | Round | S | |
diff --git
a/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionMappings.scala
b/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionMappings.scala
index 5193f31d66..d58f1b5650 100644
---
a/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionMappings.scala
+++
b/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionMappings.scala
@@ -156,6 +156,7 @@ object ExpressionMappings {
Sig[Remainder](REMAINDER),
Sig[Factorial](FACTORIAL),
Sig[Rand](RAND),
+ Sig[Randn](RANDN),
Sig[Rint](RINT),
// PrestoSQL Math functions
Sig[Acos](ACOS),
diff --git
a/gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
b/gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
index 93a7f9d1ef..bbfcca85c6 100644
---
a/gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
+++
b/gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
@@ -1020,6 +1020,10 @@ class VeloxTestSettings extends BackendTestSettings {
.exclude("SPARK-27439: Explain result should match collected result after
view change")
// https://github.com/apache/gluten/issues/11570
.exclude("getRows: binary")
+ // Velox does not reproduce Spark's guarantee that a seeded
non-deterministic
+ // expression referenced multiple times yields row-wise equal values
(rand/randn).
+ // Same class of difference as SPARK-9083. Not really an issue.
+ .exclude("SPARK-45216: Non-deterministic functions with seed")
enableSuite[GlutenDataFrameTimeWindowingSuite]
enableSuite[GlutenDataFrameTungstenSuite]
enableSuite[GlutenDataFrameWindowFunctionsSuite]
diff --git
a/gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
b/gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
index 9d8e5cdafe..c1e7c89804 100644
---
a/gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
+++
b/gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
@@ -1005,6 +1005,10 @@ class VeloxTestSettings extends BackendTestSettings {
.exclude("SPARK-27439: Explain result should match collected result after
view change")
// https://github.com/apache/gluten/issues/11570
.exclude("getRows: binary")
+ // Velox does not reproduce Spark's guarantee that a seeded
non-deterministic
+ // expression referenced multiple times yields row-wise equal values
(rand/randn).
+ // Same class of difference as SPARK-9083. Not really an issue.
+ .exclude("SPARK-45216: Non-deterministic functions with seed")
enableSuite[GlutenDataFrameTimeWindowingSuite]
enableSuite[GlutenDataFrameTungstenSuite]
enableSuite[GlutenDataFrameWindowFunctionsSuite]
diff --git
a/shims/common/src/main/scala/org/apache/gluten/expression/ExpressionNames.scala
b/shims/common/src/main/scala/org/apache/gluten/expression/ExpressionNames.scala
index a6b1818ff9..733adff050 100644
---
a/shims/common/src/main/scala/org/apache/gluten/expression/ExpressionNames.scala
+++
b/shims/common/src/main/scala/org/apache/gluten/expression/ExpressionNames.scala
@@ -198,6 +198,7 @@ object ExpressionNames {
final val REMAINDER = "modulus"
final val FACTORIAL = "factorial"
final val RAND = "rand"
+ final val RANDN = "randn"
final val RANDSTR = "randstr"
final val RINT = "rint"
final val RIGHT = "right"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]