Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VL] Support Sum(Literal)/Count(Literal) with empty input schema #6631

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading