ulysses-you commented on code in PR #44352:
URL: https://github.com/apache/spark/pull/44352#discussion_r1427477125


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala:
##########
@@ -323,12 +323,14 @@ trait ColumnResolutionHelper extends Logging with 
DataTypeErrorsBase {
   }
 
   // Resolves `UnresolvedAttribute` to `TempResolvedColumn` via 
`plan.child.output` if plan is an
-  // `Aggregate`. If `TempResolvedColumn` doesn't end up as aggregate function 
input or grouping
-  // column, we will undo the column resolution later to avoid confusing error 
message. E,g,, if
+  // `Aggregate` or `Filter(_, Aggregate)`.
+  // If `TempResolvedColumn` doesn't end up as aggregate function input or 
grouping
+  // column, we will undo the column resolution later to avoid confusing error 
message. E.g., if
   // a table `t` has columns `c1` and `c2`, for query `SELECT ... FROM t GROUP 
BY c1 HAVING c2 = 0`,
   // even though we can resolve column `c2` here, we should undo it and fail 
with
   // "Column c2 not found".
   protected def resolveColWithAgg(e: Expression, plan: LogicalPlan): 
Expression = plan match {
+    case Filter(_, agg: Aggregate) => resolveColWithAgg(e, agg)

Review Comment:
   Cann we move this into `ResolveReferencesInSort`. I think it is more clearer 
to make the call side resolve aggregate through filter.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to