GitHub user gatorsmile opened a pull request:

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

    [SPARK-17693] [SQL] Fixed Insert Failure To Data Source Tables when the 
Schema has the Comment Field - Solution 2

    ### What changes were proposed in this pull request?
    ```SQL
    CREATE TABLE tab1(col1 int COMMENT 'a', col2 int) USING parquet
    INSERT INTO TABLE tab1 SELECT 1, 2
    ```
    The insert attempt will fail if the target table has a column with 
comments. The error is strange to the external users:
    ```
    assertion failed: No plan for InsertIntoTable Relation[col1#15,col2#16] 
parquet, false, false
    +- Project [1 AS col1#19, 2 AS col2#20]
       +- OneRowRelation$
    ```
    
    This PR is to fix the above bug by checking the metadata when comparing the 
schema between the table and the query. If not matched, we also copy the 
metadata. This is an alternative to https://github.com/apache/spark/pull/15266
    
    ### How was this patch tested?
    Added a test case

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

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

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

    https://github.com/apache/spark/pull/15615.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 #15615
    
----
commit 88e7743b12d5cc5fd93898b72f78fcb2fcf5feef
Author: gatorsmile <[email protected]>
Date:   2016-10-24T19:52:47Z

    fix.

----


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