[
https://issues.apache.org/jira/browse/CALCITE-2314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16493049#comment-16493049
]
Julian Hyde commented on CALCITE-2314:
--------------------------------------
There's still one failure:
{noformat}
java.lang.ClassCastException: java.base/java.math.BigDecimal cannot be cast to
java.base/java.lang.Long
at
org.apache.calcite.test.RexImplicationCheckerTest.testSimplifyFloor(RexImplicationCheckerTest.java:403){noformat}
I fixed it with the following patch:{noformat}diff --git
a/core/src/main/java/org/apache/calcite/rex/RexInterpreter.java
b/core/src/main/java/org/apache/calcite/rex/RexInterpreter.java
index 8d20000ce..84c3a7cd2 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexInterpreter.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexInterpreter.java
@@ -217,16 +217,16 @@ private Comparable ceil(RexCall call, List<Comparable>
values) {
case MONTH:
switch (call.getKind()) {
case FLOOR:
- return new BigDecimal(DateTimeUtils.unixTimestampFloor(unit, v));
+ return DateTimeUtils.unixTimestampFloor(unit, v);
default:
- return new BigDecimal(DateTimeUtils.unixTimestampCeil(unit, v));
+ return DateTimeUtils.unixTimestampCeil(unit, v);
}
}
final TimeUnitRange subUnit = subUnit(unit);
for (long v2 = v;;) {
final int e = DateTimeUtils.unixTimestampExtract(subUnit, v2);
if (e == 0) {
- return new BigDecimal(v2);
+ return v2;
}
v2 -= unit.startUnit.multiplier.longValue();
}
{noformat}
Then I had to disable that test due to CALCITE-2332.
> Verify RexNode transformations by evaluating before and after expressions
> against sample values
> -----------------------------------------------------------------------------------------------
>
> Key: CALCITE-2314
> URL: https://issues.apache.org/jira/browse/CALCITE-2314
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: Julian Hyde
> Priority: Major
>
> Verify transformations of {{RexNode}} expressions (such as simplification,
> see {{class RexSimplify}}) by evaluating before and after expressions against
> sample values.
> Given an expression, say {{($0 < $1) IS NOT NULL}} we can bind $0 and $1 to
> values (0, 1, null) and evaluate the 9 combinations. We can also evaluate the
> simplified expression {{$0 IS NOT NULL AND $1 IS NOT NULL}} and see whether
> it gives the same value for each of the combinations.
> We can add this checking to existing tests with little effort. It will
> improve confidence that we handle 3-valued logic correctly.
> As part of this task, we will create an interpreter {{class RexInterpreter}}
> that evaluates RexNode expressions for common operators without generating
> code. It is not very efficient and does not cover very many types, functions
> and operators, but should be easy for people to extend to add a few more.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)