AngersZhuuuu commented on a change in pull request #28490:
URL: https://github.com/apache/spark/pull/28490#discussion_r480974176
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -1326,24 +1326,49 @@ class Analyzer(
* Note : In this routine, the unresolved attributes are resolved from the
input plan's
* children attributes.
*/
- private def resolveExpressionTopDown(e: Expression, q: LogicalPlan):
Expression = {
- if (e.resolved) return e
- e match {
- case f: LambdaFunction if !f.bound => f
- case u @ UnresolvedAttribute(nameParts) =>
- // Leave unchanged if resolution fails. Hopefully will be resolved
next round.
- val result =
- withPosition(u) {
- q.resolveChildren(nameParts, resolver)
- .orElse(resolveLiteralFunction(nameParts, u, q))
- .getOrElse(u)
+ private def resolveExpressionTopDown(
+ e: Expression,
+ q: LogicalPlan,
+ trimAlias: Boolean = false): Expression = {
+
+ // Explain for param trimAlias and isTopLevel:
Review comment:
> The previous parameter doc of `resolveExpressionTopDown` is good. Why
we turn it to comment here?
Since we don't have isTopLevel param in `resolveExpressionTopDow`. emm how
about
```
* @param e the expression need to be resolved.
* @param q the LogicalPlan whose children are used to resolve
expression's attribute.
* @param trimAlias whether need to trim alias of Struct field. When
true, we will trim
* Struct field alias. When isTopLevel = true, we won't
trim top-level
* Struct field alias.
* @return resolved Expression.
*/
private def resolveExpressionTopDown(
e: Expression,
q: LogicalPlan,
trimAlias: Boolean = false): Expression = {
// Explain for param trimAlias and isTopLevel:
// 1. trimAlias = false:
// We won't trim Struct Field alias.
// 2. trimAlias = true && isTopLevel = false:
// We will trim all Struct field alias.
// 3. trimAlias = true && isTopLevel = true
// Trim unnecessary alias of `GetStructField`. Note that, we cannot
trim the alias of
// top-level `GetStructField`, as we should resolve
`UnresolvedAttribute` to a named
// expression. The caller side can trim the alias of top-level
`GetStructField` if needed.
def innerResolve(
e: Expression,
isTopLevel: Boolean): Expression = {
if (e.resolved) return e
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]