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 cff5de5f4 [VL] Support Sum(Literal)/Count(Literal) with empty input 
schema (#6631)
cff5de5f4 is described below

commit cff5de5f4d90e4a2ec89c096cc1f0d1db95abc85
Author: Mingliang Zhu <[email protected]>
AuthorDate: Wed Jul 31 11:44:39 2024 +0800

    [VL] Support Sum(Literal)/Count(Literal) with empty input schema (#6631)
---
 .../scala/org/apache/gluten/backendsapi/velox/VeloxBackend.scala    | 6 +++---
 .../org/apache/gluten/execution/ScalarFunctionsValidateSuite.scala  | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git 
a/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxBackend.scala
 
b/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxBackend.scala
index 990991c71..0eb612687 100644
--- 
a/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxBackend.scala
+++ 
b/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxBackend.scala
@@ -438,13 +438,13 @@ object VeloxBackendSettings extends BackendSettingsApi {
 
     plan match {
       case exec: HashAggregateExec if exec.aggregateExpressions.nonEmpty =>
-        // Check Sum(1) or Count(1).
+        // Check Sum(Literal) or Count(Literal).
         exec.aggregateExpressions.forall(
           expression => {
             val aggFunction = expression.aggregateFunction
             aggFunction match {
-              case _: Sum | _: Count =>
-                aggFunction.children.size == 1 && 
aggFunction.children.head.equals(Literal(1))
+              case Sum(Literal(_, _), _) => true
+              case Count(Seq(Literal(_, _))) => true
               case _ => false
             }
           })
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 13ade14b5..897c1c5f5 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
@@ -754,6 +754,12 @@ abstract class ScalarFunctionsValidateSuite extends 
FunctionsValidateTest {
     }
   }
 
+  test("Test sum/count function") {
+    runQueryAndCompare("""SELECT sum(2),count(2) from lineitem""".stripMargin) 
{
+      checkGlutenOperatorMatch[BatchScanExecTransformer]
+    }
+  }
+
   test("Test spark_partition_id function") {
     runQueryAndCompare("""SELECT spark_partition_id(), l_orderkey
                          | from lineitem limit 100""".stripMargin) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to