public RelNode flattenTypes( RelNode rootRel, boolean restructure) { RelStructuredTypeFlattener typeFlattener = new RelStructuredTypeFlattener(rexBuilder, createToRelContext()); return typeFlattener.rewrite(rootRel, restructure); }
private void replaceSubqueries( final Blackboard bb, final SqlNode expr, RelOptUtil.Logic logic) { findSubqueries(bb, expr, logic, false); for (SubQuery node : bb.subqueryList) { substituteSubquery(bb, node); } }
public RexNode register( RelNode rel, JoinRelType joinType) { return register(rel, joinType, null); }
/** * If subquery is correlated and decorrelation is enabled, performs * decorrelation. * * @param query Query * @param rootRel Root relational expression * @return New root relational expression after decorrelation */ public RelNode decorrelate(SqlNode query, RelNode rootRel) { if (!enableDecorrelation()) { return rootRel; } final RelNode result = decorrelateQuery(rootRel); if (result != rootRel) { checkConvertedType(query, result); } return result; }
/** * Converts a SELECT statement's parse tree into a relational expression. */ public RelNode convertSelect(SqlSelect select) { final SqlValidatorScope selectScope = validator.getWhereScope(select); final Blackboard bb = createBlackboard(selectScope, null); convertSelectImpl(bb, select); return bb.root; }
/** * Converts a SELECT statement's parse tree into a relational expression. */ public RelNode convertValues( SqlCall values, RelDataType targetRowType) { final SqlValidatorScope scope = validator.getOverScope(values); assert scope != null; final Blackboard bb = createBlackboard(scope, null); convertValuesImpl(bb, values, targetRowType); return bb.root; }
public RexNode visit(SqlCall call) { if (agg != null) { final SqlOperator op = call.getOperator(); if (op.isAggregator()) { return agg.lookupAggregates(call); } } return exprConverter.convertCall(this, call); }
/** * Creates a RelFieldTrimmer. * * @return Field trimmer */ protected RelFieldTrimmer newFieldTrimmer() { return new RelFieldTrimmer(validator); }
/** * Converts a WITH sub-query into a relational expression. */ public RelNode convertWith(SqlWith with) { return convertQuery(with.body, false, false); }
public RexNode convertLiteral(SqlLiteral literal) { return exprConverter.convertLiteral(this, literal); }
/** * Factory method for creating translation workspace. */ protected Blackboard createBlackboard( SqlValidatorScope scope, Map<String, RexNode> nameToNodeMap) { return new Blackboard(scope, nameToNodeMap); }
/** * Creates a LookupContext with multiple input relational expressions. * * @param bb Context for translating this subquery * @param rels Relational expressions * @param systemFieldCount Number of system fields */ LookupContext(Blackboard bb, List<RelNode> rels, int systemFieldCount) { bb.flatten(rels, systemFieldCount, new int[]{0}, relOffsetList); }
void setRoot(List<RelNode> inputs) { setRoot(inputs, null, false); }
public RexNode convertInterval(SqlIntervalQualifier intervalQualifier) { return exprConverter.convertInterval(this, intervalQualifier); }
public RexNode visit(SqlDynamicParam param) { return convertDynamicParam(param); }
public RexNode visit(SqlIntervalQualifier intervalQualifier) { return convertInterval(intervalQualifier); }
private void setRoot( List<RelNode> inputs, RelNode root, boolean hasSystemFields) { this.inputs = inputs; this.root = root; this.systemFieldList.clear(); if (hasSystemFields) { this.systemFieldList.addAll(getSystemFields()); } }
public RexNode apply(Pair<RexNode, SqlNode> pair) { return rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, pair.left, bb.convertExpression(pair.right)); } }),
protected RelNode decorrelateQuery(RelNode rootRel) { return RelDecorrelator.decorrelateQuery(rootRel); }
public RexNode visit(SqlLiteral literal) { return exprConverter.convertLiteral(this, literal); }