tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blrun...@apache.org
Subject tajo git commit: TAJO-1727: Avoid to create external table using TableSpace.
Date Thu, 10 Sep 2015 21:20:38 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 508d17a2d -> 238f0b366


TAJO-1727: Avoid to create external table using TableSpace.

Closes #732


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/238f0b36
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/238f0b36
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/238f0b36

Branch: refs/heads/master
Commit: 238f0b3662b919e9b20bdc0bcda647c0d0650ffc
Parents: 508d17a
Author: JaeHwa Jung <blrunner@apache.org>
Authored: Fri Sep 11 06:17:43 2015 +0900
Committer: JaeHwa Jung <blrunner@apache.org>
Committed: Fri Sep 11 06:17:43 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |  2 ++
 .../engine/planner/TestQueryValidation.java     | 21 ++++++++++++++++++++
 .../create_external_table_with_tablespace.sql   |  1 +
 .../create_external_table_without_location.sql  |  1 +
 .../org/apache/tajo/parser/sql/SQLAnalyzer.java |  6 ++++++
 5 files changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/238f0b36/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 250a612..a6e8d0a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -257,6 +257,8 @@ Release 0.11.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1727: Avoid to create external table using TableSpace. (jaehwa)
+
     TAJO-1600: Invalid query planning for distinct group-by. (hyunsik)
 
     TAJO-1782: Check ON_ERROR_STOP flag in TSQL when error is occured. 

http://git-wip-us.apache.org/repos/asf/tajo/blob/238f0b36/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java
b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java
index f2e8e64..cb299b4 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java
@@ -19,11 +19,16 @@
 package org.apache.tajo.engine.planner;
 
 import org.apache.tajo.QueryTestCaseBase;
+import org.apache.tajo.exception.SQLSyntaxError;
 import org.junit.Test;
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
 
 import java.io.IOException;
 
 public class TestQueryValidation extends QueryTestCaseBase {
+  @Rule
+  public ExpectedException exception = ExpectedException.none();
 
   @Test
   public void testInsertWithWrongTargetColumn() throws Exception {
@@ -62,4 +67,20 @@ public class TestQueryValidation extends QueryTestCaseBase {
     // See TAJO-1249
     assertInvalidSQLFromFile("invalid_store_format.sql");
   }
+
+  @Test
+  public void testCreateExternalTableWithTablespace() throws Exception {
+    exception.expect(SQLSyntaxError.class);
+    exception.expectMessage("Tablespace clause is not allowed for an external table.");
+
+    executeFile("create_external_table_with_tablespace.sql");
+  }
+
+  @Test
+  public void testCreateExternalTableWithoutLocation() throws Exception {
+    exception.expect(SQLSyntaxError.class);
+    exception.expectMessage("LOCATION clause must be required for an external table.");
+
+    executeFile("create_external_table_without_location.sql");
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/238f0b36/tajo-core-tests/src/test/resources/queries/TestQueryValidation/create_external_table_with_tablespace.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestQueryValidation/create_external_table_with_tablespace.sql
b/tajo-core-tests/src/test/resources/queries/TestQueryValidation/create_external_table_with_tablespace.sql
new file mode 100644
index 0000000..440d976
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestQueryValidation/create_external_table_with_tablespace.sql
@@ -0,0 +1 @@
+CREATE EXTERNAL TABLE hbase_blog (rowkey text, author text, register_date text, title text)
 TABLESPACE hbasecluster1 USING hbase WITH ('table'='blog', 'columns'=':key,info:author,info:date,content:title')
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/238f0b36/tajo-core-tests/src/test/resources/queries/TestQueryValidation/create_external_table_without_location.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestQueryValidation/create_external_table_without_location.sql
b/tajo-core-tests/src/test/resources/queries/TestQueryValidation/create_external_table_without_location.sql
new file mode 100644
index 0000000..8e19709
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestQueryValidation/create_external_table_without_location.sql
@@ -0,0 +1 @@
+CREATE EXTERNAL TABLE table1 (id int, str text, num int) using text
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/238f0b36/tajo-core/src/main/java/org/apache/tajo/parser/sql/SQLAnalyzer.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/parser/sql/SQLAnalyzer.java b/tajo-core/src/main/java/org/apache/tajo/parser/sql/SQLAnalyzer.java
index 188a4f5..793cb1c 100644
--- a/tajo-core/src/main/java/org/apache/tajo/parser/sql/SQLAnalyzer.java
+++ b/tajo-core/src/main/java/org/apache/tajo/parser/sql/SQLAnalyzer.java
@@ -1285,6 +1285,10 @@ public class SQLAnalyzer extends SQLParserBaseVisitor<Expr> {
     if (checkIfExist(ctx.EXTERNAL())) {
       createTable.setExternal();
 
+      if (checkIfExist(ctx.TABLESPACE())) {
+        throw new TajoRuntimeException(new SQLSyntaxError("Tablespace clause is not allowed
for an external table."));
+      }
+
       ColumnDefinition[] elements = getDefinitions(ctx.table_elements());
       String storageType = ctx.storage_type.getText();
       createTable.setTableElements(elements);
@@ -1293,6 +1297,8 @@ public class SQLAnalyzer extends SQLParserBaseVisitor<Expr> {
       if (checkIfExist(ctx.LOCATION())) {
         String uri = stripQuote(ctx.uri.getText());
         createTable.setLocation(uri);
+      } else {
+        throw new TajoRuntimeException(new SQLSyntaxError("LOCATION clause must be required
for an external table."));
       }
     } else {
       if (checkIfExist(ctx.table_elements())) {


Mime
View raw message