You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2014/04/24 09:08:23 UTC
[05/10] git commit: DRILL-474: Long.MIN_VALUE is not parsed as BIGINT
but as a Double
DRILL-474: Long.MIN_VALUE is not parsed as BIGINT but as a Double
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/166079b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/166079b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/166079b2
Branch: refs/heads/master
Commit: 166079b2248f6e62d6cf105599e2e341f1f9868a
Parents: 1648195
Author: Aditya Kishore <ad...@maprtech.com>
Authored: Tue Apr 1 02:57:23 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Thu Apr 24 00:07:25 2014 -0700
----------------------------------------------------------------------
.../apache/drill/common/expression/parser/ExprParser.g | 6 +++---
.../apache/drill/common/expression/ValueExpressions.java | 11 ++++++-----
2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/166079b2/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 6788e56..ca37e4c 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
@@ -272,14 +272,14 @@ xorExpr returns [LogicalExpression e]
;
unaryExpr returns [LogicalExpression e]
- : Minus atom {$e = FunctionCallFactory.createExpression("u-", pos($atom.start), $atom.e); }
+ : sign=(Plus|Minus)? Number {$e = ValueExpressions.getNumericExpression($sign.text, $Number.text, pos(($sign != null) ? $sign : $Number)); }
+ | Minus atom {$e = FunctionCallFactory.createExpression("u-", pos($atom.start), $atom.e); }
| Excl atom {$e= FunctionCallFactory.createExpression("!", pos($atom.start), $atom.e); }
| atom {$e = $atom.e; }
;
atom returns [LogicalExpression e]
- : Number {$e = ValueExpressions.getNumericExpression($Number.text, pos($atom.start)); }
- | Bool {$e = new ValueExpressions.BooleanExpression( $Bool.text, pos($atom.start)); }
+ : Bool {$e = new ValueExpressions.BooleanExpression($Bool.text, pos($atom.start)); }
| lookup {$e = $lookup.e; }
;
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/166079b2/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java b/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java
index 78f698c..0948c57 100644
--- a/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java
+++ b/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java
@@ -90,29 +90,30 @@ public class ValueExpressions {
return new Decimal38Expression(i, ExpressionPosition.UNKNOWN);
}
- public static LogicalExpression getNumericExpression(String s, ExpressionPosition ep) {
+ public static LogicalExpression getNumericExpression(String sign, String s, ExpressionPosition ep) {
+ String numStr = (sign == null) ? s : sign+s;
try {
- int a = Integer.parseInt(s);
+ int a = Integer.parseInt(numStr);
return new IntExpression(a, ep);
} catch (Exception e) {
}
try {
- long l = Long.parseLong(s);
+ long l = Long.parseLong(numStr);
return new LongExpression(l, ep);
} catch (Exception e) {
}
try {
- double d = Double.parseDouble(s);
+ double d = Double.parseDouble(numStr);
return new DoubleExpression(d, ep);
} catch (Exception e) {
}
throw new IllegalArgumentException(String.format("Unable to parse string %s as integer or floating point number.",
- s));
+ numStr));
}