tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [2/2] git commit: TAJO-272: boolean test does not work correctly. (hyunsik)
Date Mon, 21 Oct 2013 17:08:22 GMT
TAJO-272: boolean test does not work correctly. (hyunsik)


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

Branch: refs/heads/branch-0.2
Commit: a386840b45ee88f886be460797c86ddbc201b1a2
Parents: 2ec3626
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Tue Oct 22 01:48:25 2013 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Tue Oct 22 02:05:28 2013 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../apache/tajo/engine/parser/SQLAnalyzer.java  | 19 +++++++++++++++-
 .../apache/tajo/engine/eval/TestPredicates.java | 24 ++++++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/a386840b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a08f513..c9e594b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -213,6 +213,8 @@ Release 0.2.0 - unreleased
 
   BUG FIXES
 
+    TAJO-272: boolean test does not work correctly. (hyunsik)
+
     TAJO-264: Remove hard-coded 'standby' mode. (jinho)
 
     TAJO-262: Integration test hang on jenkins. (jinho)

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/a386840b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
index 79e2978..3fa303a 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
@@ -514,7 +514,24 @@ public class SQLAnalyzer extends SQLParserBaseVisitor<Expr> {
 
   @Override
   public Expr visitBoolean_test(SQLParser.Boolean_testContext ctx) {
-    return visitBoolean_primary(ctx.boolean_primary());
+    if (checkIfExist(ctx.is_clause())) {
+      Is_clauseContext isClauseContext = ctx.is_clause();
+      if (checkIfExist(isClauseContext.NOT())) {
+        if (checkIfExist(ctx.is_clause().truth_value().TRUE())) {
+          return new NotExpr(visitBoolean_primary(ctx.boolean_primary()));
+        } else {
+          return visitBoolean_primary(ctx.boolean_primary());
+        }
+      } else {
+        if (checkIfExist(ctx.is_clause().truth_value().TRUE())) {
+          return visitBoolean_primary(ctx.boolean_primary());
+        } else {
+          return new NotExpr(visitBoolean_primary(ctx.boolean_primary()));
+        }
+      }
+    } else {
+      return visitBoolean_primary(ctx.boolean_primary());
+    }
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/a386840b/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 30bf56f..afab261 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
@@ -108,4 +108,28 @@ public class TestPredicates extends ExprTestBase {
     testEval(schema3, "table1", "20130715,20100102,20120525,20130716", query, new String
[] {"1"});
     testEval(schema3, "table1", "20130715,20100102,20120525,20130705", query, new String
[] {"0"});
   }
+
+  @Test
+  public void testBooleanTest() throws IOException {
+    testSimpleEval("select 1 < 3 is true", new String [] {"t"});
+    testSimpleEval("select 1 < 3 is not true", new String [] {"f"});
+    testSimpleEval("select 1 < 3 is false", new String [] {"f"});
+    testSimpleEval("select 1 < 3 is not false", new String [] {"t"});
+
+    testSimpleEval("select not (1 < 3 is true)", new String [] {"f"});
+    testSimpleEval("select not (1 < 3 is not true)", new String [] {"t"});
+    testSimpleEval("select not (1 < 3 is false)", new String [] {"t"});
+    testSimpleEval("select not (1 < 3 is not false)", new String [] {"f"});
+
+    testSimpleEval("select 1 > 3 is true", new String [] {"f"});
+    testSimpleEval("select 1 > 3 is not true", new String [] {"t"});
+    testSimpleEval("select 1 > 3 is false", new String [] {"t"});
+    testSimpleEval("select 1 > 3 is not false", new String [] {"f"});
+
+    testSimpleEval("select not (1 > 3 is true)", new String [] {"t"});
+    testSimpleEval("select not (1 > 3 is not true)", new String [] {"f"});
+    testSimpleEval("select not (1 > 3 is false)", new String [] {"f"});
+    testSimpleEval("select not (1 > 3 is not false)", new String [] {"t"});
+
+  }
 }


Mime
View raw message