TAJO-1249: Tajo should check if a file format given in DDL is supported. (DaeMyung Kang via hyunsik)
Closes #313 Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/09cad22e Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/09cad22e Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/09cad22e Branch: refs/heads/index_support Commit: 09cad22ee2f7c30a0f28ebe50e00612777e69c86 Parents: c39ed5d Author: Hyunsik Choi <[email protected]> Authored: Wed Dec 24 15:07:44 2014 +0900 Committer: Hyunsik Choi <[email protected]> Committed: Wed Dec 24 15:07:44 2014 +0900 ---------------------------------------------------------------------- CHANGES | 7 +++++-- .../apache/tajo/engine/eval/TestPredicates.java | 7 ------- .../tajo/engine/planner/TestQueryValidation.java | 6 ++++++ .../TestQueryValidation/invalid_store_format.sql | 1 + .../plan/verifier/PreLogicalPlanVerifier.java | 18 ++++++++++++++---- 5 files changed, 26 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/09cad22e/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 1bc8b9e..23d34d4 100644 --- a/CHANGES +++ b/CHANGES @@ -120,11 +120,14 @@ Release 0.9.1 - unreleased BUG FIXES + TAJO-1249: Tajo should check if a file format given in DDL is supported. + (DaeMyung Kang via hyunsik) + TAJO-1250: RawFileAppender occasionally causes BufferOverflowException. (jinho) - TAJO-1259: A title in catalog configuration document is different from others. - (Jongyoung Park via hyunsik) + TAJO-1259: A title in catalog configuration document is different from + others. (Jongyoung Park via hyunsik) TAJO-1232: Implicit groupby queries with LIMIT lead to wrong results. (jihoon) http://git-wip-us.apache.org/repos/asf/tajo/blob/09cad22e/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java b/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java index 79a287b..94d5e71 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java @@ -403,11 +403,4 @@ public class TestPredicates extends ExprTestBase { testEval(schema, "table1", "t,f", "select not col1 is not true, not col2 is not false from table1", new String [] {"t", "t"}); } - - @Test - public void testCreateTableWithUnsupportedStoreType() throws IOException { - testSimpleEval("create table table1 (name text, age int) using RAW;", - new String[] {"Wrong query statement or query plan: create table table1 (name text, age int) using RAW"}, - false); - } } http://git-wip-us.apache.org/repos/asf/tajo/blob/09cad22e/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java b/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java index 71f3f8d..b6827a2 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestQueryValidation.java @@ -50,4 +50,10 @@ public class TestQueryValidation extends QueryTestCaseBase { // See TAJO-1098 assertInvalidSQL("invalid_casewhen_1.sql"); } + + @Test + public void testUnsupportedStoreType() throws PlanningException, IOException { + // See TAJO-1249 + assertInvalidSQL("invalid_store_format.sql"); + } } http://git-wip-us.apache.org/repos/asf/tajo/blob/09cad22e/tajo-core/src/test/resources/queries/TestQueryValidation/invalid_store_format.sql ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/queries/TestQueryValidation/invalid_store_format.sql b/tajo-core/src/test/resources/queries/TestQueryValidation/invalid_store_format.sql new file mode 100644 index 0000000..e5307d6 --- /dev/null +++ b/tajo-core/src/test/resources/queries/TestQueryValidation/invalid_store_format.sql @@ -0,0 +1 @@ +create table table1 (name text, age int) using RAW; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/09cad22e/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java ---------------------------------------------------------------------- diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java b/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java index e6ff0d8..c184fff 100644 --- a/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java +++ b/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java @@ -18,6 +18,7 @@ package org.apache.tajo.plan.verifier; +import com.google.common.base.Preconditions; import org.apache.tajo.OverridableConf; import org.apache.tajo.SessionVars; import org.apache.tajo.TajoConstants; @@ -194,9 +195,12 @@ public class PreLogicalPlanVerifier extends BaseAlgebraVisitor<PreLogicalPlanVer return true; } - private boolean assertUnsupportedStoreType(VerificationState state, String name) { - if (name != null && name.equals(CatalogProtos.StoreType.RAW.name())) { - state.addVerification(String.format("Unsupported store type :%s", name)); + private boolean assertSupportedStoreType(VerificationState state, String name) { + Preconditions.checkNotNull(name); + + CatalogProtos.StoreType storeType = CatalogUtil.getStoreType(name); + if (storeType == null || storeType == CatalogProtos.StoreType.RAW) { + state.addVerification(String.format("Store format %s is not supported.", name)); return false; } return true; @@ -248,7 +252,9 @@ public class PreLogicalPlanVerifier extends BaseAlgebraVisitor<PreLogicalPlanVer if (!expr.isIfNotExists()) { assertRelationNoExistence(context, expr.getTableName()); } - assertUnsupportedStoreType(context.state, expr.getStorageType()); + if (expr.hasStorageType()) { + assertSupportedStoreType(context.state, expr.getStorageType()); + } return expr; } @@ -272,6 +278,10 @@ public class PreLogicalPlanVerifier extends BaseAlgebraVisitor<PreLogicalPlanVer assertRelationExistence(context, expr.getTableName()); } + if (expr.hasStorageType()) { + assertSupportedStoreType(context.state, expr.getStorageType()); + } + if (child != null && child.getType() == OpType.Projection) { Projection projection = (Projection) child;
