This is an automated email from the ASF dual-hosted git repository.
philo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 654fd07586 [GLUTEN-8222][VL] Support Factorial function (#8221)
654fd07586 is described below
commit 654fd075864d3525b6e1e09fe33f2d14c8bbd004
Author: Arnav Balyan <[email protected]>
AuthorDate: Tue May 6 16:45:33 2025 +0530
[GLUTEN-8222][VL] Support Factorial function (#8221)
---
.../execution/ScalarFunctionsValidateSuite.scala | 41 ++++++++++++++++++++++
.../substrait/SubstraitToVeloxPlanValidator.cc | 2 +-
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git
a/backends-velox/src/test/scala/org/apache/gluten/execution/ScalarFunctionsValidateSuite.scala
b/backends-velox/src/test/scala/org/apache/gluten/execution/ScalarFunctionsValidateSuite.scala
index 7145f215b5..e5cdcb439d 100644
---
a/backends-velox/src/test/scala/org/apache/gluten/execution/ScalarFunctionsValidateSuite.scala
+++
b/backends-velox/src/test/scala/org/apache/gluten/execution/ScalarFunctionsValidateSuite.scala
@@ -19,6 +19,7 @@ package org.apache.gluten.execution
import org.apache.gluten.config.GlutenConfig
import org.apache.spark.{SparkConf, SparkException}
+import org.apache.spark.sql.Row
import org.apache.spark.sql.catalyst.optimizer.NullPropagation
import org.apache.spark.sql.execution.ProjectExec
import org.apache.spark.sql.types._
@@ -1730,4 +1731,44 @@ abstract class ScalarFunctionsValidateSuite extends
FunctionsValidateSuite {
}
}
}
+
+ test("factorial function with project") {
+ withTable("factorial_input") {
+ sql("CREATE TABLE factorial_input(id INT) USING parquet")
+ sql("""
+ |INSERT INTO factorial_input VALUES
+ |(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)
+ |""".stripMargin)
+
+ val query =
+ """
+ |SELECT
+ | id,
+ | factorial(id)
+ |FROM factorial_input
+ |""".stripMargin
+
+ val expectedResults = Seq(
+ Row(0, 1L),
+ Row(1, 1L),
+ Row(2, 2L),
+ Row(3, 6L),
+ Row(4, 24L),
+ Row(5, 120L),
+ Row(6, 720L),
+ Row(7, 5040L),
+ Row(8, 40320L),
+ Row(9, 362880L),
+ Row(10, 3628800L)
+ )
+
+ runSql(query) {
+ df =>
+ checkGlutenOperatorMatch[ProjectExecTransformer](df)
+ val result = df.collect()
+ assert(result.length == expectedResults.length)
+ assert(result === expectedResults)
+ }
+ }
+ }
}
diff --git a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
index 945f39a061..32997d9fd7 100644
--- a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
+++ b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
@@ -59,7 +59,7 @@ const std::unordered_set<std::string> kRegexFunctions = {
"rlike"};
const std::unordered_set<std::string> kBlackList =
- {"split_part", "factorial", "trunc", "sequence", "approx_percentile",
"get_array_struct_fields", "map_from_arrays"};
+ {"split_part", "trunc", "sequence", "approx_percentile",
"get_array_struct_fields", "map_from_arrays"};
} // namespace
bool SubstraitToVeloxPlanValidator::parseVeloxType(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]