This is an automated email from the ASF dual-hosted git repository. chunwei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push: new da4970e [CALCITE-3039] In Interpreter, min() incorrectly returns maximum double value (dijkspicy) da4970e is described below commit da4970e647d58b2989077688d1e19747fd459d14 Author: dijkspicy <dijksp...@outlook.com> AuthorDate: Sun May 5 12:05:50 2019 +0800 [CALCITE-3039] In Interpreter, min() incorrectly returns maximum double value (dijkspicy) Close apache/calcite#1197 --- .../org/apache/calcite/interpreter/AggregateNode.java | 2 +- core/src/test/java/org/apache/calcite/test/JdbcTest.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java b/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java index 80d56f8..ca0e078 100644 --- a/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java +++ b/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java @@ -536,7 +536,7 @@ public class AggregateNode extends AbstractSingleNode<Aggregate> { */ public static class MinDouble extends NumericComparison<Double> { public MinDouble() { - super(Double.MAX_VALUE, Math::max); + super(Double.MAX_VALUE, Math::min); } } diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java index 79eef06..b2e31ff 100644 --- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java +++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java @@ -6744,6 +6744,21 @@ public class JdbcTest { connection.close(); } + /** Test case for + * <a href="https://issues.apache.org/jira/browse/CALCITE-3039">[CALCITE-3039] + * In Interpreter, min() incorrectly returns maximum double value</a>. */ + @Test public void testMinAggWithDouble() { + try (Hook.Closeable ignored = Hook.ENABLE_BINDABLE.addThread(Hook.propertyJ(true))) { + CalciteAssert.hr() + .query( + "select min(div) as _min from (" + + "select \"empid\", \"deptno\", CAST(\"empid\" AS DOUBLE)/\"deptno\" as div from \"hr\".\"emps\")") + .explainContains("BindableAggregate(group=[{}], _MIN=[MIN($0)])\n" + + " BindableProject(DIV=[/(CAST($0):DOUBLE NOT NULL, $1)])\n" + + " BindableTableScan(table=[[hr, emps]])") + .returns("_MIN=10.0\n"); + } + } /** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-2224">[CALCITE-2224]