protected RelDataType uniquifyFields(RelDataType rowType) { return validator.getTypeFactory().createStructType( RelOptUtil.getFieldTypeList(rowType), SqlValidatorUtil.uniquify(rowType.getFieldNames())); }
public ParseResult(OptiqPrepareImpl prepare, SqlValidator validator, String sql, SqlNode sqlNode, RelDataType rowType) { super(); this.prepare = prepare; this.sql = sql; this.sqlNode = sqlNode; this.rowType = rowType; this.typeFactory = validator.getTypeFactory(); } }
/** * Creates a call binding. * * @param validator Validator * @param scope Scope of call * @param call Call node */ public SqlCallBinding( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { super( validator.getTypeFactory(), call.getOperator()); this.validator = validator; this.scope = scope; this.call = call; }
/** * Creates a call binding. * * @param validator Validator * @param scope Scope of call * @param call Call node */ public SqlCallBinding( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { super( validator.getTypeFactory(), call.getOperator()); this.validator = validator; this.scope = scope; this.call = call; }
protected RelDataType uniquifyFields(RelDataType rowType) { final List<String> fieldNameList = new ArrayList<String>(rowType.getFieldNames()); SqlValidatorUtil.uniquify(fieldNameList); return validator.getTypeFactory().createStructType( RelOptUtil.getFieldTypeList(rowType), fieldNameList); }
public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // Check for COUNT(*) function. If it is we don't // want to try and derive the "*" if (call.isCountStar()) { return validator.getTypeFactory().createSqlType( SqlTypeName.BIGINT); } return super.deriveType(validator, scope, call); } }
public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // Check for COUNT(*) function. If it is we don't // want to try and derive the "*" if (call.isCountStar()) { return validator.getTypeFactory().createSqlType( SqlTypeName.BIGINT); } return super.deriveType(validator, scope, call); } }
protected RelDataType uniquifyFields(RelDataType rowType) { return validator.getTypeFactory().createStructType( RelOptUtil.getFieldTypeList(rowType), SqlValidatorUtil.uniquify(rowType.getFieldNames())); }
/** * Recreates a given RelDataType with nullablility iff any of a calls * operand types are nullable. */ public static RelDataType makeNullableIfOperandsAre( final SqlValidator validator, final SqlValidatorScope scope, final SqlCall call, RelDataType type) { for (SqlNode operand : call.operands) { RelDataType operandType = validator.deriveType(scope, operand); if (containsNullable(operandType)) { RelDataTypeFactory typeFactory = validator.getTypeFactory(); type = typeFactory.createTypeWithNullability(type, true); break; } } return type; }
/** * Recreates a given RelDataType with nullability iff any of the operands * of a call are nullable. */ public static RelDataType makeNullableIfOperandsAre( final SqlValidator validator, final SqlValidatorScope scope, final SqlCall call, RelDataType type) { for (SqlNode operand : call.getOperandList()) { RelDataType operandType = validator.deriveType(scope, operand); if (containsNullable(operandType)) { RelDataTypeFactory typeFactory = validator.getTypeFactory(); type = typeFactory.createTypeWithNullability(type, true); break; } } return type; }
public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { SqlSelect subSelect = (SqlSelect) call.operands[0]; subSelect.validateExpr(validator, scope); SqlValidatorNamespace ns = validator.getNamespace(subSelect); assert null != ns.getRowType(); return SqlTypeUtil.createMultisetType( validator.getTypeFactory(), ns.getRowType(), false); }
public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { SqlSelect subSelect = call.operand(0); subSelect.validateExpr(validator, scope); SqlValidatorNamespace ns = validator.getNamespace(subSelect); assert null != ns.getRowType(); return SqlTypeUtil.createMultisetType( validator.getTypeFactory(), ns.getRowType(), false); }
public RelDataType deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // Check for COUNT(*) function. If it is we don't // want to try and derive the "*" if (call.isCountStar()) { return validator.getTypeFactory().createSqlType(SqlTypeName.BIGINT); } return super.deriveType(validator, scope, call); } }
/** * Throws an error if the type is not built-in. */ public RelDataType deriveType(SqlValidator validator) { String name = typeName.getSimple(); // for now we only support builtin datatypes if (SqlTypeName.get(name) == null) { throw validator.newValidationError(this, RESOURCE.unknownDatatypeName(name)); } if (null != collectionsTypeName) { final String collectionName = collectionsTypeName.getSimple(); if (SqlTypeName.get(collectionName) == null) { throw validator.newValidationError(this, RESOURCE.unknownDatatypeName(collectionName)); } } RelDataTypeFactory typeFactory = validator.getTypeFactory(); return deriveType(typeFactory); }
validator.getTypeFactory() .createTypeWithCharsetAndCollation( type,
/** * Throws an error if the type is not built-in. */ public RelDataType deriveType(SqlValidator validator) { String name = typeName.getSimple(); // for now we only support builtin datatypes if (SqlTypeName.get(name) == null) { throw validator.newValidationError( this, EigenbaseResource.instance().UnknownDatatypeName.ex(name)); } if (null != collectionsTypeName) { final String collectionName = collectionsTypeName.getSimple(); if (!(SqlTypeName.get(collectionName) != null)) { throw validator.newValidationError( this, EigenbaseResource.instance().UnknownDatatypeName.ex( collectionName)); } } RelDataTypeFactory typeFactory = validator.getTypeFactory(); return deriveType(typeFactory); }
protected RelDataType adjustType( SqlValidator validator, SqlCall call, RelDataType type) { if (SqlTypeUtil.inCharFamily(type)) { // Determine coercibility and resulting collation name of // unary operator if needed. RelDataType operandType = validator.getValidatedNodeType(call.operands[0]); if (null == operandType) { throw Util.newInternal( "operand's type should have been derived"); } if (SqlTypeUtil.inCharFamily(operandType)) { SqlCollation collation = operandType.getCollation(); assert null != collation : "An implicit or explicit collation should have been set"; type = validator.getTypeFactory() .createTypeWithCharsetAndCollation( type, type.getCharset(), new SqlCollation( collation.getCollationName(), collation.getCoercibility())); } } return type; }
: "An implicit or explicit collation should have been set"; type = validator.getTypeFactory() .createTypeWithCharsetAndCollation( type,
protected RelDataType adjustType( SqlValidator validator, SqlCall call, RelDataType type) { if (SqlTypeUtil.inCharFamily(type)) { // Determine coercibility and resulting collation name of // unary operator if needed. RelDataType operandType = validator.getValidatedNodeType(call.operand(0)); if (null == operandType) { throw Util.newInternal( "operand's type should have been derived"); } if (SqlTypeUtil.inCharFamily(operandType)) { SqlCollation collation = operandType.getCollation(); assert null != collation : "An implicit or explicit collation should have been set"; type = validator.getTypeFactory() .createTypeWithCharsetAndCollation( type, type.getCharset(), new SqlCollation( collation.getCollationName(), collation.getCoercibility())); } } return type; }
protected RelDataType adjustType( SqlValidator validator, SqlCall call, RelDataType type) { if (SqlTypeUtil.inCharFamily(type)) { // Determine coercibility and resulting collation name of // unary operator if needed. RelDataType operandType = validator.getValidatedNodeType(call.operand(0)); if (null == operandType) { throw Util.newInternal( "operand's type should have been derived"); } if (SqlTypeUtil.inCharFamily(operandType)) { SqlCollation collation = operandType.getCollation(); assert null != collation : "An implicit or explicit collation should have been set"; type = validator.getTypeFactory() .createTypeWithCharsetAndCollation( type, type.getCharset(), new SqlCollation( collation.getCollationName(), collation.getCoercibility())); } } return type; }