This is an automated email from the ASF dual-hosted git repository.

jcamacho 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 90e69d4  [CALCITE-2953] LatticeTest.testTileAlgorithm2 and 
LatticeTest.testTileAlgorithm3 fail intermittently
90e69d4 is described below

commit 90e69d4188c02420027b51b11c315330759ec2ea
Author: Jesus Camacho Rodriguez <[email protected]>
AuthorDate: Wed Mar 27 07:35:54 2019 -0700

    [CALCITE-2953] LatticeTest.testTileAlgorithm2 and 
LatticeTest.testTileAlgorithm3 fail intermittently
    
    Close apache/calcite#1134
---
 .../java/org/apache/calcite/test/LatticeTest.java  | 33 ++++++++++++++++++----
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/core/src/test/java/org/apache/calcite/test/LatticeTest.java 
b/core/src/test/java/org/apache/calcite/test/LatticeTest.java
index c23a0de..ca7cacd 100644
--- a/core/src/test/java/org/apache/calcite/test/LatticeTest.java
+++ b/core/src/test/java/org/apache/calcite/test/LatticeTest.java
@@ -20,9 +20,12 @@ import org.apache.calcite.jdbc.CalciteSchema;
 import org.apache.calcite.materialize.Lattice;
 import org.apache.calcite.materialize.Lattices;
 import org.apache.calcite.materialize.MaterializationService;
+import org.apache.calcite.plan.RelOptPlanner;
 import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.rules.AbstractMaterializedViewRule;
 import org.apache.calcite.runtime.Hook;
 import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.test.CalciteAssert.AssertQuery;
 import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.TestUtil;
 
@@ -501,15 +504,33 @@ public class LatticeTest {
       String expectedExplain) {
     MaterializationService.setThreadLocal();
     MaterializationService.instance().clear();
-    foodmartLatticeModel(statisticProvider)
+    AssertQuery that = foodmartLatticeModel(statisticProvider)
         .query("select distinct t.\"the_year\", t.\"quarter\"\n"
             + "from \"foodmart\".\"sales_fact_1997\" as s\n"
             + "join \"foodmart\".\"time_by_day\" as t using (\"time_id\")\n")
-        .enableMaterializations(true)
-        // disable for MySQL; times out running star-join query
-        // disable for H2; it thinks our generated SQL has invalid syntax
-        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.MYSQL
-            && CalciteAssert.DB != CalciteAssert.DatabaseInstance.H2)
+        .enableMaterializations(true);
+
+    // Disable materialization rules from this test. For some reason, there is
+    // a weird interaction between these rules and the lattice rewriting that
+    // produces non-deterministic rewriting (even when only lattices are 
present).
+    // For more context, see
+    // <a 
href="https://issues.apache.org/jira/browse/CALCITE-2953";>[CALCITE-2953]</a>.
+    that.withHook(Hook.PLANNER, (Consumer<RelOptPlanner>) planner -> {
+      ImmutableList
+          .of(
+              AbstractMaterializedViewRule.INSTANCE_PROJECT_FILTER,
+              AbstractMaterializedViewRule.INSTANCE_FILTER,
+              AbstractMaterializedViewRule.INSTANCE_PROJECT_JOIN,
+              AbstractMaterializedViewRule.INSTANCE_JOIN,
+              AbstractMaterializedViewRule.INSTANCE_PROJECT_AGGREGATE,
+              AbstractMaterializedViewRule.INSTANCE_AGGREGATE)
+          .forEach(planner::removeRule);
+    });
+
+    // disable for MySQL; times out running star-join query
+    // disable for H2; it thinks our generated SQL has invalid syntax
+    that.enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.MYSQL
+        && CalciteAssert.DB != CalciteAssert.DatabaseInstance.H2)
         .explainContains(expectedExplain)
         .returnsUnordered("the_year=1997; quarter=Q1",
             "the_year=1997; quarter=Q2",

Reply via email to