public RelNode expandView( RelDataType rowType, String queryString, List<String> schemaPath) { return viewExpander.expandView(rowType, queryString, schemaPath); } };
public RelNode toRel(RelOptTable table) { return table.toRel(createToRelContext()); }
protected boolean checkConvertedRowType( SqlNode query, RelDataType convertedRowType) { RelDataType validatedRowType = validator.getValidatedNodeType(query); validatedRowType = uniquifyFields(validatedRowType); return RelOptUtil.equal( "validated row type", validatedRowType, "converted row type", convertedRowType, false); }
this.rexBuilder = rexBuilder; this.typeFactory = rexBuilder.getTypeFactory(); RelOptQuery query = new RelOptQuery(planner); this.cluster = query.createCluster(typeFactory, rexBuilder); this.shouldConvertTableAccess = true; this.exprConverter =
collationList); final RelCollation collation = cluster.traitSetOf().canonize(RelCollationImpl.of(collationList));
final RelDataType targetRowType = targetTable.getRowType(); final List<RelDataTypeField> targetFields = targetRowType.getFieldList(); return RelOptUtil.createProject(sourceRel, sourceExps, fieldNames, true);
new CollectRel( cluster, cluster.traitSetOf(Convention.NONE), input, validator.deriveAlias(call, i)); RelOptUtil.createProject( new OneRowRel(cluster), selectList,
List<RexNode> columnExprs) { final RelOptTable targetTable = getTargetTable(call); final RelDataType targetRowType = targetTable.getRowType(); SqlNodeList targetColumnList = call.getTargetColumnList(); if (targetColumnList == null) {
targetTable.unwrap(ModifiableTable.class); if (modifiableTable != null) { return modifiableTable.toModificationRel(
if (dumpPlan) { SQL2REL_LOGGER.fine( RelOptUtil.dumpPlan( "Plan after converting SqlNode to RelNode", result,
private void checkConvertedType(SqlNode query, RelNode result) { if (!query.isA(SqlKind.DML)) { // Verify that conversion from SQL to relational algebra did // not perturb any type information. (We can't do this if the // SQL statement is something like an INSERT which has no // validator type information associated with its result, // hence the namespace check above.) RelDataType convertedRowType = result.getRowType(); if (!checkConvertedRowType(query, convertedRowType)) { RelDataType validatedRowType = validator.getValidatedNodeType(query); validatedRowType = uniquifyFields(validatedRowType); throw Util.newInternal( "Conversion to relational algebra failed to preserve " + "datatypes:\n" + "validated type:\n" + validatedRowType.getFullTypeString() + "\nconverted type:\n" + convertedRowType.getFullTypeString() + "\nrel:\n" + RelOptUtil.toString(result)); } } }
protected RelDataType uniquifyFields(RelDataType rowType) { return validator.getTypeFactory().createStructType( RelOptUtil.getFieldTypeList(rowType), SqlValidatorUtil.uniquify(rowType.getFieldNames())); }
RelNode seekRel = convertQueryOrInList(seekBb, seek); return RelOptUtil.createExistsPlan(seekRel, subqueryType, logic, needsOuterJoin);
Set<String> correlatedVariables = RelOptUtil.getVariablesUsed(subq); for (String correlName : correlatedVariables) { DeferredLookup lookup = mapCorrelToDeferred.get(correlName);
return RelOptUtil.createSingleValueAggRel( cluster, plan);
return node; default: BitSet bits = RelOptUtil.InputFinder.bits(node); final int mid = leftCount + extraLeftExprs.size(); switch (Side.of(bits, mid)) {
/** * 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); } }
RelOptUtil.createProject(bb.root, exprs, fieldNames), false);
if (dumpPlan) { SQL2REL_LOGGER.fine( RelOptUtil.dumpPlan( "Plan after trimming unused fields", rootRel,