Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1774

Allow rules to be registered during planning process

    XMLWordPrintableJSON

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

          Activity

            People

              Unassigned Unassigned
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: