Skip to content
Closed
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 @@ -267,7 +267,7 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan] {
}.unzip3

// Setup expand & aggregate operators for distinct aggregate expressions.
val distinctAggChildAttrLookup = distinctAggChildAttrMap.toMap
val distinctAggChildAttrLookup = distinctAggChildAttrMap.filter(!_._1.foldable).toMap
val distinctAggFilterAttrLookup = Utils.toMap(distinctAggFilters, maxConds.map(_.toAttribute))
val distinctAggOperatorMap = distinctAggGroups.toSeq.zipWithIndex.map {
case ((group, expressions), i) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,16 @@ class DataFrameAggregateSuite extends QueryTest
|""".stripMargin)
checkAnswer(res3, Row(1, 7, 4.5, 1) :: Row(2, 7, 4.5, 2) :: Nil)
}

test("SPARK-41035: Reuse of literal in distinct aggregations should work") {
val res = sql(
"""select a, count(distinct 100), count(distinct b, 100)
|from values (1, 2), (4, 5), (4, 6) as data(a, b)
|group by a;
|""".stripMargin
)
checkAnswer(res, Row(1, 1, 1) :: Row(4, 1, 2) :: Nil)
}
}

case class B(c: Option[Double])
Expand Down