GitHub user gatorsmile opened a pull request:

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

    [SPARK-16678] [SPARK-16677] Fix two View-related bugs

    ### What changes were proposed in this pull request?
    **Issue 1: Disallow Creating a View when the same-name Table Exists**
    When we create a view, we check whether the view already exists. In the 
current implementation, if a table with the same name exists, we treat it as a 
view. However, this is not the right behavior. We should follow what Hive does. 
For example,
    ```
    hive> CREATE TABLE tab1 (id int);
    OK
    Time taken: 0.196 seconds
    hive> CREATE OR REPLACE VIEW tab1 AS SELECT * FROM t1;
    FAILED: SemanticException [Error 10218]: Existing table is not a view
     The following is an existing table, not a view: default.tab1
    ```
    
    **Issue 2: Strange Error when Issuing Load Table Against A View**
    Users should not be allowed to issue LOAD DATA against a view. Currently, 
when users doing it, we got a very strange runtime error. For example,
    ```SQL
    LOAD DATA LOCAL INPATH "$testData" INTO TABLE $viewName
    ```
    ```
    java.lang.reflect.InvocationTargetException was thrown.
    java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at 
org.apache.spark.sql.hive.client.Shim_v0_14.loadTable(HiveShim.scala:680)
    ```
    ### 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 tableDDLAgainstView

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

    https://github.com/apache/spark/pull/14314.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 #14314
    
----
commit d92a95cee8572f631813f259620cc6fe2644ed36
Author: gatorsmile <gatorsm...@gmail.com>
Date:   2016-07-22T03:48:50Z

    fix.

commit 5c9be1438e57722dbcea7a77993df636394cd9bf
Author: gatorsmile <gatorsm...@gmail.com>
Date:   2016-07-22T04:13:28Z

    changed the test case names.

----


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