Hi contributors,

I am trying to retrieve materialized view query rewrite from Calcite.

In order to do that, I have created a planner and wanted to get the
optimized relNode after applying Materializations which is equivalent to
applying [1] present in Prepare class of Calcite. However, I am facing
difficulties while trying to do so. I have so far tried:

1) Doing exactly what's being done in [1] but it turned out some members of
<Prepare.Materializations> can't be accessed outside package, so I am
unable to obtain       RelOptMaterialization from it.

2) I figured I only need (tableRel, queryRel) relNodes for making a
RelOptMaterialization which can be made from Materialization.sql but when I
try to so with the a planner instance (i.e. planner.rel(validatedNode).rel)
: I am getting errors:

i) When using the different planner instance:
Relational expression LogicalFilter#24 belongs to a different planner than
is currently being used.
ii) When using the same planner instance:
java.lang.IllegalArgumentException: cannot move to STATE_2_READY from
STATE_5_CONVERTED

I figured out that maybe SqlToRelConverter could help out in this use case
but I don't know how to get instances of CatalogReader, Validator,
ViewExpander and SqlRexConvertletTable.

Can someone point out where I am going wrong and what's the correct way to
go about it.

[1]
https://github.com/apache/calcite/blob/73023148e7f37d494f6caf92b01b090f6dde13cd/core/src/main/java/org/apache/calcite/prepare/Prepare.java#L320
-- 
Thanks & Regards

Shubham Kumar

Reply via email to