GitHub user gatorsmile opened a pull request:

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

    [SPARK-16368] [SQL] Fix Strange Errors When Creating View With Unmatched 
Column Num

    #### What changes were proposed in this pull request?
    When creating a view, a common user error is the number of columns produced 
by the `SELECT` clause does not match the number of column names specified by 
`CREATE VIEW`.
    
    For example, given Table `t1` only has 3 columns
    ```SQL
    create view v1(col2, col4, col3, col5) as select * from t1
    ```
    Currently, Spark SQL reports the following error:
    ```
    requirement failed
    java.lang.IllegalArgumentException: requirement failed
        at scala.Predef$.require(Predef.scala:212)
        at 
org.apache.spark.sql.execution.command.CreateViewCommand.run(views.scala:90)
    ```
    
    This error message is very confusing. This PR is to detect the error and 
issue a meaningful error message.
    
    #### How was this patch tested?
    Added test cases

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

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

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

    https://github.com/apache/spark/pull/14047.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 #14047
    
----
commit 6210568c98e4e57e75fbf79fdefc40f258b5123e
Author: gatorsmile <[email protected]>
Date:   2016-07-04T18:38:20Z

    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