spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From viirya <>
Subject [GitHub] spark pull request: [SPARK-6145] [SQL] Fix the bug of nested data ...
Date Thu, 05 Mar 2015 11:49:25 GMT
Github user viirya commented on a diff in the pull request:
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
    @@ -192,14 +193,17 @@ abstract class LogicalPlan extends QueryPlan[LogicalPlan] with Logging
           // One match, but we also need to extract the requested nested field.
           case Seq((a, nestedFields)) =>
    -        // The foldLeft adds UnresolvedGetField for every remaining parts of the name,
    -        // and aliased it with the last part of the name.
    -        // For example, consider name "a.b.c", where "a" is resolved to an existing attribute.
    -        // Then this will add UnresolvedGetField("b") and UnresolvedGetField("c"), and
    -        // the final expression as "c".
    -        val fieldExprs = nestedFields.foldLeft(a: Expression)(UnresolvedGetField)
    -        val aliasName = nestedFields.last
    -        Some(Alias(fieldExprs, aliasName)())
    +        // The foldLeft will resolve all of the nested data type, to get its attributes.
    +        val fieldExprs = nestedFields.foldLeft(a: Expression) { case (e, fieldName) =>
    +          resolveGetField(e, fieldName, resolver)
    +        }
    +        // TODO the alias name is quite tricky to me, set it to _col1, _col2.. ?
    +        // Set it as original attribute name like "a.b.c" seems still confusing,
    +        // and we may never reference this column by its name (with "."), except
    +        // people write SQL like: SELECT a.b.c as newCol FROM nestedTable, which
    +        // explicitly specifying the alias name for the output column
    +        Some(Alias(fieldExprs, name)())
    --- End diff --
    I meant should it be that? In Hive it should be `c` instead of `a.b.c`?

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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message