GitHub user gatorsmile opened a pull request:

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

    [SPARK-15655] [SQL] Fix Wrong Partition Column Order when Fetching 
Partitioned Tables

    #### What changes were proposed in this pull request?
    When fetching the partitioned table, the output contains wrong results. The 
order of partition key values do not match the order of partition key columns 
in output schema. For example, 
    
    ```SQL
    CREATE TABLE table_with_partition(c1 string) PARTITIONED BY (p1 string,p2 
string,p3 string,p4 string,p5 string)
    INSERT OVERWRITE TABLE table_with_partition PARTITION 
(p1='a',p2='b',p3='c',p4='d',p5='e') SELECT 'blarr'
    SELECT p1, p2, p3, p4, p5, c1 FROM table_with_partition
    ```
    ```
    +---+---+---+---+---+-----+
    | p1| p2| p3| p4| p5|   c1|
    +---+---+---+---+---+-----+
    |  d|  e|  c|  b|  a|blarr|
    +---+---+---+---+---+-----+
    ```
    
    This PR is to fix this by enforcing the order matches the table partition 
definition.
    
    #### How was this patch tested?
    Added a test case in `SQLQuerySuite`

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

    $ git pull https://github.com/gatorsmile/spark partitionedTableFetch

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

    https://github.com/apache/spark/pull/13400.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 #13400
    
----
commit cd316b13885cb4ba5c18988f72b812cd98783d30
Author: gatorsmile <[email protected]>
Date:   2016-05-30T23:40:48Z

    fix

commit 5bc89966765e1ec37b7c8d167ac6156988a9a720
Author: gatorsmile <[email protected]>
Date:   2016-05-30T23:48:09Z

    more test

----


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

Reply via email to