Skip to content

Commit

Permalink
[VL] Support Sum(Literal)/Count(Literal) with empty input schema (#6631)
Browse files Browse the repository at this point in the history
  • Loading branch information
zml1206 authored Jul 31, 2024
1 parent decd8b4 commit cff5de5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit cff5de5

Please sign in to comment.