drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sor...@apache.org
Subject [drill] 02/08: DRILL-7167: Implemented DESCRIBE TABLE statement
Date Fri, 03 May 2019 22:46:28 GMT
This is an automated email from the ASF dual-hosted git repository.

sorabh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit 878cfc033de4343e23f1422bb8845d5c6d892618
Author: Dmytriy Grinchenko <dmytriy.grinchenko@gmail.com>
AuthorDate: Fri Apr 12 10:24:17 2019 +0300

    DRILL-7167: Implemented DESCRIBE TABLE statement
    
    - altered parser implementation to honor DESCRIBE TABLE syntax
    - extended test coverage to check the new statement
    closes #1747
---
 .../src/main/codegen/includes/parserImpls.ftl      |  3 +-
 .../org/apache/drill/exec/sql/TestInfoSchema.java  | 62 +++++++++++++++++++++-
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/exec/java-exec/src/main/codegen/includes/parserImpls.ftl b/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
index 9ba92f2..25ee72b 100644
--- a/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
+++ b/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
@@ -106,7 +106,7 @@ SqlNode SqlShowSchemas() :
 
 /**
  * Parses statement
- *   { DESCRIBE | DESC } tblname [col_name | wildcard ]
+ *   { DESCRIBE | DESC } [TABLE] tblname [col_name | wildcard ]
  */
 SqlNode SqlDescribeTable() :
 {
@@ -117,6 +117,7 @@ SqlNode SqlDescribeTable() :
 }
 {
     (<DESCRIBE> | <DESC>) { pos = getPos(); }
+    (<TABLE>)?
     table = CompoundIdentifier()
     (
         column = CompoundIdentifier()
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java
index ee89c5c..f437776 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java
@@ -184,6 +184,16 @@ public class TestInfoSchema extends BaseTestQuery {
   }
 
   @Test
+  public void describeTableWithTableKeyword() throws Exception {
+    test("USE INFORMATION_SCHEMA");
+    testBuilder()
+        .sqlQuery("DESCRIBE TABLE CATALOGS")
+        .unOrdered()
+        .sqlBaselineQuery("DESCRIBE CATALOGS")
+        .go();
+  }
+
+  @Test
   public void describeTableWithSchema() throws Exception{
     testBuilder()
         .sqlQuery("DESCRIBE INFORMATION_SCHEMA.`TABLES`")
@@ -197,6 +207,15 @@ public class TestInfoSchema extends BaseTestQuery {
   }
 
   @Test
+  public void describeTableWithSchemaAndTableKeyword() throws Exception {
+    testBuilder()
+        .sqlQuery("DESCRIBE TABLE INFORMATION_SCHEMA.`TABLES`")
+        .unOrdered()
+        .sqlBaselineQuery("DESCRIBE INFORMATION_SCHEMA.`TABLES`")
+        .go();
+  }
+
+  @Test
   public void describeWhenSameTableNameExistsInMultipleSchemas() throws Exception{
     try {
       test("USE dfs.tmp");
@@ -220,7 +239,29 @@ public class TestInfoSchema extends BaseTestQuery {
           .baselineValues("TABLE_TYPE", "CHARACTER VARYING", "NO")
           .go();
     } finally {
-      test("DROP VIEW dfs.tmp.`TABLES`");
+      test("DROP VIEW IF EXISTS dfs.tmp.`TABLES`");
+    }
+  }
+
+  @Test
+  public void describeWhenSameTableNameExistsInMultipleSchemasWithTableKeyword() throws Exception
{
+    try {
+      test("USE dfs.tmp");
+      test("CREATE OR REPLACE VIEW `TABLES` AS SELECT full_name FROM cp.`employee.json`");
+
+      testBuilder()
+          .sqlQuery("DESCRIBE TABLE `TABLES`")
+          .unOrdered()
+          .sqlBaselineQuery("DESCRIBE `TABLES`")
+          .go();
+
+      testBuilder()
+          .sqlQuery("DESCRIBE TABLE INFORMATION_SCHEMA.`TABLES`")
+          .unOrdered()
+          .sqlBaselineQuery("DESCRIBE INFORMATION_SCHEMA.`TABLES`")
+          .go();
+    } finally {
+      test("DROP VIEW IF EXISTS dfs.tmp.`TABLES`");
     }
   }
 
@@ -236,6 +277,16 @@ public class TestInfoSchema extends BaseTestQuery {
   }
 
   @Test
+  public void describeTableWithColumnNameAndTableKeyword() throws Exception {
+    test("USE INFORMATION_SCHEMA");
+    testBuilder()
+        .sqlQuery("DESCRIBE TABLE `TABLES` TABLE_CATALOG")
+        .unOrdered()
+        .sqlBaselineQuery("DESCRIBE `TABLES` TABLE_CATALOG")
+        .go();
+  }
+
+  @Test
   public void describeTableWithSchemaAndColumnName() throws Exception{
     testBuilder()
         .sqlQuery("DESCRIBE INFORMATION_SCHEMA.`TABLES` TABLE_CATALOG")
@@ -246,6 +297,15 @@ public class TestInfoSchema extends BaseTestQuery {
   }
 
   @Test
+  public void describeTableWithSchemaAndColumnNameAndTableKeyword() throws Exception {
+    testBuilder()
+        .sqlQuery("DESCRIBE TABLE INFORMATION_SCHEMA.`TABLES` TABLE_CATALOG")
+        .unOrdered()
+        .sqlBaselineQuery("DESCRIBE INFORMATION_SCHEMA.`TABLES` TABLE_CATALOG")
+        .go();
+  }
+
+  @Test
   public void describeTableWithColQualifier() throws Exception{
     testBuilder()
         .sqlQuery("DESCRIBE COLUMNS 'TABLE%'")


Mime
View raw message