drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [3/8] drill git commit: DRILL-5215: CTTAS: disallow temp tables in view expansion logic
Date Sat, 04 Feb 2017 03:58:53 GMT
DRILL-5215: CTTAS: disallow temp tables in view expansion logic

This closes #725


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/63ae6cff
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/63ae6cff
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/63ae6cff

Branch: refs/heads/master
Commit: 63ae6cffc23f1de8159217da9a8879b9ffb86423
Parents: 0520101
Author: Arina Ielchiieva <arina.yelchiyeva@gmail.com>
Authored: Tue Jan 24 12:33:11 2017 +0000
Committer: Parth Chandra <pchandra@maprtech.com>
Committed: Fri Feb 3 17:41:13 2017 -0800

----------------------------------------------------------------------
 .../src/resources/drill-override-example.conf   |  3 +--
 .../drill/exec/planner/sql/SqlConverter.java    |  1 +
 .../org/apache/drill/exec/sql/TestCTTAS.java    | 26 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/63ae6cff/distribution/src/resources/drill-override-example.conf
----------------------------------------------------------------------
diff --git a/distribution/src/resources/drill-override-example.conf b/distribution/src/resources/drill-override-example.conf
index 3baac5e..43f9942 100644
--- a/distribution/src/resources/drill-override-example.conf
+++ b/distribution/src/resources/drill-override-example.conf
@@ -185,8 +185,7 @@ drill.exec: {
       root: "/app/drill"
     }
   },
-  # Settings for Temporary Tables.
-  # See https://gist.github.com/arina-ielchiieva/50158175867a18eee964b5ba36455fbf#file-temporarytablessupport-md.
+  # Settings for Temporary Tables (see https://issues.apache.org/jira/browse/DRILL-4956 for
details).
   # Temporary table can be created ONLY in default temporary workspace.
   # Full workspace name should be indicated (including schema and workspace separated by
dot).
   # Workspace MUST be file-based and writable. Workspace name is case-sensitive.

http://git-wip-us.apache.org/repos/asf/drill/blob/63ae6cff/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
index 28196c1..d20fc06 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
@@ -333,6 +333,7 @@ public class SqlConverter {
     }
 
     private RelNode expandView(String queryString, SqlConverter converter) {
+      converter.disallowTemporaryTables();
       final SqlNode parsedNode = converter.parse(queryString);
       final SqlNode validatedNode = converter.validate(parsedNode);
       return converter.toRel(validatedNode);

http://git-wip-us.apache.org/repos/asf/drill/blob/63ae6cff/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java
index 93c8cad..5d83beb 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java
@@ -338,6 +338,32 @@ public class TestCTTAS extends BaseTestQuery {
     }
   }
 
+  @Test(expected = UserRemoteException.class)
+  public void testTemporaryTablesInViewExpansionLogic() throws Exception {
+    String tableName = "table_for_expansion_logic_test";
+    String viewName = "view_for_expansion_logic_test";
+    test("use %s", TEMP_SCHEMA);
+    test("create table %s as select 'TABLE' as c1 from (values(1))", tableName);
+    test("create view %s as select * from %s", viewName, tableName);
+
+    testBuilder()
+        .sqlQuery("select * from %s", viewName)
+        .unOrdered()
+        .baselineColumns("c1")
+        .baselineValues("TABLE")
+        .go();
+
+    test("drop table %s", tableName);
+    test("create temporary table %s as select 'TEMP' as c1 from (values(1))", tableName);
+    try {
+      test("select * from %s", viewName);
+    } catch (UserRemoteException e) {
+      assertThat(e.getMessage(), containsString(String.format(
+          "VALIDATION ERROR: Temporary tables usage is disallowed. Used temporary table name:
[%s]", tableName)));
+      throw e;
+    }
+  }
+
   @Test
   public void testManualDropWithoutSchema() throws Exception {
     String temporaryTableName = "temporary_table_to_drop_without_schema";


Mime
View raw message