[ 
https://issues.apache.org/jira/browse/CALCITE-5594?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

asdfgh19 updated CALCITE-5594:
------------------------------
    Description: 
  I added a test case to LatticeTest and it fails as shown below.
{code:java}
@Test void testLatticeWithNoMeasures2() {
  foodmartModel(" auto: false,\n"
      + "  tiles: [ {\n"
      + "    dimensions: [ 'the_year', ['t', 'month_of_year'] ],\n"
      + "    measures: [ ]\n"
      + "  } ]\n")
      .query("select \"the_year\", min(\"month_of_year\"), 
max(\"month_of_year\")\n"
          + "from \"foodmart\".\"sales_fact_1997\" as s\n"
          + "join \"foodmart\".\"time_by_day\" as t using (\"time_id\")\n"
          + "group by \"the_year\"")
      .enableMaterializations(true)
      .sameResultWithMaterializationsDisabled();
}{code}
  The explain looks like this, should the original count be replaced by 
sum(count) in the materialized view, like 
MaterializedViewRelOptRulesTest#testAggregateMaterializationAggregateFuncs2.
{code:java}
EnumerableAggregate(group=[{}], EXPR$0=[COUNT()])
  EnumerableTableScan(table=[[adhoc, m{32, 36} {code}

  was:
  I changed the test testLatticeWithNoMeasures in LatticeTest to the following 
and ran, it returned 4.

  After that I changed enableMaterializations to false and re-run, the result 
returned 86837.

  Wondering why the results returned from the materialized view and from the 
original table are inconsistent.
{code:java}
@Test void testLatticeWithNoMeasures() {
  foodmartModel(" auto: false,\n"
      + "  tiles: [ {\n"
      + "    dimensions: [ 'the_year', ['t', 'quarter'] ],\n"
      + "    measures: [ ]\n"
      + "  } ]\n")
      .query("select count(*)\n"
          + "from \"foodmart\".\"sales_fact_1997\" as s\n"
          + "join \"foodmart\".\"time_by_day\" as t using (\"time_id\")\n")
      .enableMaterializations(true)
      .returns(rs -> {
        try {
          while (rs.next()) {
            System.out.println(rs.getObject(1));
          }
        } catch (Exception e) {
          fail(e);
        }
      });
} {code}
  The explain looks like this, should the original count be replaced by 
sum(count) in the materialized view, like 
MaterializedViewRelOptRulesTest#testAggregateMaterializationAggregateFuncs2.
{code:java}
EnumerableAggregate(group=[{}], EXPR$0=[COUNT()])
  EnumerableTableScan(table=[[adhoc, m{32, 36} {code}


> AggregateStarTableRule optimized plan does not get the same result to the 
> original one
> --------------------------------------------------------------------------------------
>
>                 Key: CALCITE-5594
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5594
>             Project: Calcite
>          Issue Type: Test
>          Components: core
>    Affects Versions: 1.34.0
>            Reporter: asdfgh19
>            Priority: Minor
>
>   I added a test case to LatticeTest and it fails as shown below.
> {code:java}
> @Test void testLatticeWithNoMeasures2() {
>   foodmartModel(" auto: false,\n"
>       + "  tiles: [ {\n"
>       + "    dimensions: [ 'the_year', ['t', 'month_of_year'] ],\n"
>       + "    measures: [ ]\n"
>       + "  } ]\n")
>       .query("select \"the_year\", min(\"month_of_year\"), 
> max(\"month_of_year\")\n"
>           + "from \"foodmart\".\"sales_fact_1997\" as s\n"
>           + "join \"foodmart\".\"time_by_day\" as t using (\"time_id\")\n"
>           + "group by \"the_year\"")
>       .enableMaterializations(true)
>       .sameResultWithMaterializationsDisabled();
> }{code}
>   The explain looks like this, should the original count be replaced by 
> sum(count) in the materialized view, like 
> MaterializedViewRelOptRulesTest#testAggregateMaterializationAggregateFuncs2.
> {code:java}
> EnumerableAggregate(group=[{}], EXPR$0=[COUNT()])
>   EnumerableTableScan(table=[[adhoc, m{32, 36} {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to