/** * Converts an expression from {@link SqlNode} to {@link RexNode} format. * * @param node Expression to translate * @return Converted expression */ public RexNode convertExpression( SqlNode node) { Map<String, RelDataType> nameToTypeMap = Collections.emptyMap(); final ParameterScope scope = new ParameterScope((SqlValidatorImpl) validator, nameToTypeMap); final Blackboard bb = createBlackboard(scope, null, false); return bb.convertExpression(node); }
/** * Converts an expression from {@link SqlNode} to {@link RexNode} format. * * @param node Expression to translate * @return Converted expression */ public RexNode convertExpression( SqlNode node) { Map<String, RelDataType> nameToTypeMap = Collections.emptyMap(); final ParameterScope scope = new ParameterScope((SqlValidatorImpl) validator, nameToTypeMap); final Blackboard bb = createBlackboard(scope, null, false); return bb.convertExpression(node); }
/** * Converts an expression from {@link SqlNode} to {@link RexNode} format. * * @param node Expression to translate * @return Converted expression */ public RexNode convertExpression( SqlNode node) { Map<String, RelDataType> nameToTypeMap = Collections.emptyMap(); final ParameterScope scope = new ParameterScope((SqlValidatorImpl) validator, nameToTypeMap); final Blackboard bb = createBlackboard(scope, null, false); return bb.convertExpression(node); }
/** * Converts an expression from {@link SqlNode} to {@link RexNode} format. * * @param node Expression to translate * @return Converted expression */ public RexNode convertExpression( SqlNode node) { Map<String, RelDataType> nameToTypeMap = Collections.emptyMap(); final ParameterScope scope = new ParameterScope((SqlValidatorImpl) validator, nameToTypeMap); final Blackboard bb = createBlackboard(scope, null, false); return bb.convertExpression(node); }
/** * Converts a SELECT statement's parse tree into a relational expression. */ public RelNode convertSelect(SqlSelect select, boolean top) { final SqlValidatorScope selectScope = validator.getWhereScope(select); final Blackboard bb = createBlackboard(selectScope, null, top); convertSelectImpl(bb, select); return bb.root; }
/** * Converts a SELECT statement's parse tree into a relational expression. */ public RelNode convertSelect(SqlSelect select, boolean top) { final SqlValidatorScope selectScope = validator.getWhereScope(select); final Blackboard bb = createBlackboard(selectScope, null, top); 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, false); convertValuesImpl(bb, values, targetRowType); return bb.root; }
/** * Converts a SELECT statement's parse tree into a relational expression. */ public RelNode convertSelect(SqlSelect select, boolean top) { final SqlValidatorScope selectScope = validator.getWhereScope(select); final Blackboard bb = createBlackboard(selectScope, null, top); 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, false); convertValuesImpl(bb, values, targetRowType); return bb.root; }
/** * Converts a SELECT statement's parse tree into a relational expression. */ public RelNode convertSelect(SqlSelect select, boolean top) { final SqlValidatorScope selectScope = validator.getWhereScope(select); final Blackboard bb = createBlackboard(selectScope, null, top); 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, false); convertValuesImpl(bb, values, targetRowType); 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, false); convertValuesImpl(bb, values, targetRowType); return bb.root; }
/** * Converts an expression from {@link SqlNode} to {@link RexNode} format, * mapping identifier references to predefined expressions. * * @param node Expression to translate * @param nameToNodeMap map from String to {@link RexNode}; when an * {@link SqlIdentifier} is encountered, it is used as a * key and translated to the corresponding value from * this map * @return Converted expression */ public RexNode convertExpression( SqlNode node, Map<String, RexNode> nameToNodeMap) { final Map<String, RelDataType> nameToTypeMap = new HashMap<>(); for (Map.Entry<String, RexNode> entry : nameToNodeMap.entrySet()) { nameToTypeMap.put(entry.getKey(), entry.getValue().getType()); } final ParameterScope scope = new ParameterScope((SqlValidatorImpl) validator, nameToTypeMap); final Blackboard bb = createBlackboard(scope, nameToNodeMap, false); return bb.convertExpression(node); }
/** * Converts an expression from {@link SqlNode} to {@link RexNode} format, * mapping identifier references to predefined expressions. * * @param node Expression to translate * @param nameToNodeMap map from String to {@link RexNode}; when an * {@link SqlIdentifier} is encountered, it is used as a * key and translated to the corresponding value from * this map * @return Converted expression */ public RexNode convertExpression( SqlNode node, Map<String, RexNode> nameToNodeMap) { final Map<String, RelDataType> nameToTypeMap = new HashMap<>(); for (Map.Entry<String, RexNode> entry : nameToNodeMap.entrySet()) { nameToTypeMap.put(entry.getKey(), entry.getValue().getType()); } final ParameterScope scope = new ParameterScope((SqlValidatorImpl) validator, nameToTypeMap); final Blackboard bb = createBlackboard(scope, nameToNodeMap, false); return bb.convertExpression(node); }
/** * Converts an expression from {@link SqlNode} to {@link RexNode} format, * mapping identifier references to predefined expressions. * * @param node Expression to translate * @param nameToNodeMap map from String to {@link RexNode}; when an * {@link SqlIdentifier} is encountered, it is used as a * key and translated to the corresponding value from * this map * @return Converted expression */ public RexNode convertExpression( SqlNode node, Map<String, RexNode> nameToNodeMap) { final Map<String, RelDataType> nameToTypeMap = new HashMap<>(); for (Map.Entry<String, RexNode> entry : nameToNodeMap.entrySet()) { nameToTypeMap.put(entry.getKey(), entry.getValue().getType()); } final ParameterScope scope = new ParameterScope((SqlValidatorImpl) validator, nameToTypeMap); final Blackboard bb = createBlackboard(scope, nameToNodeMap, false); return bb.convertExpression(node); }
/** * Converts an expression from {@link SqlNode} to {@link RexNode} format, * mapping identifier references to predefined expressions. * * @param node Expression to translate * @param nameToNodeMap map from String to {@link RexNode}; when an * {@link SqlIdentifier} is encountered, it is used as a * key and translated to the corresponding value from * this map * @return Converted expression */ public RexNode convertExpression( SqlNode node, Map<String, RexNode> nameToNodeMap) { final Map<String, RelDataType> nameToTypeMap = new HashMap<>(); for (Map.Entry<String, RexNode> entry : nameToNodeMap.entrySet()) { nameToTypeMap.put(entry.getKey(), entry.getValue().getType()); } final ParameterScope scope = new ParameterScope((SqlValidatorImpl) validator, nameToTypeMap); final Blackboard bb = createBlackboard(scope, nameToNodeMap, false); return bb.convertExpression(node); }
/** Creates a blackboard for translating the expressions of generated columns * in an INSERT statement. */ private Blackboard createInsertBlackboard(RelOptTable targetTable, RexNode sourceRef, List<String> targetColumnNames) { final Map<String, RexNode> nameToNodeMap = new HashMap<>(); int j = 0; // Assign expressions for non-generated columns. final List<ColumnStrategy> strategies = targetTable.getColumnStrategies(); final List<String> targetFields = targetTable.getRowType().getFieldNames(); for (String targetColumnName : targetColumnNames) { final int i = targetFields.indexOf(targetColumnName); switch (strategies.get(i)) { case STORED: case VIRTUAL: break; default: nameToNodeMap.put(targetColumnName, rexBuilder.makeFieldAccess(sourceRef, j++)); } } return createBlackboard(null, nameToNodeMap, false); }
/** Creates a blackboard for translating the expressions of generated columns * in an INSERT statement. */ private Blackboard createInsertBlackboard(RelOptTable targetTable, RexNode sourceRef, List<String> targetColumnNames) { final Map<String, RexNode> nameToNodeMap = new HashMap<>(); int j = 0; // Assign expressions for non-generated columns. final List<ColumnStrategy> strategies = targetTable.getColumnStrategies(); final List<String> targetFields = targetTable.getRowType().getFieldNames(); for (String targetColumnName : targetColumnNames) { final int i = targetFields.indexOf(targetColumnName); switch (strategies.get(i)) { case STORED: case VIRTUAL: break; default: nameToNodeMap.put(targetColumnName, rexBuilder.makeFieldAccess(sourceRef, j++)); } } return createBlackboard(null, nameToNodeMap, false); }
private RelNode convertUpdate(SqlUpdate call) { final SqlValidatorScope scope = validator.getWhereScope(call.getSourceSelect()); Blackboard bb = createBlackboard(scope, null, false); Builder<RexNode> rexNodeSourceExpressionListBuilder = ImmutableList.builder(); for (SqlNode n : call.getSourceExpressionList()) { RexNode rn = bb.convertExpression(n); rexNodeSourceExpressionListBuilder.add(rn); } RelOptTable targetTable = getTargetTable(call); // convert update column list from SqlIdentifier to String final List<String> targetColumnNameList = new ArrayList<>(); final RelDataType targetRowType = targetTable.getRowType(); for (SqlNode node : call.getTargetColumnList()) { SqlIdentifier id = (SqlIdentifier) node; RelDataTypeField field = SqlValidatorUtil.getTargetField( targetRowType, typeFactory, id, catalogReader, targetTable); assert field != null : "column " + id.toString() + " not found"; targetColumnNameList.add(field.getName()); } RelNode sourceRel = convertSelect(call.getSourceSelect(), false); return LogicalTableModify.create(targetTable, catalogReader, sourceRel, LogicalTableModify.Operation.UPDATE, targetColumnNameList, rexNodeSourceExpressionListBuilder.build(), false); }
private RelNode convertUpdate(SqlUpdate call) { final SqlValidatorScope scope = validator.getWhereScope(call.getSourceSelect()); Blackboard bb = createBlackboard(scope, null, false); Builder<RexNode> rexNodeSourceExpressionListBuilder = ImmutableList.builder(); for (SqlNode n : call.getSourceExpressionList()) { RexNode rn = bb.convertExpression(n); rexNodeSourceExpressionListBuilder.add(rn); } RelOptTable targetTable = getTargetTable(call); // convert update column list from SqlIdentifier to String final List<String> targetColumnNameList = new ArrayList<>(); final RelDataType targetRowType = targetTable.getRowType(); for (SqlNode node : call.getTargetColumnList()) { SqlIdentifier id = (SqlIdentifier) node; RelDataTypeField field = SqlValidatorUtil.getTargetField( targetRowType, typeFactory, id, catalogReader, targetTable); assert field != null : "column " + id.toString() + " not found"; targetColumnNameList.add(field.getName()); } RelNode sourceRel = convertSelect(call.getSourceSelect(), false); return LogicalTableModify.create(targetTable, catalogReader, sourceRel, LogicalTableModify.Operation.UPDATE, targetColumnNameList, rexNodeSourceExpressionListBuilder.build(), false); }