Github user scwf commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4558#discussion_r24568336
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -66,32 +66,81 @@ class Analyzer(catalog: Catalog,
           typeCoercionRules ++
           extendedRules : _*),
         Batch("Check Analysis", Once,
    -      CheckResolution ::
    -      CheckAggregation ::
    -      Nil: _*),
    -    Batch("AnalysisOperators", fixedPoint,
    -      EliminateAnalysisOperators)
    +      CheckResolution),
    +    Batch("Remove SubQueries", fixedPoint,
    +      EliminateSubQueries)
       )
     
       /**
        * Makes sure all attributes and logical plans have been resolved.
        */
       object CheckResolution extends Rule[LogicalPlan] {
    +    def failAnalysis(msg: String) = { throw new AnalysisException(msg) }
    +
         def apply(plan: LogicalPlan): LogicalPlan = {
    -      plan.transformUp {
    -        case p if p.expressions.exists(!_.resolved) =>
    -          val missing = 
p.expressions.filterNot(_.resolved).map(_.prettyString).mkString(",")
    -          val from = p.inputSet.map(_.name).mkString("{", ", ", "}")
    -
    -          throw new AnalysisException(s"Cannot resolve '$missing' given 
input columns $from")
    -        case p if !p.resolved && p.childrenResolved =>
    -          throw new AnalysisException(s"Unresolved operator in the query 
plan ${p.simpleString}")
    -      } match {
    -        // As a backstop, use the root node to check that the entire plan 
tree is resolved.
    -        case p if !p.resolved =>
    -          throw new AnalysisException(s"Unresolved operator in the query 
plan ${p.simpleString}")
    -        case p => p
    +      // We transform up and order the rules so as to catch the first 
possible failure instead
    +      // of the result of cascading resolution failures.
    +      plan.foreachUp {
    +        case operator: LogicalPlan =>
    +          operator transformAllExpressions {
    --- End diff --
    
    we can use transformExpressionsUp here to cover the case of ``` SELECT 
CAST(x AS STRING) FROM src```


---
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]

Reply via email to