Julian Hyde created CALCITE-1774:
------------------------------------
Summary: Allow rules to be registered during planning process
Key: CALCITE-1774
URL: https://issues.apache.org/jira/browse/CALCITE-1774
Project: Calcite
Issue Type: Bug
Reporter: Julian Hyde
Assignee: Julian Hyde
Allow rules to be registered during planning process.
At present, if you create a query via SQL, {{SqlToRelConverter}} calls
[Table.toRel|https://calcite.apache.org/apidocs/org/apache/calcite/plan/RelOptTable.html#toRel-org.apache.calcite.plan.RelOptTable.ToRelContext-]
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|https://calcite.apache.org/apidocs/org/apache/calcite/rel/RelNode.html#onRegister-org.apache.calcite.plan.RelOptPlanner-]
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:
{code}
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);
{code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)