private void handleOffsetFetch(SqlNode offset, SqlNode fetch) { if (offset instanceof SqlDynamicParam) { setValidatedNodeType(offset, typeFactory.createSqlType(SqlTypeName.INTEGER)); } if (fetch instanceof SqlDynamicParam) { setValidatedNodeType(fetch, typeFactory.createSqlType(SqlTypeName.INTEGER)); } }
public RelDataType deriveType( SqlValidatorScope scope, SqlNode expr) { Objects.requireNonNull(scope); Objects.requireNonNull(expr); // if we already know the type, no need to re-derive RelDataType type = nodeToTypeMap.get(expr); if (type != null) { return type; } final SqlValidatorNamespace ns = getNamespace(expr); if (ns != null) { return ns.getType(); } type = deriveTypeImpl(scope, expr); Preconditions.checkArgument( type != null, "SqlValidator.deriveTypeInternal returned null"); setValidatedNodeType(expr, type); return type; }
private void validateGroupItem(SqlValidatorScope groupScope, AggregatingSelectScope aggregatingScope, SqlNode groupItem) { switch (groupItem.getKind()) { case GROUPING_SETS: case ROLLUP: case CUBE: validateGroupingSets(groupScope, aggregatingScope, (SqlCall) groupItem); break; default: if (groupItem instanceof SqlNodeList) { break; } final RelDataType type = deriveType(groupScope, groupItem); setValidatedNodeType(groupItem, type); } }
/** * Validates a namespace. * * @param namespace Namespace * @param targetRowType Desired row type, must not be null, may be the data * type 'unknown'. */ protected void validateNamespace(final SqlValidatorNamespace namespace, RelDataType targetRowType) { namespace.validate(targetRowType); if (namespace.getNode() != null) { setValidatedNodeType(namespace.getNode(), namespace.getType()); } }
public SqlNode expandOrderExpr(SqlSelect select, SqlNode orderExpr) { final SqlNode newSqlNode = new OrderExpressionExpander(select, orderExpr).go(); if (newSqlNode != orderExpr) { final SqlValidatorScope scope = getOrderScope(select); inferUnknownTypes(unknownType, scope, newSqlNode); final RelDataType type = deriveType(scope, newSqlNode); setValidatedNodeType(newSqlNode, type); } return newSqlNode; }
private List<Map.Entry<String, RelDataType>> validateMeasure(SqlMatchRecognize mr, MatchRecognizeScope scope, boolean allRows) { final List<String> aliases = new ArrayList<>(); final List<SqlNode> sqlNodes = new ArrayList<>(); final SqlNodeList measures = mr.getMeasureList(); final List<Map.Entry<String, RelDataType>> fields = new ArrayList<>(); for (SqlNode measure : measures) { assert measure instanceof SqlCall; final String alias = deriveAlias(measure, aliases.size()); aliases.add(alias); SqlNode expand = expand(measure, scope); expand = navigationInMeasure(expand, allRows); setOriginal(expand, measure); inferUnknownTypes(unknownType, scope, expand); final RelDataType type = deriveType(scope, expand); setValidatedNodeType(measure, type); fields.add(Pair.of(alias, type)); sqlNodes.add( SqlStdOperatorTable.AS.createCall(SqlParserPos.ZERO, expand, new SqlIdentifier(alias, SqlParserPos.ZERO))); } SqlNodeList list = new SqlNodeList(sqlNodes, measures.getParserPosition()); inferUnknownTypes(unknownType, scope, list); for (SqlNode node : list) { validateExpr(node, scope); } mr.setOperand(SqlMatchRecognize.OPERAND_MEASURES, list); return fields; }
setValidatedNodeType(selectItem, type);
setValidatedNodeType(expanded, type); fields.add(Pair.of(alias, type)); return false;
inferredType.getCollation()); setValidatedNodeType(node, newInferredType); } else if (node instanceof SqlNodeList) { SqlNodeList nodeList = (SqlNodeList) node; caseCall.getElseOperand()); } else { setValidatedNodeType(caseCall.getElseOperand(), returnType);
throw newValidationError(expand, RESOURCE.condMustBeBoolean("DEFINE")); setValidatedNodeType(item, type);
final RelDataType logicalTargetRowType = getLogicalTargetRowType(targetRowType, insert); setValidatedNodeType(insert, logicalTargetRowType); final RelDataType logicalSourceRowType = getLogicalSourceRowType(sourceRowType, insert);
setValidatedNodeType(interval, type);
private void handleOffsetFetch(SqlNode offset, SqlNode fetch) { if (offset instanceof SqlDynamicParam) { setValidatedNodeType(offset, typeFactory.createSqlType(SqlTypeName.INTEGER)); } if (fetch instanceof SqlDynamicParam) { setValidatedNodeType(fetch, typeFactory.createSqlType(SqlTypeName.INTEGER)); } }
private void handleOffsetFetch(SqlNode offset, SqlNode fetch) { if (offset instanceof SqlDynamicParam) { setValidatedNodeType(offset, typeFactory.createSqlType(SqlTypeName.INTEGER)); } if (fetch instanceof SqlDynamicParam) { setValidatedNodeType(fetch, typeFactory.createSqlType(SqlTypeName.INTEGER)); } }
@Override public RelDataType deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // To prevent operator rewriting by SqlFunction#deriveType. for (SqlNode operand : call.getOperandList()) { RelDataType nodeType = validator.deriveType(scope, operand); ((SqlValidatorImpl) validator).setValidatedNodeType(operand, nodeType); } return validateOperands(validator, scope, call); }
@Override public RelDataType deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // To prevent operator rewriting by SqlFunction#deriveType. for (SqlNode operand : call.getOperandList()) { RelDataType nodeType = validator.deriveType(scope, operand); ((SqlValidatorImpl) validator).setValidatedNodeType(operand, nodeType); } return validateOperands(validator, scope, call); }
public SqlNode expandOrderExpr(SqlSelect select, SqlNode orderExpr) { final SqlNode newSqlNode = new OrderExpressionExpander(select, orderExpr).go(); if (newSqlNode != orderExpr) { final SqlValidatorScope scope = getOrderScope(select); inferUnknownTypes(unknownType, scope, newSqlNode); final RelDataType type = deriveType(scope, newSqlNode); setValidatedNodeType(newSqlNode, type); } return newSqlNode; }
public SqlNode expandOrderExpr(SqlSelect select, SqlNode orderExpr) { final SqlNode newSqlNode = new OrderExpressionExpander(select, orderExpr).go(); if (newSqlNode != orderExpr) { final SqlValidatorScope scope = getOrderScope(select); inferUnknownTypes(unknownType, scope, newSqlNode); final RelDataType type = deriveType(scope, newSqlNode); setValidatedNodeType(newSqlNode, type); } return newSqlNode; }
protected RelDataType validateImpl(RelDataType targetRowType) { for (SqlNode withItem : with.withList) { validator.validateWithItem((SqlWithItem) withItem); } final SqlValidatorScope scope2 = validator.getWithScope(Util.last(with.withList.getList())); validator.validateQuery(with.body, scope2, targetRowType); final RelDataType rowType = validator.getValidatedNodeType(with.body); validator.setValidatedNodeType(with, rowType); return rowType; }
protected RelDataType validateImpl(RelDataType targetRowType) { for (SqlNode withItem : with.withList) { validator.validateWithItem((SqlWithItem) withItem); } final SqlValidatorScope scope2 = validator.getWithScope(Util.last(with.withList.getList())); validator.validateQuery(with.body, scope2, targetRowType); final RelDataType rowType = validator.getValidatedNodeType(with.body); validator.setValidatedNodeType(with, rowType); return rowType; }