Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/4068#discussion_r23746914
--- 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 --
ok I see. With your change, the `resolved` field will always be true as
long as its child's `resolved` is true (the existence of the desired field is
not considered). Actually, we are breaking the semantic of `resolved` at here.
I do think checking ambiguity is necessary, but I think it is also necessary to
follow the definition of `resolved`.
I am sorry if I missed it. Can you explain why you prefer not to put this
check in `GetField`?
---
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]