/** * Returns the type inferred for a dynamic parameter. * * @param index 0-based index of dynamic parameter * @return inferred type, never null */ public RelDataType getDynamicParamType(int index) { SqlNode sqlNode = dynamicParamSqlNodes.get(index); if (sqlNode == null) { throw Util.needToImplement("dynamic param type inference"); } return validator.getValidatedNodeType(sqlNode); }
/** * Returns the type inferred for a dynamic parameter. * * @param index 0-based index of dynamic parameter * @return inferred type, never null */ public RelDataType getDynamicParamType(int index) { SqlNode sqlNode = dynamicParamSqlNodes.get(index); if (sqlNode == null) { throw Util.needToImplement("dynamic param type inference"); } return validator.getValidatedNodeType(sqlNode); }
/** * Returns the type inferred for a dynamic parameter. * * @param index 0-based index of dynamic parameter * @return inferred type, never null */ public RelDataType getDynamicParamType(int index) { SqlNode sqlNode = dynamicParamSqlNodes.get(index); if (sqlNode == null) { throw Util.needToImplement("dynamic param type inference"); } return validator.getValidatedNodeType(sqlNode); }
/** * Returns the type inferred for a dynamic parameter. * * @param index 0-based index of dynamic parameter * @return inferred type, never null */ public RelDataType getDynamicParamType(int index) { SqlNode sqlNode = dynamicParamSqlNodes.get(index); if (sqlNode == null) { throw Util.needToImplement("dynamic param type inference"); } return validator.getValidatedNodeType(sqlNode); }
/** * Casts a RexNode value to the validated type of a SqlCall. If the value * was already of the validated type, then the value is returned without an * additional cast. */ public static RexNode castToValidatedType(SqlNode node, RexNode e, SqlValidator validator, RexBuilder rexBuilder) { final RelDataType type = validator.getValidatedNodeType(node); if (e.getType() == type) { return e; } return rexBuilder.makeCast(type, e); }
/** * Casts a RexNode value to the validated type of a SqlCall. If the value * was already of the validated type, then the value is returned without an * additional cast. */ public static RexNode castToValidatedType(SqlNode node, RexNode e, SqlValidator validator, RexBuilder rexBuilder) { final RelDataType type = validator.getValidatedNodeType(node); if (e.getType() == type) { return e; } return rexBuilder.makeCast(type, e); }
public RexNode convertSequenceValue( SqlRexContext cx, SqlSequenceValueOperator fun, SqlCall call) { final List<SqlNode> operands = call.getOperandList(); assert operands.size() == 1; assert operands.get(0) instanceof SqlIdentifier; final SqlIdentifier id = (SqlIdentifier) operands.get(0); final String key = Util.listToString(id.names); RelDataType returnType = cx.getValidator().getValidatedNodeType(call); return cx.getRexBuilder().makeCall(returnType, fun, ImmutableList.of(cx.getRexBuilder().makeLiteral(key))); }
public RexNode convertSequenceValue( SqlRexContext cx, SqlSequenceValueOperator fun, SqlCall call) { final List<SqlNode> operands = call.getOperandList(); assert operands.size() == 1; assert operands.get(0) instanceof SqlIdentifier; final SqlIdentifier id = (SqlIdentifier) operands.get(0); final String key = Util.listToString(id.names); RelDataType returnType = cx.getValidator().getValidatedNodeType(call); return cx.getRexBuilder().makeCall(returnType, fun, ImmutableList.of(cx.getRexBuilder().makeLiteral(key))); }
public RexNode convertDatetimeMinus( SqlRexContext cx, SqlDatetimeSubtractionOperator op, SqlCall call) { // Rewrite datetime minus final RexBuilder rexBuilder = cx.getRexBuilder(); final List<SqlNode> operands = call.getOperandList(); final List<RexNode> exprs = convertExpressionList(cx, operands, SqlOperandTypeChecker.Consistency.NONE); final RelDataType resType = cx.getValidator().getValidatedNodeType(call); return rexBuilder.makeCall(resType, op, exprs.subList(0, 2)); }
public RexNode convertDatetimeMinus( SqlRexContext cx, SqlDatetimeSubtractionOperator op, SqlCall call) { // Rewrite datetime minus final RexBuilder rexBuilder = cx.getRexBuilder(); final List<SqlNode> operands = call.getOperandList(); final List<RexNode> exprs = convertExpressionList(cx, operands, SqlOperandTypeChecker.Consistency.NONE); final RelDataType resType = cx.getValidator().getValidatedNodeType(call); return rexBuilder.makeCall(resType, op, exprs.subList(0, 2)); }
public RelDataType getResultType(String sql) { SqlValidator validator = getValidator(); SqlNode n = parseAndValidate(validator, sql); return validator.getValidatedNodeType(n); }
public RelDataType getResultType(String sql) { SqlValidator validator = getValidator(); SqlNode n = parseAndValidate(validator, sql); return validator.getValidatedNodeType(n); }
@Override public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) { final SqlValidator validator = callBinding.getValidator(); RelDataType defaultValueOnEmptyType = validator.getValidatedNodeType(callBinding.operand(2)); RelDataType defaultValueOnErrorType = validator.getValidatedNodeType(callBinding.operand(4)); RelDataType returnType = validator.deriveType(callBinding.getScope(), callBinding.operand(5)); if (!canCastFrom(callBinding, throwOnFailure, defaultValueOnEmptyType, returnType)) { return false; } if (!canCastFrom(callBinding, throwOnFailure, defaultValueOnErrorType, returnType)) { return false; } return true; }
protected RelNode convertInsert(SqlInsert call) { RelOptTable targetTable = getTargetTable(call); final RelDataType targetRowType = validator.getValidatedNodeType(call); assert targetRowType != null; RelNode sourceRel = convertQueryRecursive(call.getSource(), false, targetRowType).project(); RelNode massagedRel = convertColumnList(call, sourceRel); return createModify(targetTable, massagedRel); }
protected RelNode convertInsert(SqlInsert call) { RelOptTable targetTable = getTargetTable(call); final RelDataType targetRowType = validator.getValidatedNodeType(call); assert targetRowType != null; RelNode sourceRel = convertQueryRecursive(call.getSource(), false, targetRowType).project(); RelNode massagedRel = convertColumnList(call, sourceRel); return createModify(targetTable, massagedRel); }
protected RelNode convertInsert(SqlInsert call) { RelOptTable targetTable = getTargetTable(call); final RelDataType targetRowType = validator.getValidatedNodeType(call); assert targetRowType != null; RelNode sourceRel = convertQueryRecursive(call.getSource(), false, targetRowType).project(); RelNode massagedRel = convertColumnList(call, sourceRel); return createModify(targetTable, massagedRel); }
protected RelNode convertInsert(SqlInsert call) { RelOptTable targetTable = getTargetTable(call); final RelDataType targetRowType = validator.getValidatedNodeType(call); assert targetRowType != null; RelNode sourceRel = convertQueryRecursive(call.getSource(), false, targetRowType).project(); RelNode massagedRel = convertColumnList(call, sourceRel); return createModify(targetTable, massagedRel); }
/** * Throws an error if the type is not found. */ public RelDataType deriveType(SqlValidator validator) { RelDataType type = null; if (typeName.isSimple()) { if (null != collectionsTypeName) { final String collectionName = collectionsTypeName.getSimple(); if (SqlTypeName.get(collectionName) == null) { throw validator.newValidationError(this, RESOURCE.unknownDatatypeName(collectionName)); } } RelDataTypeFactory typeFactory = validator.getTypeFactory(); type = deriveType(typeFactory); } if (type == null) { type = validator.getValidatedNodeType(typeName); } return type; }
public void checkMonotonic(String query, SqlMonotonicity expectedMonotonicity) { SqlValidator validator = getValidator(); SqlNode n = parseAndValidate(validator, query); final RelDataType rowType = validator.getValidatedNodeType(n); final SqlValidatorNamespace selectNamespace = validator.getNamespace(n); final String field0 = rowType.getFieldList().get(0).getName(); final SqlMonotonicity monotonicity = selectNamespace.getMonotonicity(field0); assertThat(monotonicity, equalTo(expectedMonotonicity)); }
public void checkMonotonic(String query, SqlMonotonicity expectedMonotonicity) { SqlValidator validator = getValidator(); SqlNode n = parseAndValidate(validator, query); final RelDataType rowType = validator.getValidatedNodeType(n); final SqlValidatorNamespace selectNamespace = validator.getNamespace(n); final String field0 = rowType.getFieldList().get(0).getName(); final SqlMonotonicity monotonicity = selectNamespace.getMonotonicity(field0); assertThat(monotonicity, equalTo(expectedMonotonicity)); }