Add tests for POSTFIX operators added in 
097fc00b375b8a171a53e8062d03f06b350ae14e


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

Branch: refs/heads/master
Commit: ed5d7c91a6eeded6a5b0aec713e58bd2c654a87b
Parents: 8296be5
Author: vkorukanti <[email protected]>
Authored: Wed Apr 16 11:28:22 2014 -0700
Committer: Jacques Nadeau <[email protected]>
Committed: Sat Apr 19 21:07:00 2014 -0700

----------------------------------------------------------------------
 .../exec/physical/impl/TestSimpleFunctions.java | 56 ----------------
 .../test/resources/functions/testIsNotNull.json | 35 ----------
 .../test/resources/functions/testIsNull.json    | 35 ----------
 .../apache/drill/jdbc/test/TestJdbcQuery.java   | 68 ++++++++++++++++++++
 sqlparser/src/test/resources/test_null_op.json  | 10 +++
 .../src/test/resources/test_true_false_op.json  | 11 ++++
 6 files changed, 89 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ed5d7c91/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFunctions.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFunctions.java
 
b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFunctions.java
index 4a5f470..2206243 100644
--- 
a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFunctions.java
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFunctions.java
@@ -144,62 +144,6 @@ public class TestSimpleFunctions {
   }
 
   @Test
-  public void testIsNull(@Injectable final DrillbitContext bitContext,
-                         @Injectable UserServer.UserClientConnection 
connection) throws Throwable {
-
-    new NonStrictExpectations(){{
-      bitContext.getMetrics(); result = new MetricRegistry();
-      bitContext.getAllocator(); result = new TopLevelAllocator();
-      bitContext.getOperatorCreatorRegistry(); result = new 
OperatorCreatorRegistry(c);
-    }};
-
-    PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), 
CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
-    PhysicalPlan plan = 
reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/functions/testIsNull.json"),
 Charsets.UTF_8));
-    FunctionImplementationRegistry registry = new 
FunctionImplementationRegistry(c);
-    FragmentContext context = new FragmentContext(bitContext, 
PlanFragment.getDefaultInstance(), connection, registry);
-    SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, 
(FragmentRoot) plan.getSortedOperators(false).iterator().next()));
-
-    while(exec.next()){
-      assertEquals(50, exec.getSelectionVector2().getCount());
-    }
-
-    if(context.getFailureCause() != null){
-      throw context.getFailureCause();
-    }
-
-    assertTrue(!context.isFailed());
-
-  }
-
-  @Test
-  public void testIsNotNull(@Injectable final DrillbitContext bitContext,
-                            @Injectable UserServer.UserClientConnection 
connection) throws Throwable{
-
-    new NonStrictExpectations(){{
-      bitContext.getMetrics(); result = new MetricRegistry();
-      bitContext.getAllocator(); result = new TopLevelAllocator();
-      bitContext.getOperatorCreatorRegistry(); result = new 
OperatorCreatorRegistry(c);
-    }};
-
-    PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), 
CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
-    PhysicalPlan plan = 
reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/functions/testIsNotNull.json"),
 Charsets.UTF_8));
-    FunctionImplementationRegistry registry = new 
FunctionImplementationRegistry(c);
-    FragmentContext context = new FragmentContext(bitContext, 
PlanFragment.getDefaultInstance(), connection, registry);
-    SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, 
(FragmentRoot) plan.getSortedOperators(false).iterator().next()));
-
-    while(exec.next()){
-      assertEquals(50, exec.getSelectionVector2().getCount());
-    }
-
-    if(context.getFailureCause() != null){
-      throw context.getFailureCause();
-    }
-
-    assertTrue(!context.isFailed());
-
-  }
-
-  @Test
   public void testSubstring(@Injectable final DrillbitContext bitContext,
                             @Injectable UserServer.UserClientConnection 
connection) throws Throwable{
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ed5d7c91/exec/java-exec/src/test/resources/functions/testIsNotNull.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/functions/testIsNotNull.json 
b/exec/java-exec/src/test/resources/functions/testIsNotNull.json
deleted file mode 100644
index 713d58f..0000000
--- a/exec/java-exec/src/test/resources/functions/testIsNotNull.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
-    head:{
-        type:"APACHE_DRILL_PHYSICAL",
-        version:"1",
-        generator:{
-            type:"manual"
-        }
-    },
-       graph:[
-        {
-            @id:1,
-            pop:"mock-sub-scan",
-            url: "http://apache.org";,
-            entries:[
-               {records: 100, types: [
-                 {name: "blue", type: "INT", mode: "REQUIRED"},
-                 {name: "red", type: "BIGINT", mode: "REQUIRED"},
-                 {name: "yellow", type: "FLOAT8", mode: "OPTIONAL"},
-                 {name: "green", type: "INT", mode: "REQUIRED"}
-               ]}
-            ]
-        },
-        {
-            @id:2,
-            child: 1,
-            pop:"filter",
-            expr: "isnotnull(yellow)"
-        },
-        {
-            @id: 3,
-            child: 2,
-            pop: "screen"
-        }
-    ]
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ed5d7c91/exec/java-exec/src/test/resources/functions/testIsNull.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/functions/testIsNull.json 
b/exec/java-exec/src/test/resources/functions/testIsNull.json
deleted file mode 100644
index e173adc..0000000
--- a/exec/java-exec/src/test/resources/functions/testIsNull.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
-    head:{
-        type:"APACHE_DRILL_PHYSICAL",
-        version:"1",
-        generator:{
-            type:"manual"
-        }
-    },
-       graph:[
-        {
-            @id:1,
-            pop:"mock-sub-scan",
-            url: "http://apache.org";,
-            entries:[
-               {records: 100, types: [
-                 {name: "blue", type: "INT", mode: "REQUIRED"},
-                 {name: "red", type: "BIGINT", mode: "REQUIRED"},
-                 {name: "yellow", type: "FLOAT8", mode: "OPTIONAL"},
-                 {name: "green", type: "INT", mode: "REQUIRED"}
-               ]}
-            ]
-        },
-        {
-            @id:2,
-            child: 1,
-            pop:"filter",
-            expr: "isnull(yellow)"
-        },
-        {
-            @id: 3,
-            child: 2,
-            pop: "screen"
-        }
-    ]
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ed5d7c91/sqlparser/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
----------------------------------------------------------------------
diff --git 
a/sqlparser/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java 
b/sqlparser/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
index e2666f8..7031283 100644
--- a/sqlparser/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
+++ b/sqlparser/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
@@ -194,4 +194,72 @@ public class TestJdbcQuery {
       .sql("select substring('asd' from 1 for 2) from 
INFORMATION_SCHEMA.`TABLES` limit 1")
       .returns("EXPR$0=as\n");
   }
+
+  @Test
+  public void testNullOpForNullableType() throws Exception{
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT * FROM cp.`test_null_op.json` WHERE intType IS NULL AND 
varCharType IS NOT NULL")
+        .returns("intType=null; varCharType=val2");
+  }
+
+  @Test
+  public void testNullOpForNonNullableType() throws Exception{
+    // output of (intType IS NULL) is a non-nullable type
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT * FROM cp.`test_null_op.json` "+
+            "WHERE (intType IS NULL) IS NULL AND (varCharType IS NOT NULL) IS 
NOT NULL")
+        .returns("");
+  }
+
+  @Test
+  public void testTrueOpForNullableType() throws Exception{
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT data FROM cp.`test_true_false_op.json` WHERE booleanType 
IS TRUE")
+        .returns("data=set to true");
+
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT data FROM cp.`test_true_false_op.json` WHERE booleanType 
IS FALSE")
+        .returns("data=set to false");
+
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT data FROM cp.`test_true_false_op.json` WHERE booleanType 
IS NOT TRUE")
+        .returns(
+            "data=set to false\n" +
+            "data=not set"
+        );
+
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT data FROM cp.`test_true_false_op.json` WHERE booleanType 
IS NOT FALSE")
+        .returns(
+            "data=set to true\n" +
+            "data=not set"
+        );
+  }
+
+
+  @Test
+  public void testTrueOpForNonNullableType() throws Exception{
+    // Output of IS TRUE (and others) is a Non-nullable type
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT data FROM cp.`test_true_false_op.json` WHERE (booleanType 
IS TRUE) IS TRUE")
+        .returns("data=set to true");
+
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT data FROM cp.`test_true_false_op.json` WHERE (booleanType 
IS FALSE) IS FALSE")
+        .returns(
+            "data=set to true\n" +
+            "data=not set"
+        );
+
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT data FROM cp.`test_true_false_op.json` WHERE (booleanType 
IS NOT TRUE) IS NOT TRUE")
+        .returns("data=set to true");
+
+    JdbcAssert.withNoDefaultSchema()
+        .sql("SELECT data FROM cp.`test_true_false_op.json` WHERE (booleanType 
IS NOT FALSE) IS NOT FALSE")
+        .returns(
+            "data=set to true\n" +
+            "data=not set"
+        );
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ed5d7c91/sqlparser/src/test/resources/test_null_op.json
----------------------------------------------------------------------
diff --git a/sqlparser/src/test/resources/test_null_op.json 
b/sqlparser/src/test/resources/test_null_op.json
new file mode 100644
index 0000000..01acead
--- /dev/null
+++ b/sqlparser/src/test/resources/test_null_op.json
@@ -0,0 +1,10 @@
+{
+    "intType": 1,
+    "varCharType": "val1"
+}
+{
+    "varCharType": "val2"
+}
+{
+    "intType": 2
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ed5d7c91/sqlparser/src/test/resources/test_true_false_op.json
----------------------------------------------------------------------
diff --git a/sqlparser/src/test/resources/test_true_false_op.json 
b/sqlparser/src/test/resources/test_true_false_op.json
new file mode 100644
index 0000000..9e29ddc
--- /dev/null
+++ b/sqlparser/src/test/resources/test_true_false_op.json
@@ -0,0 +1,11 @@
+{
+    "booleanType": false,
+    "data" : "set to false"
+}
+{
+    "booleanType": true,
+    "data" : "set to true"
+}
+{
+    "data" : "not set"
+}

Reply via email to