GitHub user maropu opened a pull request:

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

    [SPARK-17237][SQL] Remove backticks in a pivot result schema

    ## What changes were proposed in this pull request?
    Pivoting adds backticks (e.g. 3_count(\`c\`)) in column names and, in some 
cases,
    thes causes analysis exceptions  like;
    ```
    scala> val df = Seq((2, 3, 4), (3, 4, 5)).toDF("a", "x", "y")
    scala> df.groupBy("a").pivot("x").agg(count("y"), avg("y")).na.fill(0)
    org.apache.spark.sql.AnalysisException: syntax error in attribute name: 
`3_count(`y`)`;
      at 
org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute$.e$1(unresolved.scala:134)
      at 
org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute$.parseAttributeName(unresolved.scala:144)
    ...
    ```
    So, this pr proposes to remove these backticks from column names.
    
    This is a backport pr coming from #14812.
    
    ## How was this patch tested?
    Added a test in `DataFrameAggregateSuite`.


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

    $ git pull https://github.com/maropu/spark SPARK-17237-3

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

    https://github.com/apache/spark/pull/16565.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 #16565
    
----
commit 875e2c07a66ac9c0c1d4ab111870209f80d5410c
Author: Takeshi YAMAMURO <linguin....@gmail.com>
Date:   2016-08-25T19:17:50Z

    Fix a bug to handle missing data after pivoting

----


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