/** * Sets a new root relational expression, as the translation process * backs its way further up the tree. * * @param root New root relational expression * @param leaf Whether the relational expression is a leaf, that is, * derived from an atomic relational expression such as a table * name in the from clause, or the projection on top of a * select-subquery. In particular, relational expressions * derived from JOIN operators are not leaves, but set * expressions are. */ public void setRoot(RelNode root, boolean leaf) { setRoot( Collections.singletonList(root), root, root instanceof JoinRel); if (leaf) { leaves.add(root); } this.columnMonotonicities.clear(); }
bb.setRoot( RelOptUtil.createProject(bb.root, exprs, fieldNames), false);
private RexNode convertJoinCondition( Blackboard bb, SqlNode condition, JoinConditionType conditionType, RelNode leftRel, RelNode rightRel) { if (condition == null) { return rexBuilder.makeLiteral(true); } bb.setRoot(ImmutableList.of(leftRel, rightRel)); replaceSubqueries(bb, condition); switch (conditionType) { case ON: bb.setRoot(ImmutableList.of(leftRel, rightRel)); return bb.convertExpression(condition); case USING: SqlNodeList list = (SqlNodeList) condition; List<String> nameList = new ArrayList<String>(); for (SqlNode columnName : list) { final SqlIdentifier id = (SqlIdentifier) columnName; String name = id.getSimple(); nameList.add(name); } return convertUsing(leftRel, rightRel, nameList); default: throw Util.unexpected(conditionType); } }
/** * Converts a WHERE clause. * * @param bb Blackboard * @param where WHERE clause, may be null */ private void convertWhere( final Blackboard bb, final SqlNode where) { if (where == null) { return; } SqlNode newWhere = pushDownNotForIn(where); replaceSubqueries(bb, newWhere); final RexNode convertedWhere = bb.convertExpression(newWhere); // only allocate filter if the condition is not TRUE if (!convertedWhere.isAlwaysTrue()) { bb.setRoot( CalcRel.createFilter(bb.root, convertedWhere), false); } }
/** * Sets a new root relational expression, as the translation process * backs its way further up the tree. * * @param root New root relational expression * @param leaf Whether the relational expression is a leaf, that is, * derived from an atomic relational expression such as a table name in * the from clause, or the projection on top of a select-subquery. In * particular, relational expressions derived from JOIN operators are * not leaves, but set expressions are. */ public void setRoot(RelNode root, boolean leaf) { setRoot( Collections.singletonList(root), root, root instanceof JoinRel); if (leaf) { leaves.add(root); } this.columnMonotonicities.clear(); }
/** * Sets a new root relational expression, as the translation process * backs its way further up the tree. * * @param root New root relational expression * @param leaf Whether the relational expression is a leaf, that is, * derived from an atomic relational expression such as a table * name in the from clause, or the projection on top of a * select-subquery. In particular, relational expressions * derived from JOIN operators are not leaves, but set * expressions are. */ public void setRoot(RelNode root, boolean leaf) { setRoot( Collections.singletonList(root), root, root instanceof JoinRel); if (leaf) { leaves.add(root); } this.columnMonotonicities.clear(); }
void setRoot(List<RelNode> inputs) { setRoot(inputs, null, false); }
void setRoot(List<RelNode> inputs) { setRoot(inputs, null, false); }
tableSampleSpec.isRepeatable(), tableSampleSpec.getRepeatableSeed()); bb.setRoot(new SamplingRel(cluster, bb.root, params), false); } else { throw Util.newInternal( tableRel = new TableAccessRel(cluster, table); bb.setRoot(tableRel, true); if (usedDataset[0]) { bb.setDataset(datasetName); conditionExp, convertedJoinType); bb.setRoot(joinRel, false); return; case UNION: final RelNode rel = convertQueryRecursive(from, false, null); bb.setRoot(rel, true); return; new UncollectRel(cluster, cluster.traitSetOf(Convention.NONE), childRel); bb.setRoot(uncollectRel, true); return;
rexBuilder.makeLiteral(true), JoinRelType.INNER, ImmutableSet.<String>of()); bb.setRoot(join, false);
SqlNode query = cursorCall.operand(0); RelNode converted = convertQuery(query, false, false); bb.setRoot(converted, false); datasetStack.pop(); return; RelOptTable relOptTable = RelOptTableImpl.create(null, rowType, table); RelNode converted = toRel(relOptTable); bb.setRoot(converted, true); return; validator.getValidatedNodeType(call), columnMappings); bb.setRoot(callRel, true); afterTableFunction(bb, call, callRel);
select, bb, collation, orderExprList, select.getOffset(), select.getFetch()); bb.setRoot(bb.root, true);
private RexNode convertJoinCondition( Blackboard bb, SqlNode condition, JoinConditionType conditionType, RelNode leftRel, RelNode rightRel) { if (condition == null) { return rexBuilder.makeLiteral(true); } bb.setRoot(ImmutableList.of(leftRel, rightRel)); replaceSubqueries(bb, condition, RelOptUtil.Logic.UNKNOWN_AS_FALSE); switch (conditionType) { case ON: bb.setRoot(ImmutableList.of(leftRel, rightRel)); return bb.convertExpression(condition); case USING: SqlNodeList list = (SqlNodeList) condition; List<String> nameList = new ArrayList<String>(); for (SqlNode columnName : list) { final SqlIdentifier id = (SqlIdentifier) columnName; String name = id.getSimple(); nameList.add(name); } return convertUsing(leftRel, rightRel, nameList); default: throw Util.unexpected(conditionType); } }
/** * Converts a WHERE clause. * * @param bb Blackboard * @param where WHERE clause, may be null */ private void convertWhere( final Blackboard bb, final SqlNode where) { if (where == null) { return; } SqlNode newWhere = pushDownNotForIn(where); replaceSubqueries(bb, newWhere, RelOptUtil.Logic.UNKNOWN_AS_FALSE); final RexNode convertedWhere = bb.convertExpression(newWhere); // only allocate filter if the condition is not TRUE if (!convertedWhere.isAlwaysTrue()) { bb.setRoot( RelOptUtil.createFilter(bb.root, convertedWhere), false); } }
void setRoot(List<RelNode> inputs) { setRoot(inputs, null, false); }