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

    https://github.com/apache/spark/pull/4068#discussion_r23665510
  
    --- 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 --
    
    I think `CheckResolution` should catch it. If we cannot resolve it, just 
leave it unchanged. Can you see if there is a unit test for this? If not, can 
you add one? Maybe we can also log it like what `LogicalPlan.resolve` does.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to