@Override public LogicalCalc copy(RelTraitSet traitSet, RelNode child, RexProgram program) { return new LogicalCalc(getCluster(), traitSet, child, program); }
protected RelNode makeRel(RelOptCluster cluster, RelTraitSet traitSet, RelBuilder relBuilder, RelNode input, RexProgram program) { return LogicalCalc.create(input, program); }
public void onMatch(RelOptRuleCall call) { LogicalCalc calc = call.rel(0); RexProgram program = calc.getProgram(); if (!program.isTrivial()) { return; } RelNode input = calc.getInput(); input = call.getPlanner().register(input, calc); call.transformTo( convert( input, calc.getTraitSet())); } }
public RelNode convert(RelNode rel) { final LogicalCalc calc = (LogicalCalc) rel; final RelNode input = calc.getInput(); return EnumerableCalc.create( convert(input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)), calc.getProgram()); } }
public void onMatch(RelOptRuleCall call) { LogicalCalc calc = call.rel(0); // Expand decimals in every expression in this program. If no // expression changes, don't apply the rule. final RexProgram program = calc.getProgram(); if (!RexUtil.requiresDecimalExpansion(program, true)) { return; } final RexBuilder rexBuilder = calc.getCluster().getRexBuilder(); final RexShuttle shuttle = new DecimalShuttle(rexBuilder); RexProgramBuilder programBuilder = RexProgramBuilder.create( rexBuilder, calc.getInput().getRowType(), program.getExprList(), program.getProjectList(), program.getCondition(), program.getOutputRowType(), shuttle, true); final RexProgram newProgram = programBuilder.getProgram(); LogicalCalc newCalc = LogicalCalc.create(calc.getInput(), newProgram); call.transformTo(newCalc); }
@Override protected RelNode handle(RelNode rel) { if (!(rel instanceof LogicalCalc)) { return rel; } final LogicalCalc calc = (LogicalCalc) rel; final RexProgram program = calc.getProgram(); relBuilder.push(calc.getInput()); if (program.getCondition() != null) { relBuilder.filter( program.expandLocalRef(program.getCondition())); } if (!program.projectsOnlyIdentity()) { relBuilder.project( Lists.transform(program.getProjectList(), program::expandLocalRef), calc.getRowType().getFieldNames()); } return relBuilder.build(); } };
Permutation permutation1 = calc.getProgram().getPermutation(); if (permutation1 != null) { Permutation permutation2 = permutation.product(permutation1); null, typeFactory.createStructType(outputTypeList, outputNameList)); return LogicalCalc.create(rel, program);
/** * Returns whether a relational expression can be implemented solely in a * given {@link RelType}. * * @param rel Calculation relational expression * @param relTypeName Name of a {@link RelType} * @return Whether relational expression can be implemented */ protected boolean canImplement(LogicalCalc rel, String relTypeName) { for (RelType relType : relTypes) { if (relType.name.equals(relTypeName)) { return relType.canImplement(rel.getProgram()); } } throw new AssertionError("unknown type " + relTypeName); }
public static LogicalCalc create(final RelNode input, final RexProgram program) { final RelOptCluster cluster = input.getCluster(); final RelMetadataQuery mq = cluster.getMetadataQuery(); final RelTraitSet traitSet = cluster.traitSet() .replace(Convention.NONE) .replaceIfs(RelCollationTraitDef.INSTANCE, () -> RelMdCollation.calc(mq, input, program)) .replaceIf(RelDistributionTraitDef.INSTANCE, () -> RelMdDistribution.calc(mq, input, program)); return new LogicalCalc(cluster, traitSet, input, program); }
public void onMatch(RelOptRuleCall call) { LogicalCalc calc = call.rel(0); // Expand decimals in every expression in this program. If no // expression changes, don't apply the rule. final RexProgram program = calc.getProgram(); if (!RexUtil.requiresDecimalExpansion(program, true)) { return; } final RexBuilder rexBuilder = calc.getCluster().getRexBuilder(); final RexShuttle shuttle = new DecimalShuttle(rexBuilder); RexProgramBuilder programBuilder = RexProgramBuilder.create( rexBuilder, calc.getInput().getRowType(), program.getExprList(), program.getProjectList(), program.getCondition(), program.getOutputRowType(), shuttle, true); final RexProgram newProgram = programBuilder.getProgram(); LogicalCalc newCalc = LogicalCalc.create(calc.getInput(), newProgram); call.transformTo(newCalc); }
@Override protected RelNode handle(RelNode rel) { if (!(rel instanceof LogicalCalc)) { return rel; } final LogicalCalc calc = (LogicalCalc) rel; final RexProgram program = calc.getProgram(); relBuilder.push(calc.getInput()); if (program.getCondition() != null) { relBuilder.filter( program.expandLocalRef(program.getCondition())); } if (!program.projectsOnlyIdentity()) { relBuilder.project( Lists.transform(program.getProjectList(), program::expandLocalRef), calc.getRowType().getFieldNames()); } return relBuilder.build(); } };
public RelNode convert(RelNode rel) { final LogicalCalc calc = (LogicalCalc) rel; final RelNode input = calc.getInput(); return EnumerableCalc.create( convert(input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)), calc.getProgram()); } }
Permutation permutation1 = calc.getProgram().getPermutation(); if (permutation1 != null) { Permutation permutation2 = permutation.product(permutation1); null, typeFactory.createStructType(outputTypeList, outputNameList)); return LogicalCalc.create(rel, program);
/** * Returns whether a relational expression can be implemented solely in a * given {@link RelType}. * * @param rel Calculation relational expression * @param relTypeName Name of a {@link RelType} * @return Whether relational expression can be implemented */ protected boolean canImplement(LogicalCalc rel, String relTypeName) { for (RelType relType : relTypes) { if (relType.name.equals(relTypeName)) { return relType.canImplement(rel.getProgram()); } } throw new AssertionError("unknown type " + relTypeName); }
public static LogicalCalc create(final RelNode input, final RexProgram program) { final RelOptCluster cluster = input.getCluster(); final RelMetadataQuery mq = cluster.getMetadataQuery(); final RelTraitSet traitSet = cluster.traitSet() .replace(Convention.NONE) .replaceIfs(RelCollationTraitDef.INSTANCE, () -> RelMdCollation.calc(mq, input, program)) .replaceIf(RelDistributionTraitDef.INSTANCE, () -> RelMdDistribution.calc(mq, input, program)); return new LogicalCalc(cluster, traitSet, input, program); }
if (calc.getProgram().containsAggs()) { return; final RexProgramBuilder progBuilder = new RexProgramBuilder( calc.getRowType(), rexBuilder); progBuilder.addIdentity(); progBuilder.addCondition(filter.getCondition()); RexProgram topProgram = progBuilder.getProgram(); RexProgram bottomProgram = calc.getProgram(); rexBuilder); final LogicalCalc newCalc = LogicalCalc.create(calc.getInput(), mergedProgram); call.transformTo(newCalc);
public void onMatch(RelOptRuleCall call) { LogicalCalc calc = call.rel(0); RexProgram program = calc.getProgram(); if (!program.isTrivial()) { return; } RelNode input = calc.getInput(); input = call.getPlanner().register(input, calc); call.transformTo( convert( input, calc.getTraitSet())); } }
protected RelNode makeRel(RelOptCluster cluster, RelTraitSet traitSet, RelBuilder relBuilder, RelNode input, RexProgram program) { return LogicalCalc.create(input, program); }
@Override public LogicalCalc copy(RelTraitSet traitSet, RelNode child, RexProgram program) { return new LogicalCalc(getCluster(), traitSet, child, program); }
&& ((LogicalCalc) rel).getProgram().isTrivial()) { rel = rel.getInput(0);