You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Jesus Camacho Rodriguez (JIRA)" <ji...@apache.org> on 2018/09/16 18:36:00 UTC
[jira] [Resolved] (CALCITE-2563) Materialized view rewriting may
swap columns in equivalent classes incorrectly
[ https://issues.apache.org/jira/browse/CALCITE-2563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jesus Camacho Rodriguez resolved CALCITE-2563.
----------------------------------------------
Resolution: Fixed
Fix Version/s: 1.18.0
Fixed in [5f8c06f03|http://git-wip-us.apache.org/repos/asf/calcite/commit/5f8c06f03].
Thanks for the pointer [~julianhyde]. They seem to target similar problem. I will take a look and may replace it (extending EquivalenceSet if anything is missing). I was planning to split AbstractMaterializedViewRule too, but I have not found the time yet.
> Materialized view rewriting may swap columns in equivalent classes incorrectly
> ------------------------------------------------------------------------------
>
> Key: CALCITE-2563
> URL: https://issues.apache.org/jira/browse/CALCITE-2563
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.17.0
> Reporter: Vladimir Sitnikov
> Assignee: Jesus Camacho Rodriguez
> Priority: Major
> Fix For: 1.18.0
>
>
> https://github.com/apache/calcite/blob/323200507b72fec152e2f557b3f7f2209a042fe4/core/src/main/java/org/apache/calcite/rel/rules/AbstractMaterializedViewRule.java#L2542
> {code:java}
> Set<RexTableInputRef> c1 = nodeToEquivalenceClass.get(p1);
> Set<RexTableInputRef> c2 = nodeToEquivalenceClass.get(p2);
> if (c1 != null && c2 != null) {
> // Both present, we need to merge
> if (c1.size() < c2.size()) {
> // We swap them to merge
> c1 = c2; // <-- HERE. Should c1 and c2 be actually swapped?
> p1 = p2; // <-- What does this mean? p1 and p2 are not used. Should they be swapped as well just in case
> }
> for (RexTableInputRef newRef : c2) {
> c1.add(newRef);
> nodeToEquivalenceClass.put(newRef, c1);
> }
> {code}
> It looks like c1 vs c2 swap is missing, and a mere c1=c2 is used.
> It would likely produce weird results.
> /cc [~jcamachorodriguez]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)