Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/9055#discussion_r42581802
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -408,6 +552,25 @@ class Analyzer(
}
}
+ // Try to resolve the attributes from the given logical plan
+ def tryResolveAttributes(expr: Expression, q: LogicalPlan): Expression
= {
+ checkAnalysis(q)
+ val projection = Project(q.output, q)
+
+ logTrace(s"Attempting to resolve ${expr.simpleString}")
+ expr transformUp {
+ case u @ UnresolvedAlias(expr) => expr
+ case u @ UnresolvedAttribute(nameParts) =>
+ // Leave unchanged if resolution fails. Hopefully will be
resolved next round.
+ val result =
+ withPosition(u) { projection.resolveChildren(nameParts,
resolver).getOrElse(u) }
+ logDebug(s"Resolving $u to $result")
+ result
+ case UnresolvedExtractValue(child, fieldExpr) if child.resolved =>
+ ExtractValue(child, fieldExpr, resolver)
+ }
+ }
+
--- End diff --
Should we just use the resolve method of a logical plan?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]