drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-5952) Implement "CREATE TABLE IF NOT EXISTS"
Date Fri, 17 Nov 2017 06:57:00 GMT

    [ https://issues.apache.org/jira/browse/DRILL-5952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16256566#comment-16256566
] 

ASF GitHub Bot commented on DRILL-5952:
---------------------------------------

Github user prasadns14 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1033#discussion_r151614016
  
    --- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java ---
    @@ -313,6 +313,59 @@ public void createTableWithCustomUmask() throws Exception {
         }
       }
     
    +  @Test // DRILL-5951
    +  public void testCreateTableIfNotExistsWhenTableWithSameNameAlreadyExists() throws Exception{
    +    final String newTblName = "createTableIfNotExistsWhenATableWithSameNameAlreadyExists";
    +
    +    try {
    +      test(String.format("CREATE TABLE %s.%s AS SELECT * from cp.`region.json`", TEMP_SCHEMA,
newTblName));
    +
    +      final String ctasQuery =
    +        String.format("CREATE TABLE IF NOT EXISTS %s.%s AS SELECT * FROM cp.`employee.json`",
TEMP_SCHEMA, newTblName);
    +
    +      testBuilder()
    +        .sqlQuery(ctasQuery)
    +        .unOrdered()
    +        .baselineColumns("ok", "summary")
    +        .baselineValues(false, String.format("A table or view with given name [%s] already
exists in schema [%s]", newTblName, TEMP_SCHEMA))
    +        .go();
    +    } finally {
    +      test(String.format("DROP TABLE %s.%s", TEMP_SCHEMA, newTblName));
    --- End diff --
    
    changed to use drop table if exists


> Implement "CREATE TABLE IF NOT EXISTS"
> --------------------------------------
>
>                 Key: DRILL-5952
>                 URL: https://issues.apache.org/jira/browse/DRILL-5952
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: SQL Parser
>    Affects Versions: 1.11.0
>            Reporter: Prasad Nagaraj Subramanya
>            Assignee: Prasad Nagaraj Subramanya
>             Fix For: Future
>
>
> Currently, if a table/view with the same name exists CREATE TABLE fails with VALIDATION
ERROR
> Having "IF NOT EXISTS" support for CREATE TABLE will ensure that query succeeds 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message