You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by jn...@apache.org on 2015/02/18 20:10:56 UTC
drill git commit: DRILL-2054: Interpret "||" as string concat
operator; Disable `&&`;
Repository: drill
Updated Branches:
refs/heads/master 30c09ec48 -> d4dc295f1
DRILL-2054: Interpret "||" as string concat operator; Disable `&&`;
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/d4dc295f
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/d4dc295f
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/d4dc295f
Branch: refs/heads/master
Commit: d4dc295f1c46555a4cba774e0b211de72c119e29
Parents: 30c09ec
Author: Hsuan-Yi Chu <hs...@usc.edu>
Authored: Fri Jan 30 09:09:04 2015 -0800
Committer: Jinfeng Ni <jn...@maprtech.com>
Committed: Wed Feb 18 11:08:30 2015 -0800
----------------------------------------------------------------------
.../drill/common/expression/parser/ExprLexer.g | 4 +--
.../drill/common/expression/parser/ExprParser.g | 4 +--
.../common/expression/FunctionCallFactory.java | 4 +--
.../apache/drill/TestDisabledFunctionality.java | 21 +++++++++++
.../org/apache/drill/TestExampleQueries.java | 37 ++++++++++++++++++++
.../testExampleQueries/testConcatOperator.tsv | 25 +++++++++++++
.../testConcatOperatorInputTypeCombination.tsv | 25 +++++++++++++
pom.xml | 2 +-
8 files changed, 114 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/d4dc295f/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 e3a0e34..092d82f 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
@@ -61,8 +61,8 @@ DECIMAL28DENSE : 'decimal28dense' | 'DECIMAL28DENSE';
DECIMAL28SPARSE : 'decimal28sparse' | 'DECIMAL28SPARSE';
DECIMAL38DENSE : 'decimal38dense' | 'DECIMAL38DENSE';
DECIMAL38SPARSE : 'decimal38sparse' | 'DECIMAL38SPARSE';
-Or : '||' | 'or' | 'OR' | 'Or';
-And : '&&' | 'and' | 'AND' ;
+Or : 'or' | 'OR' | 'Or';
+And : 'and' | 'AND' ;
Equals : '==' | '=';
NEquals : '<>' | '!=';
GTEquals : '>=';
http://git-wip-us.apache.org/repos/asf/drill/blob/d4dc295f/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 dafb1d6..4948a02 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
@@ -204,7 +204,7 @@ orExpr returns [LogicalExpression e]
if(exprs.size() == 1){
$e = exprs.get(0);
}else{
- $e = FunctionCallFactory.createBooleanOperator("||", p, exprs);
+ $e = FunctionCallFactory.createBooleanOperator("or", p, exprs);
}
}
: a1=andExpr { exprs.add($a1.e); p = pos( $a1.start );} (Or a2=andExpr { exprs.add($a2.e); })*
@@ -219,7 +219,7 @@ andExpr returns [LogicalExpression e]
if(exprs.size() == 1){
$e = exprs.get(0);
}else{
- $e = FunctionCallFactory.createBooleanOperator("&&", p, exprs);
+ $e = FunctionCallFactory.createBooleanOperator("and", p, exprs);
}
}
: e1=equExpr { exprs.add($e1.e); p = pos( $e1.start ); } ( And e2=equExpr { exprs.add($e2.e); })*
http://git-wip-us.apache.org/repos/asf/drill/blob/d4dc295f/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java b/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java
index 0a2006a..64432ca 100644
--- a/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java
+++ b/common/src/main/java/org/apache/drill/common/expression/FunctionCallFactory.java
@@ -39,11 +39,9 @@ public class FunctionCallFactory {
opToFuncTable.put("*", "multiply");
opToFuncTable.put("%", "modulo");
opToFuncTable.put("^", "xor");
-
- opToFuncTable.put("||", "booleanOr");
+ opToFuncTable.put("||", "concat");
opToFuncTable.put("or", "booleanOr");
opToFuncTable.put("and", "booleanAnd");
- opToFuncTable.put("&&", "booleanAnd");
opToFuncTable.put(">", "greater_than");
opToFuncTable.put("<", "less_than");
opToFuncTable.put("==", "equal");
http://git-wip-us.apache.org/repos/asf/drill/blob/d4dc295f/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java b/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
index c88badd..b1437c1 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
@@ -16,6 +16,7 @@
* limitations under the License.
*/
package org.apache.drill;
+import org.apache.drill.exec.rpc.RpcException;
import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
import org.apache.drill.exec.work.foreman.UnsupportedDataTypeException;
import org.apache.drill.exec.work.foreman.UnsupportedFunctionException;
@@ -25,6 +26,26 @@ import org.junit.Test;
public class TestDisabledFunctionality extends BaseTestQuery{
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestExampleQueries.class);
+ @Test(expected = RpcException.class) // see DRILL-2054
+ public void testBooleanORExpression() throws Exception {
+ test("select (1 = 1) || (1 > 0) from cp.`tpch/nation.parquet` ");
+ }
+
+ @Test(expected = RpcException.class) // see DRILL-2054
+ public void testBooleanORSelectClause() throws Exception {
+ test("select true || true from cp.`tpch/nation.parquet` ");
+ }
+
+ @Test(expected = RpcException.class) // see DRILL-2054
+ public void testBooleanORWhereClause() throws Exception {
+ test("select * from cp.`tpch/nation.parquet` where (true || true) ");
+ }
+
+ @Test(expected = RpcException.class) // see DRILL-2054
+ public void testBooleanAND() throws Exception {
+ test("select true && true from cp.`tpch/nation.parquet` ");
+ }
+
@Test(expected = UnsupportedFunctionException.class) // see DRILL-1937
public void testDisabledExplainplanForComparisonWithNonscalarSubquery() throws Exception {
try {
http://git-wip-us.apache.org/repos/asf/drill/blob/d4dc295f/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
index 9d3b8dc..55fb59f 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
@@ -19,6 +19,7 @@ package org.apache.drill;
import static org.junit.Assert.assertEquals;
+import org.apache.drill.common.types.TypeProtos;
import org.apache.drill.common.util.FileUtils;
import org.apache.drill.common.util.TestTools;
import org.junit.Ignore;
@@ -27,6 +28,42 @@ import org.junit.Test;
public class TestExampleQueries extends BaseTestQuery{
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestExampleQueries.class);
+ @Test // see DRILL-2054
+ public void testConcatOperator() throws Exception {
+ testBuilder()
+ .sqlQuery("select n_nationkey || '+' || n_name || '=' as CONCAT, n_nationkey, '+' as PLUS, n_name from cp.`tpch/nation.parquet`")
+ .ordered()
+ .csvBaselineFile("testframework/testExampleQueries/testConcatOperator.tsv")
+ .baselineTypes(TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.INT, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.VARCHAR)
+ .baselineColumns("CONCAT", "n_nationkey", "PLUS", "n_name")
+ .build().run();
+
+ testBuilder()
+ .sqlQuery("select (n_nationkey || n_name) as CONCAT from cp.`tpch/nation.parquet`")
+ .ordered()
+ .csvBaselineFile("testframework/testExampleQueries/testConcatOperatorInputTypeCombination.tsv")
+ .baselineTypes(TypeProtos.MinorType.VARCHAR)
+ .baselineColumns("CONCAT")
+ .build().run();
+
+
+ testBuilder()
+ .sqlQuery("select (n_nationkey || cast(n_name as varchar(30))) as CONCAT from cp.`tpch/nation.parquet`")
+ .ordered()
+ .csvBaselineFile("testframework/testExampleQueries/testConcatOperatorInputTypeCombination.tsv")
+ .baselineTypes(TypeProtos.MinorType.VARCHAR)
+ .baselineColumns("CONCAT")
+ .build().run();
+
+ testBuilder()
+ .sqlQuery("select (cast(n_nationkey as varchar(30)) || n_name) as CONCAT from cp.`tpch/nation.parquet`")
+ .ordered()
+ .csvBaselineFile("testframework/testExampleQueries/testConcatOperatorInputTypeCombination.tsv")
+ .baselineTypes(TypeProtos.MinorType.VARCHAR)
+ .baselineColumns("CONCAT")
+ .build().run();
+ }
+
@Test // see DRILL-985
public void testViewFileName() throws Exception {
test("use dfs.tmp");
http://git-wip-us.apache.org/repos/asf/drill/blob/d4dc295f/exec/java-exec/src/test/resources/testframework/testExampleQueries/testConcatOperator.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/testframework/testExampleQueries/testConcatOperator.tsv b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testConcatOperator.tsv
new file mode 100644
index 0000000..23e083c
--- /dev/null
+++ b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testConcatOperator.tsv
@@ -0,0 +1,25 @@
+0+ALGERIA= 0 + ALGERIA
+1+ARGENTINA= 1 + ARGENTINA
+2+BRAZIL= 2 + BRAZIL
+3+CANADA= 3 + CANADA
+4+EGYPT= 4 + EGYPT
+5+ETHIOPIA= 5 + ETHIOPIA
+6+FRANCE= 6 + FRANCE
+7+GERMANY= 7 + GERMANY
+8+INDIA= 8 + INDIA
+9+INDONESIA= 9 + INDONESIA
+10+IRAN= 10 + IRAN
+11+IRAQ= 11 + IRAQ
+12+JAPAN= 12 + JAPAN
+13+JORDAN= 13 + JORDAN
+14+KENYA= 14 + KENYA
+15+MOROCCO= 15 + MOROCCO
+16+MOZAMBIQUE= 16 + MOZAMBIQUE
+17+PERU= 17 + PERU
+18+CHINA= 18 + CHINA
+19+ROMANIA= 19 + ROMANIA
+20+SAUDI ARABIA= 20 + SAUDI ARABIA
+21+VIETNAM= 21 + VIETNAM
+22+RUSSIA= 22 + RUSSIA
+23+UNITED KINGDOM= 23 + UNITED KINGDOM
+24+UNITED STATES= 24 + UNITED STATES
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/drill/blob/d4dc295f/exec/java-exec/src/test/resources/testframework/testExampleQueries/testConcatOperatorInputTypeCombination.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/testframework/testExampleQueries/testConcatOperatorInputTypeCombination.tsv b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testConcatOperatorInputTypeCombination.tsv
new file mode 100644
index 0000000..0f6526a
--- /dev/null
+++ b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testConcatOperatorInputTypeCombination.tsv
@@ -0,0 +1,25 @@
+0ALGERIA
+1ARGENTINA
+2BRAZIL
+3CANADA
+4EGYPT
+5ETHIOPIA
+6FRANCE
+7GERMANY
+8INDIA
+9INDONESIA
+10IRAN
+11IRAQ
+12JAPAN
+13JORDAN
+14KENYA
+15MOROCCO
+16MOZAMBIQUE
+17PERU
+18CHINA
+19ROMANIA
+20SAUDI ARABIA
+21VIETNAM
+22RUSSIA
+23UNITED KINGDOM
+24UNITED STATES
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/drill/blob/d4dc295f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7f973c8..f7dc245 100644
--- a/pom.xml
+++ b/pom.xml
@@ -946,7 +946,7 @@
<dependency>
<groupId>net.hydromatic</groupId>
<artifactId>optiq-core</artifactId>
- <version>0.9-drill-r19</version>
+ <version>0.9-drill-r20</version>
<exclusions>
<exclusion>
<groupId>org.jgrapht</groupId>