org.apache.calcite.plan.RelOptLattice Java Examples
The following examples show how to use
org.apache.calcite.plan.RelOptLattice.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Programs.java From Bats with Apache License 2.0 | 6 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { planner.clear(); for (RelOptRule rule : ruleSet) { planner.addRule(rule); } for (RelOptMaterialization materialization : materializations) { planner.addMaterialization(materialization); } for (RelOptLattice lattice : lattices) { planner.addLattice(lattice); } if (!rel.getTraitSet().equals(requiredOutputTraits)) { rel = planner.changeTraits(rel, requiredOutputTraits); } planner.setRoot(rel); return planner.findBestExp(); }
Example #2
Source File: Programs.java From calcite with Apache License 2.0 | 6 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { planner.clear(); for (RelOptRule rule : ruleSet) { planner.addRule(rule); } for (RelOptMaterialization materialization : materializations) { planner.addMaterialization(materialization); } for (RelOptLattice lattice : lattices) { planner.addLattice(lattice); } if (!rel.getTraitSet().equals(requiredOutputTraits)) { rel = planner.changeTraits(rel, requiredOutputTraits); } planner.setRoot(rel); return planner.findBestExp(); }
Example #3
Source File: Programs.java From calcite with Apache License 2.0 | 6 votes |
/** Creates a program that executes a {@link HepProgram}. */ public static Program of(final HepProgram hepProgram, final boolean noDag, final RelMetadataProvider metadataProvider) { return (planner, rel, requiredOutputTraits, materializations, lattices) -> { final HepPlanner hepPlanner = new HepPlanner(hepProgram, null, noDag, null, RelOptCostImpl.FACTORY); List<RelMetadataProvider> list = new ArrayList<>(); if (metadataProvider != null) { list.add(metadataProvider); } hepPlanner.registerMetadataProviders(list); for (RelOptMaterialization materialization : materializations) { hepPlanner.addMaterialization(materialization); } for (RelOptLattice lattice : lattices) { hepPlanner.addLattice(lattice); } RelMetadataProvider plannerChain = ChainedRelMetadataProvider.of(list); rel.getCluster().setMetadataProvider(plannerChain); hepPlanner.setRoot(rel); return hepPlanner.findBestExp(); }; }
Example #4
Source File: SqlWorker.java From quark with Apache License 2.0 | 6 votes |
private void populateMaterializationsAndLattice( QuarkMaterializeCluster.RelOptPlannerHolder plannerHolder, CalciteSchema rootSchema) { if (materializations == null) { materializations = MaterializationService.instance().query(rootSchema); } Materializer materializer = new Materializer(materializations); materializer.populateMaterializations(context.getPrepareContext(), plannerHolder); List<CalciteSchema.LatticeEntry> lattices = Schemas.getLatticeEntries(rootSchema); for (CalciteSchema.LatticeEntry lattice : lattices) { final CalciteSchema.TableEntry starTable = lattice.getStarTable(); final JavaTypeFactory typeFactory = context.getTypeFactory(); final RelOptTableImpl starRelOptTable = RelOptTableImpl.create(catalogReader, starTable.getTable().getRowType(typeFactory), starTable, null); plannerHolder.getPlanner().addLattice( new RelOptLattice(lattice.getLattice(), starRelOptTable)); } }
Example #5
Source File: FilterAggStarRule.java From quark with Apache License 2.0 | 6 votes |
/** * Checks if filter satisfies the lattice filter * i.e., it needs data captured by the lattice */ private boolean isLatticeFilterSatisfied(final RelOptLattice lattice, final Filter filter, final StarTable.StarTableScan scan) { if (lattice.lattice.filter == null) { return true; } RexExecutorImpl rexImpl = (RexExecutorImpl) (scan.getCluster().getPlanner().getExecutor()); RexImplicationChecker solver = new RexImplicationChecker(scan.getCluster().getRexBuilder(), rexImpl, scan.getRowType()); try { return solver.implies(filter.getCondition(), lattice.lattice.filter); } catch (Exception e) { LOG.debug("Exception thrown while solving " + filter.getCondition() + " => " + lattice.lattice.filter); return false; } }
Example #6
Source File: SqlWorker.java From quark with Apache License 2.0 | 5 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { planner.clear(); planner.addRelTraitDef(ConventionTraitDef.INSTANCE); planner.addRelTraitDef(RelCollationTraitDef.INSTANCE); //((VolcanoPlanner) planner).registerAbstractRelationalRules(); RelOptUtil.registerAbstractRels(planner); for (RelOptRule rule : ruleSet) { planner.addRule(rule); } planner.addRule(Bindables.BINDABLE_TABLE_SCAN_RULE); planner.addRule(ProjectTableScanRule.INSTANCE); planner.addRule(ProjectTableScanRule.INTERPRETER); planner.addRule(EnumerableInterpreterRule.INSTANCE); final CalciteSchema rootSchema = CalciteSchema.from(context.getRootSchema()); planner.setExecutor(new RexExecutorImpl(null)); planner.setRoot(rel); MaterializationService.setThreadLocal(materializationService); plannerHolder.setPlanner(planner); populateMaterializationsAndLattice(plannerHolder, rootSchema); if (!rel.getTraitSet().equals(requiredOutputTraits)) { rel = planner.changeTraits(rel, requiredOutputTraits); planner.setRoot(rel); } RelOptPlanner planner2 = planner.chooseDelegate(); return planner2.findBestExp(); }
Example #7
Source File: Programs.java From calcite with Apache License 2.0 | 5 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); return new RelFieldTrimmer(null, relBuilder).trim(rel); }
Example #8
Source File: Programs.java From calcite with Apache License 2.0 | 5 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { final CalciteConnectionConfig config = planner.getContext().unwrap(CalciteConnectionConfig.class); if (config != null && config.forceDecorrelate()) { final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); return RelDecorrelator.decorrelateQuery(rel, relBuilder); } return rel; }
Example #9
Source File: Programs.java From calcite with Apache License 2.0 | 5 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { for (Program program : programs) { rel = program.run( planner, rel, requiredOutputTraits, materializations, lattices); } return rel; }
Example #10
Source File: ForcedRulesProgram.java From calcite-sql-rewriter with Apache License 2.0 | 5 votes |
@Override public RelNode run(RelOptPlanner relOptPlanner, RelNode relNode, RelTraitSet relTraitSet, List<RelOptMaterialization> relOptMaterializationList, List<RelOptLattice> list1) { logger.debug("Running forced rules on:\n" + RelOptUtil.toString(relNode)); return replace(relNode, rules, relBuilderFactoryFactory.create(relOptPlanner.getContext())); }
Example #11
Source File: SequenceProgram.java From calcite-sql-rewriter with Apache License 2.0 | 5 votes |
@Override public RelNode run(RelOptPlanner relOptPlanner, RelNode relNode, RelTraitSet relTraitSet, List<RelOptMaterialization> relOptMaterializationList, List<RelOptLattice> relOptLatticeList) { for (Program program : programs) { relNode = program.run(relOptPlanner, relNode, relTraitSet, relOptMaterializationList, relOptLatticeList); logger.debug("After running " + program + ":\n" + RelOptUtil.toString(relNode)); } return relNode; }
Example #12
Source File: Programs.java From Bats with Apache License 2.0 | 5 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); return new RelFieldTrimmer(null, relBuilder).trim(rel); }
Example #13
Source File: Programs.java From Bats with Apache License 2.0 | 5 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { final CalciteConnectionConfig config = planner.getContext().unwrap(CalciteConnectionConfig.class); if (config != null && config.forceDecorrelate()) { final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); return RelDecorrelator.decorrelateQuery(rel, relBuilder); } return rel; }
Example #14
Source File: Programs.java From Bats with Apache License 2.0 | 5 votes |
public RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices) { for (Program program : programs) { rel = program.run( planner, rel, requiredOutputTraits, materializations, lattices); } return rel; }
Example #15
Source File: Program.java From Bats with Apache License 2.0 | 4 votes |
RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices);
Example #16
Source File: Program.java From calcite with Apache License 2.0 | 4 votes |
RelNode run(RelOptPlanner planner, RelNode rel, RelTraitSet requiredOutputTraits, List<RelOptMaterialization> materializations, List<RelOptLattice> lattices);
Example #17
Source File: VolcanoPlanner.java From Bats with Apache License 2.0 | 4 votes |
@Override public RelOptLattice getLattice(RelOptTable table) { return latticeByName.get(table.getQualifiedName()); }
Example #18
Source File: VolcanoPlanner.java From Bats with Apache License 2.0 | 4 votes |
@Override public void addLattice(RelOptLattice lattice) { latticeByName.put(lattice.starRelOptTable.getQualifiedName(), lattice); }
Example #19
Source File: VolcanoPlanner.java From calcite with Apache License 2.0 | 4 votes |
@Override public void addLattice(RelOptLattice lattice) { latticeByName.put(lattice.starRelOptTable.getQualifiedName(), lattice); }
Example #20
Source File: VolcanoPlanner.java From calcite with Apache License 2.0 | 4 votes |
@Override public RelOptLattice getLattice(RelOptTable table) { return latticeByName.get(table.getQualifiedName()); }