Repository: calcite Updated Branches: refs/heads/master db3794c25 -> 6981778c5
[CALCITE-2099] Incorrect code generated for UNION (Zhen Wang) Close apache/calcite#625 Project: http://git-wip-us.apache.org/repos/asf/calcite/repo Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/bb57919d Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/bb57919d Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/bb57919d Branch: refs/heads/master Commit: bb57919df89cadeac117a966f4e9a74187267887 Parents: db3794c Author: zhen wang <[email protected]> Authored: Mon Feb 12 18:54:06 2018 +0800 Committer: Julian Hyde <[email protected]> Committed: Tue Feb 13 21:44:47 2018 -0800 ---------------------------------------------------------------------- .../adapter/enumerable/EnumerableUnion.java | 4 --- core/src/test/resources/sql/misc.iq | 36 ++++++++++++++++++++ .../java/org/apache/calcite/test/CsvTest.java | 10 +++++- 3 files changed, 45 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/calcite/blob/bb57919d/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableUnion.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableUnion.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableUnion.java index 2df6550..a3fb07c 100644 --- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableUnion.java +++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableUnion.java @@ -62,10 +62,6 @@ public class EnumerableUnion extends Union implements EnumerableRel { Expressions.list(childExp) .appendIfNotNull(result.physType.comparer())); } - - // Once the first input has chosen its format, ask for the same for - // other inputs. - pref = pref.of(result.format); } builder.add(unionExp); http://git-wip-us.apache.org/repos/asf/calcite/blob/bb57919d/core/src/test/resources/sql/misc.iq ---------------------------------------------------------------------- diff --git a/core/src/test/resources/sql/misc.iq b/core/src/test/resources/sql/misc.iq index cac239d..b9d64cd 100644 --- a/core/src/test/resources/sql/misc.iq +++ b/core/src/test/resources/sql/misc.iq @@ -1030,6 +1030,42 @@ Expression 'DEPTNO' is not being grouped !use scott +# [CALCITE-2099] Incorrect code generated for UNION +select count(*) as c from "scott".emp group by deptno +union +select count(*) as c from "scott".emp group by deptno; ++---+ +| C | ++---+ +| 3 | +| 5 | +| 6 | ++---+ +(3 rows) + +!ok + +# Similar +select count(*) as c from "scott".emp group by job +union all +select count(*) as c from "scott".dept group by deptno; ++---+ +| C | ++---+ +| 1 | +| 1 | +| 1 | +| 1 | +| 1 | +| 2 | +| 3 | +| 4 | +| 4 | ++---+ +(9 rows) + +!ok + # [CALCITE-1864] Allow NULL literal as argument select count(*) as c from "scott".emp where empno > null; +---+ http://git-wip-us.apache.org/repos/asf/calcite/blob/bb57919d/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java ---------------------------------------------------------------------- diff --git a/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java b/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java index 8f7f9d8..b739a9d 100644 --- a/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java +++ b/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java @@ -483,7 +483,15 @@ public class CsvTest { "C=1; T=1996-09-03") .ok(); } - @Test public void testBoolean() throws SQLException { + + @Test public void testUnionGroupByWithoutGroupKey() { + final String sql = "select count(*) as c1 from EMPS group by NAME\n" + + "union\n" + + "select count(*) as c1 from EMPS group by NAME"; + sql("model", sql).ok(); + } + + @Test public void testBoolean() { sql("smart", "select empno, slacker from emps where slacker") .returns("EMPNO=100; SLACKER=true").ok(); }
