Skip to content
Closed
Prev Previous commit
Next Next commit
Update
  • Loading branch information
bersprockets committed Jan 21, 2025
commit 424d80392855d7c15522db21aa2a0813f1031a8a
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,15 @@ object RewritePredicateSubquery extends Rule[LogicalPlan] with PredicateHelper {
val newAggregate = a.copy(aggregateExpressions = newAggregateExpressions)

// Create a projection with the in-subquery expressions that contain aggregates, replacing
// the aggregates with an attribute references to the output of the Aggregate operator.
// Also include the other output of the Aggregate operator.
// the aggregate expressions with attribute references to the output of the Aggregate
// operator. Also include the other output of the Aggregate operator.
val projList = a.aggregateExpressions.map { ae =>
// if this expression contains an in-subquery that uses an aggregate, we
// need to do something special
if (inSubqueryMap.contains(ae)) {
ae.transform {
// patch the aggregate expression with an attribute
case a: AggregateExpression if aggregateExprAttrMap.contains(a) =>
// patch any aggregate expression with its corresponding attribute
case a: AggregateExpression =>
aggregateExprAttrMap(a)
}.asInstanceOf[NamedExpression]
} else {
Expand Down