Skip to content

Commit

Permalink
fix: incorrect result with aggregate expression with filter (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya authored Apr 18, 2024
1 parent 4710d62 commit 4da74d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,11 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde {
return None
}

// Aggregate expressions with filter are not supported yet.
if (aggregateExpressions.exists(_.filter.isDefined)) {
return None
}

val groupingExprs = groupingExpressions.map(exprToProto(_, child.output))

// In some of the cases, the aggregateExpressions could be empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ import org.apache.comet.CometSparkSessionExtensions.isSpark34Plus
class CometAggregateSuite extends CometTestBase with AdaptiveSparkPlanHelper {
import testImplicits._

test("count with aggregation filter") {
withSQLConf(
CometConf.COMET_ENABLED.key -> "true",
CometConf.COMET_EXEC_SHUFFLE_ENABLED.key -> "true",
CometConf.COMET_COLUMNAR_SHUFFLE_ENABLED.key -> "true") {
val df1 = sql("SELECT count(DISTINCT 2), count(DISTINCT 2,3)")
checkSparkAnswer(df1)

val df2 = sql("SELECT count(DISTINCT 2), count(DISTINCT 3,2)")
checkSparkAnswer(df2)
}
}

test("lead/lag should return the default value if the offset row does not exist") {
withSQLConf(
CometConf.COMET_ENABLED.key -> "true",
Expand Down

0 comments on commit 4da74d8

Please sign in to comment.