tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blrun...@apache.org
Subject git commit: TAJO-663: CREATE TABLE USING RAW doesn't throw ERROR. (jaehwa)
Date Thu, 06 Mar 2014 09:07:52 GMT
Repository: incubator-tajo
Updated Branches:
  refs/heads/branch-0.8.0 be1663bd1 -> 7625fb757


TAJO-663: CREATE TABLE USING RAW doesn't throw ERROR. (jaehwa)


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

Branch: refs/heads/branch-0.8.0
Commit: 7625fb7571626e7fc3d298f4a02f0298d94c7da3
Parents: be1663b
Author: blrunner <jhjung@gruter.com>
Authored: Thu Mar 6 18:07:49 2014 +0900
Committer: blrunner <jhjung@gruter.com>
Committed: Thu Mar 6 18:07:49 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../engine/planner/PreLogicalPlanVerifier.java  | 10 +++++++
 .../apache/tajo/engine/eval/ExprTestBase.java   | 31 ++++++++++++++++----
 .../apache/tajo/engine/eval/TestPredicates.java |  6 ++++
 .../TestStringOperatorsAndFunctions.java        |  6 ++--
 5 files changed, 46 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/7625fb75/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1a17801..54119c8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -269,6 +269,8 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
+    TAJO-663: CREATE TABLE USING RAW doesn't throw ERROR. (jaehwa)
+
     TAJO-665: sort buffer size must be dealt as long type values. 
     (hyoungjunkim via hyunsik)
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/7625fb75/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
index 024a9ae..b225012 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
@@ -21,6 +21,7 @@ package org.apache.tajo.engine.planner;
 import com.google.common.collect.ObjectArrays;
 import org.apache.tajo.algebra.*;
 import org.apache.tajo.catalog.CatalogService;
+import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.util.TUtil;
 
 import java.util.Arrays;
@@ -138,6 +139,14 @@ public class PreLogicalPlanVerifier extends BaseAlgebraVisitor <VerificationStat
     return true;
   }
 
+  private boolean assertUnsupportedStoreType(VerificationState state, String name) {
+    if (name.equals(CatalogProtos.StoreType.RAW.name())) {
+      state.addVerification(String.format("Unsupported store type :%s", name));
+      return false;
+    }
+    return true;
+  }
+
   ///////////////////////////////////////////////////////////////////////////////////////////////////////////
   // Data Definition Language Section
   ///////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -146,6 +155,7 @@ public class PreLogicalPlanVerifier extends BaseAlgebraVisitor <VerificationStat
   public Expr visitCreateTable(VerificationState state, Stack<Expr> stack, CreateTable
expr) throws PlanningException {
     super.visitCreateTable(state, stack, expr);
     assertRelationNoExistence(state, expr.getTableName());
+    assertUnsupportedStoreType(state, expr.getStorageType());
     return expr;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/7625fb75/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
index 622da90..2982f83 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
@@ -80,11 +80,22 @@ public class ExprTestBase {
     assertEquals(expr, fromJson);
   }
 
-  private static Target[] getRawTargets(String query) throws PlanningException {
+  /**
+   * verify query syntax and get raw targets.
+   *
+   * @param query a query for execution
+   * @param condition this parameter means whether it is for success case or is not for failure
case.
+   * @return
+   * @throws PlanningException
+   */
+  private static Target[] getRawTargets(String query, boolean condition) throws PlanningException
{
     Expr expr = analyzer.parse(query);
     VerificationState state = new VerificationState();
     preLogicalPlanVerifier.visit(state, new Stack<Expr>(), expr);
     if (state.getErrorMessages().size() > 0) {
+      if (!condition && state.getErrorMessages().size() > 0) {
+        throw new PlanningException(state.getErrorMessages().get(0));
+      }
       assertFalse(state.getErrorMessages().get(0), true);
     }
     LogicalPlan plan = planner.createPlan(expr, true);
@@ -109,13 +120,17 @@ public class ExprTestBase {
     testEval(null, null, null, query, expected);
   }
 
+  public void testSimpleEval(String query, String [] expected, boolean condition) throws
IOException {
+    testEval(null, null, null, query, expected, ',', condition);
+  }
+
   public void testEval(Schema schema, String tableName, String csvTuple, String query, String
[] expected)
       throws IOException {
-    testEval(schema, tableName, csvTuple, query, expected, ',');
+    testEval(schema, tableName, csvTuple, query, expected, ',', true);
   }
 
   public void testEval(Schema schema, String tableName, String csvTuple, String query, String
[] expected,
-                       char delimiter) throws IOException {
+                       char delimiter, boolean condition) throws IOException {
     LazyTuple lazyTuple;
     VTuple vtuple  = null;
     Schema inputSchema = null;
@@ -146,7 +161,7 @@ public class ExprTestBase {
     Target [] targets;
 
     try {
-      targets = getRawTargets(query);
+      targets = getRawTargets(query, condition);
 
       Tuple outTuple = new VTuple(targets.length);
       for (int i = 0; i < targets.length; i++) {
@@ -158,7 +173,13 @@ public class ExprTestBase {
         assertEquals(query, expected[i], outTuple.get(i).asChars());
       }
     } catch (PlanningException e) {
-      assertFalse(e.getMessage(), true);
+      // In failure test case, an exception must occur while executing query.
+      // So, we should check an error message, and return it.
+      if (!condition) {
+        assertEquals(expected[0], e.getMessage());
+      } else {
+        assertFalse(e.getMessage(), true);
+      }
     } finally {
       if (schema != null) {
         cat.deleteTable(tableName);

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/7625fb75/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java
index 86b921f..39c7492 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/TestPredicates.java
@@ -353,4 +353,10 @@ 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[] {"Unsupported
store type :RAW"}, false);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/7625fb75/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java
index f1d0ce3..71d7b85 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java
@@ -21,14 +21,12 @@ package org.apache.tajo.engine.function;
 
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.catalog.exception.NoSuchFunctionException;
 import org.apache.tajo.engine.eval.ExprTestBase;
 import org.junit.Test;
 
 import java.io.IOException;
 
 import static org.apache.tajo.common.TajoDataTypes.Type.*;
-import static org.junit.Assert.fail;
 
 public class TestStringOperatorsAndFunctions extends ExprTestBase {
 
@@ -594,8 +592,8 @@ public class TestStringOperatorsAndFunctions extends ExprTestBase {
     schema.addColumn("col1", TEXT);
     schema.addColumn("col2", TEXT);
     testEval(schema, "table1", "|crt,c,cr,c,def", "select find_in_set(col1, col2) is null
from table1",
-        new String[]{"t"}, '|');
+        new String[]{"t"}, '|', true);
     testEval(schema, "table1", "cr|", "select find_in_set(col1, col2) is null from table1",
-        new String[]{"t"}, '|');
+        new String[]{"t"}, '|', true);
   }
 }


Mime
View raw message