本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeFactory.createTypeWithCharsetAndCollation方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeFactory.createTypeWithCharsetAndCollation方法的具体用法?Java RelDataTypeFactory.createTypeWithCharsetAndCollation怎么用?Java RelDataTypeFactory.createTypeWithCharsetAndCollation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.type.RelDataTypeFactory
的用法示例。
在下文中一共展示了RelDataTypeFactory.createTypeWithCharsetAndCollation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCharsetAndCollation
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* Adds collation and charset to a character type, returns other types
* unchanged.
*
* @param type Type
* @param typeFactory Type factory
* @return Type with added charset and collation, or unchanged type if it is
* not a char type.
*/
public static RelDataType addCharsetAndCollation(
RelDataType type,
RelDataTypeFactory typeFactory) {
if (!inCharFamily(type)) {
return type;
}
Charset charset = type.getCharset();
if (charset == null) {
charset = typeFactory.getDefaultCharset();
}
SqlCollation collation = type.getCollation();
if (collation == null) {
collation = SqlCollation.IMPLICIT;
}
// todo: should get the implicit collation from repository
// instead of null
type =
typeFactory.createTypeWithCharsetAndCollation(
type,
charset,
collation);
SqlValidatorUtil.checkCharsetAndCollateConsistentIfCharType(type);
return type;
}
示例2: addCharsetAndCollation
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* Adds collation and charset to a character type, returns other types
* unchanged.
*
* @param type Type
* @param typeFactory Type factory
* @return Type with added charset and collation, or unchanged type if it is
* not a char type.
*/
public static RelDataType addCharsetAndCollation(
RelDataType type,
RelDataTypeFactory typeFactory) {
if (!inCharFamily(type)) {
return type;
}
Charset charset = type.getCharset();
if (charset == null) {
charset = typeFactory.getDefaultCharset();
}
SqlCollation collation = type.getCollation();
if (collation == null) {
collation = SqlCollation.IMPLICIT;
}
// todo: should get the implicit collation from repository
// instead of null
type =
typeFactory.createTypeWithCharsetAndCollation(
type,
charset,
collation);
SqlValidatorUtil.checkCharsetAndCollateConsistentIfCharType(type);
return type;
}
示例3: createNlsStringType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* Creates the type of an {@link org.apache.calcite.util.NlsString}.
*
* <p>The type inherits the The NlsString's {@link Charset} and
* {@link SqlCollation}, if they are set, otherwise it gets the system
* defaults.
*
* @param typeFactory Type factory
* @param str String
* @return Type, including collation and charset
*/
public static RelDataType createNlsStringType(
RelDataTypeFactory typeFactory,
NlsString str) {
Charset charset = str.getCharset();
if (null == charset) {
charset = typeFactory.getDefaultCharset();
}
SqlCollation collation = str.getCollation();
if (null == collation) {
collation = SqlCollation.COERCIBLE;
}
RelDataType type =
typeFactory.createSqlType(
SqlTypeName.CHAR,
str.getValue().length());
type =
typeFactory.createTypeWithCharsetAndCollation(
type,
charset,
collation);
return type;
}
示例4: getRelDataTypeFromHivePrimitiveType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
private RelDataType getRelDataTypeFromHivePrimitiveType(RelDataTypeFactory typeFactory, PrimitiveTypeInfo pTypeInfo) {
switch(pTypeInfo.getPrimitiveCategory()) {
case BOOLEAN:
return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
case BYTE:
case SHORT:
return typeFactory.createSqlType(SqlTypeName.INTEGER);
case INT:
return typeFactory.createSqlType(SqlTypeName.INTEGER);
case LONG:
return typeFactory.createSqlType(SqlTypeName.BIGINT);
case FLOAT:
return typeFactory.createSqlType(SqlTypeName.FLOAT);
case DOUBLE:
return typeFactory.createSqlType(SqlTypeName.DOUBLE);
case DATE:
return typeFactory.createSqlType(SqlTypeName.DATE);
case TIMESTAMP:
return typeFactory.createSqlType(SqlTypeName.TIMESTAMP);
case BINARY:
return typeFactory.createSqlType(SqlTypeName.VARBINARY);
case DECIMAL: {
DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo)pTypeInfo;
return typeFactory.createSqlType(SqlTypeName.DECIMAL, decimalTypeInfo.precision(), decimalTypeInfo.scale());
}
case STRING:
case VARCHAR: {
int maxLen = TypeInfoUtils.getCharacterLengthForType(pTypeInfo);
return typeFactory.createTypeWithCharsetAndCollation(
typeFactory.createSqlType(SqlTypeName.VARCHAR, maxLen), /*input type*/
Charset.forName("ISO-8859-1"), /*unicode char set*/
SqlCollation.IMPLICIT /* TODO: need to decide if implicit is the correct one */
);
}
case UNKNOWN:
case VOID:
default:
throwUnsupportedHiveDataTypeError(pTypeInfo.getPrimitiveCategory().toString());
}
return null;
}
示例5: createSqlType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType createSqlType(RelDataTypeFactory typeFactory) {
BitString bitString;
switch (typeName) {
case NULL:
case BOOLEAN:
RelDataType ret = typeFactory.createSqlType(typeName);
ret = typeFactory.createTypeWithNullability(ret, null == value);
return ret;
case BINARY:
bitString = (BitString) value;
int bitCount = bitString.getBitCount();
return typeFactory.createSqlType(SqlTypeName.BINARY, bitCount / 8);
case CHAR:
NlsString string = (NlsString) value;
Charset charset = string.getCharset();
if (null == charset) {
charset = typeFactory.getDefaultCharset();
}
SqlCollation collation = string.getCollation();
if (null == collation) {
collation = SqlCollation.COERCIBLE;
}
RelDataType type =
typeFactory.createSqlType(
SqlTypeName.CHAR,
string.getValue().length());
type =
typeFactory.createTypeWithCharsetAndCollation(
type,
charset,
collation);
return type;
case INTERVAL_YEAR:
case INTERVAL_YEAR_MONTH:
case INTERVAL_MONTH:
case INTERVAL_DAY:
case INTERVAL_DAY_HOUR:
case INTERVAL_DAY_MINUTE:
case INTERVAL_DAY_SECOND:
case INTERVAL_HOUR:
case INTERVAL_HOUR_MINUTE:
case INTERVAL_HOUR_SECOND:
case INTERVAL_MINUTE:
case INTERVAL_MINUTE_SECOND:
case INTERVAL_SECOND:
SqlIntervalLiteral.IntervalValue intervalValue =
(SqlIntervalLiteral.IntervalValue) value;
return typeFactory.createSqlIntervalType(
intervalValue.getIntervalQualifier());
case SYMBOL:
return typeFactory.createSqlType(SqlTypeName.SYMBOL);
case INTEGER: // handled in derived class
case TIME: // handled in derived class
case VARCHAR: // should never happen
case VARBINARY: // should never happen
default:
throw Util.needToImplement(toString() + ", operand=" + value);
}
}