GitHub user liancheng opened a pull request:

    https://github.com/apache/spark/pull/3248

    [SPARK-4322][SQL] Enables struct fields as sub expressions of grouping 
fields

    While resolving struct fields, the resulted `GetField` expression is 
wrapped with an `Alias` to make it a named expression. Assume `a` is a struct 
instance with a field `b`, then `"a.b"` will be resolved as `Alias(GetField(a, 
"b"), "b")`. Thus, for this following SQL query:
    
    ```sql
    SELECT a.b + 1 FROM t GROUP BY a.b + 1
    ```
    
    the grouping expression is
    
    ```scala
    Add(GetField(a, "b"), Literal(1, IntegerType))
    ```
    
    while the aggregation expression is
    
    ```scala
    Add(Alias(GetField(a, "b"), "b"), Literal(1, IntegerType))
    ```
    
    This mismatch makes the above SQL query fail during the both analysis and 
execution phases. This PR fixes this issue by removing the alias when 
substituting aggregation expressions.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/liancheng/spark spark-4322

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/3248.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3248
    
----
commit 7f4653246647b32299b0f48414391323fcd4273a
Author: Cheng Lian <l...@databricks.com>
Date:   2014-11-13T16:34:09Z

    Enables struct fields as sub expressions of grouping fields

----


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