Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4068#discussion_r23747469
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -285,11 +285,22 @@ class Analyzer(catalog: Catalog,
                 result
     
               // Resolve field names using the resolver.
    -          case f @ GetField(child, fieldName) if !f.resolved && 
child.resolved =>
    +          case f @ GetField(child, fieldName) if child.resolved =>
                 child.dataType match {
                   case StructType(fields) =>
    -                val resolvedFieldName = 
fields.map(_.name).find(resolver(_, fieldName))
    -                resolvedFieldName.map(n => f.copy(fieldName = 
n)).getOrElse(f)
    +                val actualField = fields.filter(f => resolver(f.name, 
fieldName))
    +                if (actualField.length == 0) {
    +                  sys.error(
    +                    s"No such struct field $fieldName in 
${fields.map(_.name).mkString(", ")}")
    --- End diff --
    
    As I said before, we need `Resolver` to check the existence of desired 
field. However, we can't get it inside `GetField`, that's why we also did this 
check in `LogicalPlan.resolveNesting`.
    And we build `GetField` in `SqlParser`, so it's hard to put `Resolver` into 
`GetField` during building.



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