/** Converts a relational expression to use a * {@link org.apache.calcite.schema.impl.StarTable} defined in {@code schema}. * Uses the first star table that fits. */ private Iterable<Callback> useStar(CalciteSchema schema, RelNode queryRel) { List<CalciteSchema.TableEntry> starTables = Schemas.getStarTables(schema.root()); if (starTables.isEmpty()) { // Don't waste effort converting to leaf-join form. return ImmutableList.of(); } final List<Callback> list = new ArrayList<>(); final RelNode rel2 = RelOptMaterialization.toLeafJoinForm(queryRel); for (CalciteSchema.TableEntry starTable : starTables) { final Table table = starTable.getTable(); assert table instanceof StarTable; RelOptTableImpl starRelOptTable = RelOptTableImpl.create(catalogReader, table.getRowType(typeFactory), starTable, null); final RelNode rel3 = RelOptMaterialization.tryUseStar(rel2, starRelOptTable); if (rel3 != null) { list.add(new Callback(rel3, starTable, starRelOptTable)); } } return list; }
/** Converts a relational expression to use a * {@link org.apache.calcite.schema.impl.StarTable} defined in {@code schema}. * Uses the first star table that fits. */ private Iterable<Callback> useStar(CalciteSchema schema, RelNode queryRel) { List<CalciteSchema.TableEntry> starTables = Schemas.getStarTables(schema.root()); if (starTables.isEmpty()) { // Don't waste effort converting to leaf-join form. return ImmutableList.of(); } final List<Callback> list = new ArrayList<>(); final RelNode rel2 = RelOptMaterialization.toLeafJoinForm(queryRel); for (CalciteSchema.TableEntry starTable : starTables) { final Table table = starTable.getTable(); assert table instanceof StarTable; RelOptTableImpl starRelOptTable = RelOptTableImpl.create(catalogReader, table.getRowType(typeFactory), starTable, null); final RelNode rel3 = RelOptMaterialization.tryUseStar(rel2, starRelOptTable); if (rel3 != null) { list.add(new Callback(rel3, starTable, starRelOptTable)); } } return list; }