You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by tn...@apache.org on 2014/03/27 22:39:52 UTC
git commit: Drill-449: Catch parsing error thrown by Antlr parser,
when expression has error, and stop the execution immediately.
Repository: incubator-drill
Updated Branches:
refs/heads/master 7658f55ae -> f63292148
Drill-449: Catch parsing error thrown by Antlr parser, when expression has error, and stop the execution immediately.
DRILL-449: minor change to test case.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/f6329214
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/f6329214
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/f6329214
Branch: refs/heads/master
Commit: f632921489e3099ba898c6fb2e9019b0d3aea8f4
Parents: 7658f55
Author: Jinfeng Ni <jn...@maprtech.com>
Authored: Wed Mar 26 16:14:59 2014 -0700
Committer: Timothy Chen <tn...@apache.org>
Committed: Thu Mar 27 12:57:31 2014 -0700
----------------------------------------------------------------------
.../apache/drill/common/expression/parser/ExprParser.g | 9 ++++++++-
.../java/org/apache/drill/exec/expr/ExpressionTest.java | 11 +++++++++++
pom.xml | 1 +
3 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f6329214/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 edb8507..b60e2d6 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
@@ -37,7 +37,7 @@ import java.util.*;
import org.apache.drill.common.expression.*;
import org.apache.drill.common.types.*;
import org.apache.drill.common.types.TypeProtos.*;
-
+import org.apache.drill.common.exceptions.ExpressionParsingException;
}
@members{
@@ -51,6 +51,13 @@ import org.apache.drill.common.types.TypeProtos.*;
public ExpressionPosition pos(Token token){
return new ExpressionPosition(fullExpression, token.getTokenIndex());
}
+
+ @Override
+ public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
+ String hdr = getErrorHeader(e);
+ String msg = getErrorMessage(e, tokenNames);
+ throw new ExpressionParsingException("Expression has syntax error! " + hdr + ":" + msg);
+ }
}
parse returns [LogicalExpression e]
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f6329214/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java
index 3491e7a..65b4e76 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java
@@ -27,6 +27,7 @@ import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.common.exceptions.ExpressionParsingException;
import org.apache.drill.common.expression.ErrorCollector;
import org.apache.drill.common.expression.ErrorCollectorImpl;
import org.apache.drill.common.expression.ExpressionPosition;
@@ -93,6 +94,16 @@ public class ExpressionTest {
}
+ @Test(expected = ExpressionParsingException.class)
+ public void testExprParseError(@Injectable RecordBatch batch) throws Exception {
+ getExpressionCode("less than(1, 2)", batch);
+ }
+
+ @Test
+ public void testExprParseNoError(@Injectable RecordBatch batch) throws Exception {
+ getExpressionCode("equal(1, 2)", batch);
+ }
+
// HELPER METHODS //
private LogicalExpression parseExpr(String expr) throws RecognitionException {
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f6329214/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5998f99..44eb1c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,6 +120,7 @@
<exclude>**/target/**</exclude>
<exclude>**/*.iml</exclude>
<exclude>**/*.tdd</exclude>
+ <exclude>**/*.project</exclude>
</excludes>
</configuration>
</plugin>