public RelNode createProject(RelNode child, List<RexNode> childExprs, List<String> fieldNames) { return CalcRel.createProject(child, childExprs, fieldNames); } }
/** * Constructs a CalcRelSplitter. * * @param calc CalcRel to split * @param relTypes Array of rel types, e.g. {Java, Fennel}. Must be * distinct. */ CalcRelSplitter(CalcRel calc, RelType [] relTypes) { for (int i = 0; i < relTypes.length; i++) { assert relTypes[i] != null; for (int j = 0; j < i; j++) { assert relTypes[i] != relTypes[j] : "Rel types must be distinct"; } } this.program = calc.getProgram(); this.cluster = calc.getCluster(); this.traits = calc.getTraitSet(); this.typeFactory = calc.getCluster().getTypeFactory(); this.child = calc.getChild(); this.relTypes = relTypes; }
public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) { return new CalcRel( getCluster(), traitSet, sole(inputs), rowType, program.copy(), getCollationList()); }
@Override public CalcRelBase copy( RelTraitSet traitSet, RelNode child, RexProgram program, List<RelCollation> collationList) { return new CalcRel( getCluster(), traitSet, child, program.getOutputRowType(), program, collationList); }
public RelNode convert(RelNode rel) { final CalcRel calc = (CalcRel) rel; // If there's a multiset, let FarragoMultisetSplitter work on it // first. if (RexMultisetUtil.containsMultiset(calc.getProgram())) { return null; } return new JdbcCalcRel(rel.getCluster(), rel.getTraitSet().replace(out), convert(calc.getChild(), calc.getTraitSet().replace(out)), calc.getProgram(), ProjectRelBase.Flags.BOXED); } }
conditions); ret = CalcRel.createFilter(ret, conditionExp); CalcRel.createProject( ret, Collections.<RexNode>singletonList(extraExpr), null); List<RelDataType> argTypes =
public RelNode convert(RelNode rel) { final CalcRel calc = (CalcRel) rel; // If there's a multiset, let FarragoMultisetSplitter work on it // first. final RexProgram program = calc.getProgram(); if (B && RexMultisetUtil.containsMultiset(program) || program.containsAggs()) { return null; } return new EnumerableCalcRel( rel.getCluster(), rel.getTraitSet().replace(EnumerableConvention.INSTANCE), convert( calc.getChild(), calc.getChild().getTraitSet() .replace(EnumerableConvention.INSTANCE)), calc.getRowType(), program, calc.getCollationList()); } }
public void onMatch(RelOptRuleCall call) { CalcRel calc = call.rel(0); RexProgram program = calc.getProgram(); if (!program.isTrivial()) { return; } RelNode child = calc.getInput(0); child = call.getPlanner().register(child, calc); call.transformTo( convert( child, calc.getTraitSet())); } }
RexProgram program = RexProgram.create( calc.getRowType(), project.getProjects(), null, if (RexOver.containsOver(program)) { CalcRel projectAsCalc = new CalcRel( cluster, project.getTraitSet(), final RexProgramBuilder progBuilder = new RexProgramBuilder( calc.getRowType(), rexBuilder); for (Pair<RexNode, String> field : project.getNamedProjects()) { RexProgram bottomProgram = calc.getProgram(); rexBuilder); final CalcRel newCalc = new CalcRel( cluster, project.getTraitSet(), calc.getChild(), project.getRowType(), mergedProgram,
Permutation permutation1 = calcRel.getProgram().getPermutation(); if (permutation1 != null) { Permutation permutation2 = permutation.product(permutation1); return permute(rel, permutation2, null); if (permutation1 != null) { Permutation permutation2 = permutation.product(permutation1); return permute(rel, permutation2, null); outputTypeList, outputNameList)); return new CalcRel( rel.getCluster(), rel.getTraitSet(),
final RexProgram program = child.getProgram(); final RelDataType childRowType = child.getRowType(); final int groupCount = aggregate.getGroupSet().cardinality(); IntList constantList = new IntList(); CalcRel.createProject(newAggregate, projects, false);
/** * If the filter list passed in is non-empty, creates a FilterRel on top of * the existing RelNode; otherwise, just returns the RelNode * * @param rexBuilder rex builder * @param rel the RelNode that the filter will be put on top of * @param filters list of filters * * @return new RelNode or existing one if no filters */ private RelNode createFilterOnRel( RexBuilder rexBuilder, RelNode rel, List<RexNode> filters) { RelNode newRel; if (filters.size() == 0) { newRel = rel; } else { RexNode andFilters = RexUtil.andRexNodeList(rexBuilder, filters); newRel = CalcRel.createFilter(rel, andFilters); } return newRel; } }
/** * 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(CalcRel rel, String relTypeName) { for (RelType relType : relTypes) { if (relType.name.equals(relTypeName)) { return relType.canImplement(rel.getProgram()); } } throw Util.newInternal("unknown reltype " + relTypeName); }
public RelNode convert(RelNode rel) { final CalcRel calc = (CalcRel) rel; // If there's a multiset, let FarragoMultisetSplitter work on it // first. final RexProgram program = calc.getProgram(); if (RexMultisetUtil.containsMultiset(program) || program.containsAggs()) { return null; } return new EnumerableCalcRel( rel.getCluster(), rel.getTraitSet().replace(EnumerableConvention.INSTANCE), convert( calc.getChild(), calc.getChild().getTraitSet() .replace(EnumerableConvention.INSTANCE)), program, ProjectRelBase.Flags.Boxed); } }
protected RelNode makeRel( RelOptCluster cluster, RelTraitSet traits, RelDataType rowType, RelNode child, RexProgram program) { return new CalcRel( cluster, traits, child, rowType, program, Collections.<RelCollation>emptyList()); }
/** * Renames a relational expression to make its field names the same as * another row type. If the row type is already identical, or if the row * type is too different (the fields are different in number or type) does * nothing. * * @param rel Relational expression * @param desiredRowType Desired row type (including desired field names) * @return Renamed relational expression, or the original expression if * there is nothing to do or nothing we <em>can</em> do. */ public static RelNode renameIfNecessary( RelNode rel, RelDataType desiredRowType) { final RelDataType rowType = rel.getRowType(); if (rowType == desiredRowType) { // Nothing to do. return rel; } assert !rowType.equals(desiredRowType); if (!areRowTypesEqual(rowType, desiredRowType, false)) { // The row types are different ignoring names. Nothing we can do. return rel; } rel = CalcRel.createRename( rel, desiredRowType.getFieldNames()); return rel; }
public RelNode convert(RelNode rel) { final CalcRel calc = (CalcRel) rel; // If there's a multiset, let FarragoMultisetSplitter work on it // first. if (RexMultisetUtil.containsMultiset(calc.getProgram())) { return null; } return new JdbcCalcRel(rel.getCluster(), rel.getTraitSet().replace(out), convert(calc.getChild(), calc.getTraitSet().replace(out)), calc.getProgram(), ProjectRelBase.Flags.Boxed); } }
cluster.getRexBuilder(), conditions, true); ret = CalcRel.createFilter(ret, conditionExp); CalcRel.createProject( ret, Collections.<RexNode>singletonList(extraExpr), null); List<RelDataType> argTypes =
public void onMatch(RelOptRuleCall call) { CalcRel calc = call.rel(0); RexProgram program = calc.getProgram(); if (!program.isTrivial()) { return; } RelNode child = calc.getInput(0); child = call.getPlanner().register(child, calc); call.transformTo( convert( child, calc.getTraitSet())); } }
Permutation permutation1 = calcRel.getProgram().getPermutation(); if (permutation1 != null) { Permutation permutation2 = permutation.product(permutation1); return permute(rel, permutation2, null); if (permutation1 != null) { Permutation permutation2 = permutation.product(permutation1); return permute(rel, permutation2, null); outputTypeList, outputNameList)); return new CalcRel( rel.getCluster(), rel.getTraitSet(),