Skip to content

Commit

Permalink
[CALCITE-4276] MaterializedViewOnlyAggregateRule performs invalid rew…
Browse files Browse the repository at this point in the history
…rite on query that contains join and time-rollup function (FLOOR) (Justin Swett)

Without the fix, MaterializedViewOnlyAggregateRule gets a
field ordinal wrong, which manifests as a type mismatch
something like this:

  java.lang.AssertionError: type mismatch:
      ref: TIMESTAMP(3)
      input: INTEGER NOT NULL
    at org.apache.calcite.util.Litmus$1.fail(Litmus.java:32)
    at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:2207)
    at org.apache.calcite.rex.RexChecker.visitInputRef(RexChecker.java:129)

It's difficult to see among all the refactoring, but the fix
is just two lines; in MaterializedViewOnlyAggregateRule, change

  final int k = find(topViewProject, r);

to

   final int j = find(viewNode, r);
   final int k = find(topViewProject, j);

and the problem goes away.
  • Loading branch information
Justin Swett authored and julianhyde committed Mar 4, 2021
1 parent 00d1086 commit 0fb14d5
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 163 deletions.
Loading

0 comments on commit 0fb14d5

Please sign in to comment.