public RelNode createProject(RelNode child, List<RexNode> childExprs, List<String> fieldNames) { return CalcRel.createProject(child, childExprs, fieldNames); } }
/** * Creates a relational expression which projects an array of expressions. * * @param child input relational expression * @param exprList list of expressions for the input columns * @param fieldNameList aliases of the expressions, or null to generate */ public static RelNode createProject( RelNode child, List<RexNode> exprList, List<String> fieldNameList) { return createProject(child, exprList, fieldNameList, false); }
/** * Creates a relational expression which projects an array of expressions. * * @param child input relational expression * @param exprList list of expressions for the input columns * @param fieldNameList aliases of the expressions, or null to generate */ public static RelNode createProject( RelNode child, List<RexNode> exprList, List<String> fieldNameList) { return createProject(child, exprList, fieldNameList, false); }
public static RelNode createProject( final RelNode child, final List<Integer> posList) { return CalcRel.createProject( child, new AbstractList<RexNode>() { public int size() { return posList.size(); } public RexNode get(int index) { final int pos = posList.get(index); return child.getCluster().getRexBuilder().makeInputRef( child.getRowType().getFieldList().get(pos).getType(), pos); } }, null); }
/** * Creates a relational expression which projects an array of expressions. * * @param child input relational expression * @param projectList list of (expression, name) pairs * @param optimize Whether to optimize */ public static RelNode createProject( RelNode child, List<Pair<RexNode, String>> projectList, boolean optimize) { return createProject( child, Pair.left(projectList), Pair.right(projectList), optimize); }
/** * Returns a relational expression which has the same fields as the * underlying expression, but the fields have different names. * * @param rel Relational expression * @param fieldNames Field names * @return Renamed relational expression */ public static RelNode createRename( RelNode rel, List<String> fieldNames) { final List<RelDataTypeField> fields = rel.getRowType().getFieldList(); assert fieldNames.size() == fields.size(); final List<Pair<RexNode, String>> refs = new AbstractList<Pair<RexNode, String>>() { public int size() { return fields.size(); } public Pair<RexNode, String> get(int index) { return RexInputRef.of2(index, fields); } }; return createProject(rel, refs, true); }
/** * Creates a relational expression which projects an array of expressions. * * @param child input relational expression * @param projectList list of (expression, name) pairs * @param optimize Whether to optimize */ public static RelNode createProject( RelNode child, List<Pair<RexNode, String>> projectList, boolean optimize) { return createProject( child, Pair.left(projectList), Pair.right(projectList), optimize); }
/** * Returns a relational expression which has the same fields as the * underlying expression, but the fields have different names. * * @param rel Relational expression * @param fieldNames Field names * * @return Renamed relational expression */ public static RelNode createRename( RelNode rel, List<String> fieldNames) { final List<RelDataTypeField> fields = rel.getRowType().getFieldList(); assert fieldNames.size() == fields.size(); final List<Pair<RexNode, String>> refs = new AbstractList<Pair<RexNode, String>>() { public int size() { return fields.size(); } public Pair<RexNode, String> get(int index) { return RexInputRef.of2(index, fields); } }; return createProject(rel, refs, true); }
public void rewriteRel(ProjectRel rel) { final List<RexNode> flattenedExpList = new ArrayList<RexNode>(); final List<String> flattenedFieldNameList = new ArrayList<String>(); List<String> fieldNames = rel.getRowType().getFieldNames(); flattenProjections( rel.getProjects(), fieldNames, "", flattenedExpList, flattenedFieldNameList); RelNode newRel = CalcRel.createProject( getNewForOldRel(rel.getChild()), flattenedExpList, flattenedFieldNameList); setNewForOldRel(rel, newRel); }
/** * Project all childRel output fields plus the additional expressions. * * @param childRel Child relational expression * @param additionalExprs Additional expressions and names * @return the new ProjectRel */ private RelNode createProjectWithAdditionalExprs( RelNode childRel, List<Pair<RexNode, String>> additionalExprs) { final List<RelDataTypeField> fieldList = childRel.getRowType().getFieldList(); List<Pair<RexNode, String>> projects = Lists.newArrayList(); for (Ord<RelDataTypeField> field : Ord.zip(fieldList)) { projects.add( Pair.of( (RexNode) rexBuilder.makeInputRef( field.e.getType(), field.i), field.e.getName())); } projects.addAll(additionalExprs); return CalcRel.createProject(childRel, projects, false); }
public void rewriteRel(ProjectRel rel) { final List<RexNode> flattenedExpList = new ArrayList<RexNode>(); final List<String> flattenedFieldNameList = new ArrayList<String>(); List<String> fieldNames = rel.getRowType().getFieldNames(); flattenProjections( rel.getProjects(), fieldNames, "", flattenedExpList, flattenedFieldNameList); RelNode newRel = CalcRel.createProject( getNewForOldRel(rel.getChild()), flattenedExpList, flattenedFieldNameList); setNewForOldRel(rel, newRel); }
public void onMatch(RelOptRuleCall call) { CorrelatorRel corRel = call.rel(0); RelNode leftInputRel = call.rel(1); ProjectRel aggOutputProjRel; AggregateRel aggRel; if (flavor) { aggOutputProjRel = call.rel(2); aggRel = call.rel(3); } else { aggRel = call.rel(2); // Create identity projection List<Pair<RexNode, String>> projects = Lists.newArrayList(); final List<RelDataTypeField> fields = aggRel.getRowType().getFieldList(); for (int i = 0; i < fields.size(); i++) { projects.add(RexInputRef.of2(projects.size(), fields)); } aggOutputProjRel = (ProjectRel) CalcRel.createProject( aggRel, projects, false); } onMatch2(call, corRel, leftInputRel, aggOutputProjRel, aggRel); }
/** * Project all childRel output fields plus the additional expressions. * * @param childRel Child relational expression * @param additionalExprs Additional expressions and names * * @return the new ProjectRel */ private RelNode createProjectWithAdditionalExprs( RelNode childRel, List<Pair<RexNode, String>> additionalExprs) { final List<RelDataTypeField> fieldList = childRel.getRowType().getFieldList(); List<Pair<RexNode, String>> projects = new ArrayList<Pair<RexNode, String>>(); for (Ord<RelDataTypeField> field : Ord.zip(fieldList)) { projects.add( Pair.of( (RexNode) rexBuilder.makeInputRef( field.e.getType(), field.i), field.e.getName())); } projects.addAll(additionalExprs); return CalcRel.createProject(childRel, projects, false); }
public void onMatch(RelOptRuleCall call) { CorrelatorRel corRel = call.rel(0); RelNode leftInputRel = call.rel(1); ProjectRel aggOutputProjRel; AggregateRel aggRel; if (flavor) { aggOutputProjRel = call.rel(2); aggRel = call.rel(3); } else { aggRel = call.rel(2); // Create identity projection List<Pair<RexNode, String>> projects = new ArrayList<Pair<RexNode, String>>(); final List<RelDataTypeField> fields = aggRel.getRowType().getFieldList(); for (int i = 0; i < fields.size(); i++) { projects.add(RexInputRef.of2(projects.size(), fields)); } aggOutputProjRel = (ProjectRel) CalcRel.createProject( aggRel, projects, false); } onMatch2(call, corRel, leftInputRel, aggOutputProjRel, aggRel); }
@Override public RelNode visit(TableAccessRelBase scan) { RelOptTable relOptTable = scan.getTable(); final Table table = relOptTable.unwrap(Table.class); if (table.equals(starTable.tables.get(0))) { Mappings.TargetMapping mapping = Mappings.createShiftMapping( starRelOptTable.getRowType().getFieldCount(), 0, 0, relOptTable.getRowType().getFieldCount()); return CalcRel.createProject( new TableAccessRel(scan.getCluster(), starRelOptTable), Mappings.asList(mapping.inverse())); } return scan; }
public RelNode rewrite(RelNode root, boolean restructure) { // Perform flattening. oldToNewRelMap = new HashMap<RelNode, RelNode>(); visitor.visit(root, 0, null); RelNode flattened = getNewForOldRel(root); flattenedRootType = flattened.getRowType(); // If requested, add an additional projection which puts // everything back into structured form for return to the // client. restructured = false; List<RexNode> structuringExps = null; if (restructure) { iRestructureInput = 0; structuringExps = restructureFields(root.getRowType()); } if (restructured) { // REVIEW jvs 23-Mar-2005: How do we make sure that this // implementation stays in Java? Fennel can't handle // structured types. return CalcRel.createProject( flattened, structuringExps, root.getRowType().getFieldNames()); } else { return flattened; } }
RelOptUtil.projectMultiJoin(multiJoin, project); ProjectRel newProject = (ProjectRel) CalcRel.createProject( newMultiJoin, project.getProjects(),
public void onMatch(RelOptRuleCall call) { ProjectRel project = call.rel(0); MultiJoinRel multiJoin = call.rel(1); // if all inputs have their projFields set, then projection information // has already been pushed into each input boolean allSet = true; for (int i = 0; i < multiJoin.getInputs().size(); i++) { if (multiJoin.getProjFields().get(i) == null) { allSet = false; break; } } if (allSet) { return; } // create a new MultiJoinRel that reflects the columns in the projection // above the MultiJoinRel MultiJoinRel newMultiJoin = RelOptUtil.projectMultiJoin(multiJoin, project); ProjectRel newProject = (ProjectRel) CalcRel.createProject( newMultiJoin, project.getProjects(), project.getRowType().getFieldNames()); call.transformTo(newProject); } }
public RelNode rewrite(RelNode root, boolean restructure) { // Perform flattening. visitor.visit(root, 0, null); RelNode flattened = getNewForOldRel(root); flattenedRootType = flattened.getRowType(); // If requested, add an additional projection which puts // everything back into structured form for return to the // client. restructured = false; List<RexNode> structuringExps = null; if (restructure) { iRestructureInput = 0; structuringExps = restructureFields(root.getRowType()); } if (restructured) { // REVIEW jvs 23-Mar-2005: How do we make sure that this // implementation stays in Java? Fennel can't handle // structured types. return CalcRel.createProject( flattened, structuringExps, root.getRowType().getFieldNames()); } else { return flattened; } }
public void onMatch(RelOptRuleCall call) { FilterRel filterRel = call.rel(0); ProjectRel projRel = call.rel(1); // convert the filter to one that references the child of the project RexNode newCondition = RelOptUtil.pushFilterPastProject(filterRel.getCondition(), projRel); FilterRel newFilterRel = new FilterRel( filterRel.getCluster(), projRel.getChild(), newCondition); ProjectRel newProjRel = (ProjectRel) CalcRel.createProject( newFilterRel, projRel.getNamedProjects(), false); call.transformTo(newProjRel); } }