You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2021/03/04 01:59:00 UTC
[jira] [Resolved] (CALCITE-4276) Rewriting for materialized view
will project wrong input
[ https://issues.apache.org/jira/browse/CALCITE-4276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Hyde resolved CALCITE-4276.
----------------------------------
Fix Version/s: 1.27.0
Resolution: Fixed
Fixed in [0fb14d55|https://github.com/apache/calcite/commit/0fb14d553764f2a993ec56db4a36de2713ac1206]; thank you for your contribution, [~jswett]!
> Rewriting for materialized view will project wrong input
> --------------------------------------------------------
>
> Key: CALCITE-4276
> URL: https://issues.apache.org/jira/browse/CALCITE-4276
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Justin Swett
> Assignee: Julian Hyde
> Priority: Major
> Fix For: 1.27.0
>
> Attachments: TemporalMaterializationWithJoinsTest.java
>
>
> When MaterializedViewOnlyAggregateRule does its rewrite it will sometimes produce a project above the materialized view that references the incorrect input. For example,
> Materialization Rel:
> {noformat}
> LogicalAggregate(group=[{0}], ORDER_ITEMS.ORDER_SIZE=[COUNT()], ORDER_ITEMS.ORDER_SUM=[$SUM0($1)])
> LogicalProject(ORDER_ID=[$1], AMOUNT=[$2])
> 2(table=[[orders_items]]){noformat}
> Query Rel:
> {noformat}
> LogicalAggregate(group=[{0}], agg#0=[COUNT()])
> LogicalProject($f0=[FLOOR($1, FLAG(YEAR))])
> LogicalJoin(condition=[=($0, $1)], joinType=[inner])
> LogicalProject(ORDER_ID=[$1])
> 2(table=[[orders_items]])
> LogicalProject(ID=[$0], CREATED_AT=[$4])
> 4(table=[[orders]]){noformat}
> Will Produce the following rel after MaterializedViewOnlyAggregateRule fires:
> {noformat}
> LogicalAggregate(group=[{8}], agg#0=[$SUM0($1)])
> LogicalProject(ORDER_ID=[$0], ORDER_ITEMS.ORDER_SIZE=[$1], ORDER_ITEMS.ORDER_SUM=[$2], ID=[$3], USER_ID=[$4], ORDER_AMOUNT=[$5], STATUS=[$6], CREATED_AT=[$7], $f8=[FLOOR($0, FLAG(YEAR))])
> LogicalFilter(condition=[=($0, $3)])
> LogicalJoin(condition=[true], joinType=[inner])
> 6(table=[[testing_mv]])
> 4(table=[[orders]]){noformat}
> Notice the "*$f8=[FLOOR($0, FLAG(YEAR))*" the $0 is pointing to the test_mv order_id field. It should be point to $7 for this test, so perhaps something with the filter?
> The attached test case reproduces the issue.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)