From bd07c111a59ce0cce7055e05f7d19653502f91e4 Mon Sep 17 00:00:00 2001 From: Julian Hyde Date: Thu, 5 Sep 2024 12:35:34 -0700 Subject: [PATCH 1/2] Test case for [CALCITE-6525] Query with one-to-many join of measure to regular table --- core/src/test/resources/sql/measure.iq | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/test/resources/sql/measure.iq b/core/src/test/resources/sql/measure.iq index aa8ee999fd77..143cf5c527e1 100644 --- a/core/src/test/resources/sql/measure.iq +++ b/core/src/test/resources/sql/measure.iq @@ -395,6 +395,16 @@ where job = 'MANAGER'; !ok +!if (false) { +# [CALCITE-6525] Query with one-to-many join of measure to regular table +with deptm as + (select deptno, dname, avg(char_length(dname)) as measure m + from dept) +select aggregate(m) as m +from deptm join emp using (deptno); +!ok +!} + # Measure that references another measure select * from ( From 6caca00d924751822dcfaaffd93af7a14656ec1b Mon Sep 17 00:00:00 2001 From: Julian Hyde Date: Thu, 5 Sep 2024 12:55:30 -0700 Subject: [PATCH 2/2] Enable test cases --- .../java/org/apache/calcite/test/RelOptRulesTest.java | 3 +-- .../org/apache/calcite/test/RelOptRulesTest.xml | 11 ++++++----- core/src/test/resources/sql/measure.iq | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java index 6c672b72ab3b..2452b80e3592 100644 --- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java +++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java @@ -6062,7 +6062,6 @@ private HepProgram getTransitiveProgram() { .check(); } - @Disabled @Test void testMeasureJoin() { final String sql = "with deptm as\n" + " (select deptno, name, avg(char_length(name)) as measure m\n" @@ -6075,7 +6074,7 @@ private HepProgram getTransitiveProgram() { t.withOperatorTable(opTab -> SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable( SqlLibrary.STANDARD, SqlLibrary.CALCITE))) // for AGGREGATE - .withRule(MeasureRules.AGGREGATE, + .withRule(MeasureRules.AGGREGATE2, CoreRules.PROJECT_MERGE, MeasureRules.PROJECT) .check(); diff --git a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml index 0ebdb9b469d4..6bedf930b814 100644 --- a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml +++ b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml @@ -6753,10 +6753,11 @@ LogicalProject(DEPTNO=[$0], C1=[$1]) - @@ -6774,7 +6775,7 @@ LogicalProject(DEPTNO=[$0], M=[$1])