Java Code Examples for org.apache.calcite.rel.logical.LogicalProject#getCluster()
The following examples show how to use
org.apache.calcite.rel.logical.LogicalProject#getCluster() .
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: IncrementalUpdateUtils.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public RelNode visit(LogicalProject project) { RelNode input = project.getInput().accept(this); RelDataType incomingRowType = input.getRowType(); List<RexNode> newProjects; RelDataTypeField modField = incomingRowType.getField(UPDATE_COLUMN, false, false); if (modField == null) { return project; } newProjects = FluentIterable.from(project.getProjects()) .append(new RexInputRef(modField.getIndex(), modField.getType())) .toList(); FieldInfoBuilder fieldInfoBuilder = new FieldInfoBuilder(project.getCluster().getTypeFactory()); for (RelDataTypeField field : project.getRowType().getFieldList()) { fieldInfoBuilder.add(field); } fieldInfoBuilder.add(UPDATE_COLUMN, modField.getType()); return new LogicalProject( project.getCluster(), project.getTraitSet(), input, newProjects, fieldInfoBuilder.build() ); }
Example 2
Source File: GeodeRules.java From calcite with Apache License 2.0 | 5 votes |
@Override public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelTraitSet traitSet = project.getTraitSet().replace(out); return new GeodeProject( project.getCluster(), traitSet, convert(project.getInput(), out), project.getProjects(), project.getRowType()); }
Example 3
Source File: CassandraRules.java From calcite with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelTraitSet traitSet = project.getTraitSet().replace(out); return new CassandraProject(project.getCluster(), traitSet, convert(project.getInput(), out), project.getProjects(), project.getRowType()); }
Example 4
Source File: MongoRules.java From calcite with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelTraitSet traitSet = project.getTraitSet().replace(out); return new MongoProject(project.getCluster(), traitSet, convert(project.getInput(), out), project.getProjects(), project.getRowType()); }
Example 5
Source File: ProjectCalcMergeRule.java From Bats with Apache License 2.0 | 4 votes |
public void onMatch(RelOptRuleCall call) { final LogicalProject project = call.rel(0); final LogicalCalc calc = call.rel(1); // Don't merge a project which contains windowed aggregates onto a // calc. That would effectively be pushing a windowed aggregate down // through a filter. Transform the project into an identical calc, // which we'll have chance to merge later, after the over is // expanded. final RelOptCluster cluster = project.getCluster(); RexProgram program = RexProgram.create( calc.getRowType(), project.getProjects(), null, project.getRowType(), cluster.getRexBuilder()); if (RexOver.containsOver(program)) { LogicalCalc projectAsCalc = LogicalCalc.create(calc, program); call.transformTo(projectAsCalc); return; } // Create a program containing the project node's expressions. final RexBuilder rexBuilder = cluster.getRexBuilder(); final RexProgramBuilder progBuilder = new RexProgramBuilder( calc.getRowType(), rexBuilder); for (Pair<RexNode, String> field : project.getNamedProjects()) { progBuilder.addProject(field.left, field.right); } RexProgram topProgram = progBuilder.getProgram(); RexProgram bottomProgram = calc.getProgram(); // Merge the programs together. RexProgram mergedProgram = RexProgramBuilder.mergePrograms( topProgram, bottomProgram, rexBuilder); final LogicalCalc newCalc = LogicalCalc.create(calc.getInput(), mergedProgram); call.transformTo(newCalc); }
Example 6
Source File: ElasticsearchProjectRule.java From dk-fitting with Apache License 2.0 | 4 votes |
@Override public RelNode convert(RelNode relNode) { final LogicalProject project = (LogicalProject) relNode; final RelTraitSet traitSet = project.getTraitSet().replace(getOutTrait()); return new ElasticsearchProject(project.getCluster(), traitSet, convert(project.getInput(), getOutTrait()), project.getProjects(), project.getRowType()); }
Example 7
Source File: ElasticsearchProjectRule.java From dk-fitting with Apache License 2.0 | 4 votes |
@Override public RelNode convert(RelNode relNode) { final LogicalProject project = (LogicalProject) relNode; final RelTraitSet traitSet = project.getTraitSet().replace(getOutTrait()); return new ElasticsearchProject(project.getCluster(), traitSet, convert(project.getInput(), getOutTrait()), project.getProjects(), project.getRowType()); }
Example 8
Source File: PigRules.java From calcite with Apache License 2.0 | 4 votes |
public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelTraitSet traitSet = project.getTraitSet().replace(PigRel.CONVENTION); return new PigProject(project.getCluster(), traitSet, project.getInput(), project.getProjects(), project.getRowType()); }
Example 9
Source File: ElasticsearchRules.java From calcite with Apache License 2.0 | 4 votes |
@Override public RelNode convert(RelNode relNode) { final LogicalProject project = (LogicalProject) relNode; final RelTraitSet traitSet = project.getTraitSet().replace(out); return new ElasticsearchProject(project.getCluster(), traitSet, convert(project.getInput(), out), project.getProjects(), project.getRowType()); }
Example 10
Source File: ProjectCalcMergeRule.java From calcite with Apache License 2.0 | 4 votes |
public void onMatch(RelOptRuleCall call) { final LogicalProject project = call.rel(0); final LogicalCalc calc = call.rel(1); // Don't merge a project which contains windowed aggregates onto a // calc. That would effectively be pushing a windowed aggregate down // through a filter. Transform the project into an identical calc, // which we'll have chance to merge later, after the over is // expanded. final RelOptCluster cluster = project.getCluster(); RexProgram program = RexProgram.create( calc.getRowType(), project.getProjects(), null, project.getRowType(), cluster.getRexBuilder()); if (RexOver.containsOver(program)) { LogicalCalc projectAsCalc = LogicalCalc.create(calc, program); call.transformTo(projectAsCalc); return; } // Create a program containing the project node's expressions. final RexBuilder rexBuilder = cluster.getRexBuilder(); final RexProgramBuilder progBuilder = new RexProgramBuilder( calc.getRowType(), rexBuilder); for (Pair<RexNode, String> field : project.getNamedProjects()) { progBuilder.addProject(field.left, field.right); } RexProgram topProgram = progBuilder.getProgram(); RexProgram bottomProgram = calc.getProgram(); // Merge the programs together. RexProgram mergedProgram = RexProgramBuilder.mergePrograms( topProgram, bottomProgram, rexBuilder); final LogicalCalc newCalc = LogicalCalc.create(calc.getInput(), mergedProgram); call.transformTo(newCalc); }