Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
Allow rules to be registered during planning process.
At present, if you create a query via SQL, SqlToRelConverter calls Table.toRel on each TableScan. But if you create an equivalent query using RelBuilder those tables remain LogicalTableScan, and only get converted into physical tables when TableScanRule is called during planning.
Why is that a problem? Because physical tables, such as DruidQuery, register the rules they need when their override of RelNode.onRegister is called. But if planning has already started, registering those rules will not cause matches to be added to the queue.
For CALCITE-1769 I've added a hacky workaround to [Prepare.optimize], viz:
new RelVisitor() { @Override public void visit(RelNode node, int ordinal, RelNode parent) { if (node instanceof TableScan) { final RelOptCluster cluster = node.getCluster(); final RelOptTable.ToRelContext context = RelOptUtil.getContext(cluster); final RelNode r = node.getTable().toRel(context); planner.registerClass(r); } super.visit(node, ordinal, parent); } }.go(root.rel);
Attachments
Issue Links
- is related to
-
CALCITE-1536 Initialize cluster before planner
- Open
-
CALCITE-473 Create a wrapper Program to support the ability to enable/disable rules
- Open