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); } }
selectList = validator.expandStar(selectList, select, false); replaceSubqueries(bb, selectList, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
/** * 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); } }
SqlCall rowConstructor = (SqlCall) rowConstructor1; Blackboard tmpBb = createBlackboard(bb.scope, null); replaceSubqueries(tmpBb, rowConstructor, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN); List<Pair<RexNode, String>> exps =
replaceSubqueries(bb, aggList, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN); replaceSubqueries(bb, newHaving, RelOptUtil.Logic.UNKNOWN_AS_FALSE); havingExpr = bb.convertExpression(newHaving); if (havingExpr.isAlwaysTrue()) { replaceSubqueries(bb, selectList, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
return; replaceSubqueries(bb, call, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
replaceSubqueries(bb, node, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN); final RelNode childRel = RelOptUtil.createProject(
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); } }
private RexNode convertJoinCondition( Blackboard bb, SqlNode condition, SqlJoinOperator.ConditionType conditionType, RelNode leftRel, RelNode rightRel) { if (condition == null) { return rexBuilder.makeLiteral(true); } bb.setRoot(Arrays.asList(leftRel, rightRel)); replaceSubqueries(bb, condition); switch (conditionType) { case On: bb.setRoot(Arrays.asList(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); } }
selectList = validator.expandStar(selectList, select, false); replaceSubqueries(bb, selectList);
selectList = validator.expandStar(selectList, select, false); replaceSubqueries(bb, selectList);
replaceSubqueries(bb, newWhere); final RexNode convertedWhere = bb.convertExpression(newWhere);
/** * 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); } }
SqlCall rowConstructor = (SqlCall) rowConstructor1; Blackboard tmpBb = createBlackboard(bb.scope, null); replaceSubqueries(tmpBb, rowConstructor); List<Pair<RexNode, String>> exps = new ArrayList<Pair<RexNode, String>>();
SqlCall rowConstructor = (SqlCall) rowConstructor1; Blackboard tmpBb = createBlackboard(bb.scope, null); replaceSubqueries(tmpBb, rowConstructor); List<Pair<RexNode, String>> exps = new ArrayList<Pair<RexNode, String>>();
protected void convertCollectionTable( Blackboard bb, SqlCall call) { if (call.getOperator() == SqlStdOperatorTable.sampleFunction) { final String sampleName = SqlLiteral.stringValue(call.operands[0]); datasetStack.push(sampleName); SqlCall cursorCall = (SqlCall) call.operands[1]; SqlNode query = cursorCall.operands[0]; RelNode converted = convertQuery(query, false, false); bb.setRoot(converted, false); datasetStack.pop(); return; } replaceSubqueries(bb, call); RexNode rexCall = bb.convertExpression(call); final List<RelNode> inputs = bb.retrieveCursors(); Set<RelColumnMapping> columnMappings = getColumnMappings(call.getOperator()); TableFunctionRel callRel = new TableFunctionRel( cluster, inputs, rexCall, validator.getValidatedNodeType(call), columnMappings); bb.setRoot(callRel, true); afterTableFunction(bb, call, callRel); }
replaceSubqueries(bb, aggList); replaceSubqueries(bb, newHaving); havingExpr = bb.convertExpression(newHaving); if (havingExpr.isAlwaysTrue()) { replaceSubqueries(bb, selectList);
return; replaceSubqueries(bb, call);
replaceSubqueries(bb, call); final RelNode childRel = CalcRel.createProject(
replaceSubqueries(bb, node); final RelNode childRel = CalcRel.createProject(