drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ve...@apache.org
Subject [1/3] drill git commit: DRILL-2606: Fix BIT (de)serialization issues in ExprParser.
Date Wed, 15 Apr 2015 18:20:29 GMT
Repository: drill
Updated Branches:
  refs/heads/master 314e5a2a8 -> 07cca5dba


DRILL-2606: Fix BIT (de)serialization issues in ExprParser.


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

Branch: refs/heads/master
Commit: f55e53a161857fbad92b20b382af56f4934a65c5
Parents: 09e752e
Author: vkorukanti <venki.korukanti@gmail.com>
Authored: Tue Apr 14 22:21:39 2015 -0700
Committer: vkorukanti <venki.korukanti@gmail.com>
Committed: Wed Apr 15 09:00:23 2015 -0700

----------------------------------------------------------------------
 .../drill/common/expression/parser/ExprLexer.g  |  3 +-
 .../drill/common/expression/parser/ExprParser.g |  7 ++-
 .../common/expression/parser/TreeTest.java      |  5 ++
 .../drill/exec/expr/TestLogicalExprSerDe.java   | 55 ++++++++++++++++++++
 4 files changed, 68 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/f55e53a1/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprLexer.g
----------------------------------------------------------------------
diff --git a/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprLexer.g
b/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprLexer.g
index 092d82f..604b397 100644
--- a/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprLexer.g
+++ b/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprLexer.g
@@ -41,7 +41,8 @@ Nullable: 'nullable';
 Repeat: 'repeat';
 As: 'as';
 
-INT    : 'int' | 'INT';
+BIT      : 'bit' | 'BIT';
+INT      : 'int' | 'INT';
 BIGINT   : 'bigint' | 'BIGINT';
 FLOAT4   : 'float4' | 'FLOAT4';
 FLOAT8   : 'float8' | 'FLOAT8';

http://git-wip-us.apache.org/repos/asf/drill/blob/f55e53a1/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprParser.g
----------------------------------------------------------------------
diff --git a/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprParser.g
b/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprParser.g
index 4948a02..600b791 100644
--- a/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprParser.g
+++ b/common/src/main/antlr3/org/apache/drill/common/expression/parser/ExprParser.g
@@ -101,8 +101,13 @@ dataType returns [MajorType type]
 	: numType  {$type =$numType.type;}
 	| charType {$type =$charType.type;}
 	| dateType {$type =$dateType.type;}
+	| booleanType {$type =$booleanType.type;}
 	;
-  
+
+booleanType returns [MajorType type]
+	: BIT { $type = Types.required(TypeProtos.MinorType.BIT); }
+	;
+
 numType returns [MajorType type]
 	: INT    { $type = Types.required(TypeProtos.MinorType.INT); }
 	| BIGINT { $type = Types.required(TypeProtos.MinorType.BIGINT); }

http://git-wip-us.apache.org/repos/asf/drill/blob/f55e53a1/common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
b/common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
index 39aed44..7cf1477 100644
--- a/common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
+++ b/common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
@@ -65,6 +65,11 @@ public class TreeTest extends DrillTest {
     testExpressionParsing("goodbye[4].`hello`");
   }
 
+  @Test // DRILL-2606
+  public void testCastToBooleanExpr() throws Exception{
+    testExpressionParsing("cast( (cast( (`bool_col` ) as VARCHAR(100) ) ) as BIT )");
+  }
+
   private LogicalExpression parseExpression(String expr) throws RecognitionException, IOException{
 
     ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));

http://git-wip-us.apache.org/repos/asf/drill/blob/f55e53a1/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java
new file mode 100644
index 0000000..420fc75
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java
@@ -0,0 +1,55 @@
+package org.apache.drill.exec.expr;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.drill.BaseTestQuery;
+import org.apache.drill.exec.ExecConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test LogicalExpressions are serialized and deserialized properly when query is planned
into multiple fragments.
+ */
+public class TestLogicalExprSerDe extends BaseTestQuery {
+
+  @BeforeClass
+  public static void setSliceCount() throws Exception {
+    // Set the slice count to low, so that query is divided into multiple fragments with
exchanges.
+    test("ALTER SESSION SET `planner.slice_target`=1;");
+  }
+
+  @Test // DRILL-2606
+  public void castToBit() throws Exception {
+    testBuilder()
+        .sqlQuery("SELECT CAST(CAST('true' as VARCHAR(20)) AS BOOLEAN) c1 FROM cp.`region.json`
ORDER BY `region_id` LIMIT 1")
+        .unOrdered()
+        .baselineColumns("c1")
+        .baselineValues(true)
+        .go();
+  }
+
+  // TODO: Need to add better coverage for ExprParser
+
+  @AfterClass
+  public static void resetSliceCount() throws Exception {
+    // Set the slice count to low, so that query is divided into multiple fragments with
exchanges.
+    test(String.format("ALTER SESSION SET `planner.slice_target`=%d;", ExecConstants.SLICE_TARGET_DEFAULT));
+  }
+}


Mime
View raw message