AngersZhuuuu commented on a change in pull request #28490:
URL: https://github.com/apache/spark/pull/28490#discussion_r480987402
##########
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:
+ // 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,
+ q: LogicalPlan,
+ trimAlias: Boolean = false,
+ isTopLevel: Boolean = true): Expression = {
Review comment:
> this parameter doesn't need a default value.
Done
##########
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:
+ // 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,
+ q: LogicalPlan,
Review comment:
> inner method can access the parameters of outer method. We don't need
this parameter.
Done
----------------------------------------------------------------
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]