viirya commented on code in PR #38888:
URL: https://github.com/apache/spark/pull/38888#discussion_r1055181848
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala:
##########
@@ -648,13 +648,26 @@ case object UnresolvedSeed extends LeafExpression with
Unevaluable {
/**
* An intermediate expression to hold a resolved (nested) column. Some rules
may need to undo the
- * column resolution and use this expression to keep the original column name.
+ * column resolution and use this expression to keep the original column name,
or redo the column
+ * resolution with a different priority if the analyzer has tried to resolve
it with the default
+ * priority before but failed.
Review Comment:
```suggestion
* resolution with a different priority if the analyzer has tried to resolve
it with the default
* priority before but failed (i.e. `hasTried` is true).
```
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -4245,42 +4230,42 @@ object UpdateOuterReferences extends Rule[LogicalPlan] {
}
/**
- * The rule `ResolveAggregationFunctions` in the main resolution batch creates
- * [[TempResolvedColumn]] in filter conditions and sort expressions to hold
the temporarily resolved
- * column with `agg.child`. When filter conditions or sort expressions are
resolved,
- * `ResolveAggregationFunctions` will replace [[TempResolvedColumn]], to
[[AttributeReference]] if
- * it's inside aggregate functions or group expressions, or to
[[UnresolvedAttribute]] otherwise,
- * hoping other rules can resolve it.
+ * The rule `ResolveReferences` in the main resolution batch creates
[[TempResolvedColumn]] in
+ * UnresolvedHaving/Filter/Sort to hold the temporarily resolved column with
`agg.child`.
*
- * This rule runs after the main resolution batch, and can still hit
[[TempResolvedColumn]] if
- * filter conditions or sort expressions are not resolved. When this happens,
there is no point to
- * turn [[TempResolvedColumn]] to [[UnresolvedAttribute]], as we can't resolve
the column
- * differently, and query will fail. This rule strips all
[[TempResolvedColumn]]s in Filter/Sort and
- * turns them to [[AttributeReference]] so that the error message can tell
users why the filter
- * conditions or sort expressions were not resolved.
+ * If the expression hosting [[TempResolvedColumn]] is fully resolved, the rule
+ * `ResolveAggregationFunctions` will replace [[TempResolvedColumn]] with
[[AttributeReference]] if
+ * it's inside aggregate functions or group expressions, or mark it as
`hasTried` otherwise, hoping
Review Comment:
I'm not sure I read this correctly. `hasTried` will be set to true, if the
expression hosting `TempResolvedColumn` cannot be resolved, OR if it is not
inside aggregate functions or group expressions?
--
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]