本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeFactory.createMapType方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeFactory.createMapType方法的具体用法?Java RelDataTypeFactory.createMapType怎么用?Java RelDataTypeFactory.createMapType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.type.RelDataTypeFactory
的用法示例。
在下文中一共展示了RelDataTypeFactory.createMapType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRelDataTypeFromHiveType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
private RelDataType getRelDataTypeFromHiveType(RelDataTypeFactory typeFactory, TypeInfo typeInfo) {
switch(typeInfo.getCategory()) {
case PRIMITIVE:
return getRelDataTypeFromHivePrimitiveType(typeFactory, ((PrimitiveTypeInfo) typeInfo));
case LIST: {
ListTypeInfo listTypeInfo = (ListTypeInfo)typeInfo;
RelDataType listElemTypeInfo = getRelDataTypeFromHiveType(typeFactory, listTypeInfo.getListElementTypeInfo());
return typeFactory.createArrayType(listElemTypeInfo, -1);
}
case MAP: {
MapTypeInfo mapTypeInfo = (MapTypeInfo)typeInfo;
RelDataType keyType = getRelDataTypeFromHiveType(typeFactory, mapTypeInfo.getMapKeyTypeInfo());
RelDataType valueType = getRelDataTypeFromHiveType(typeFactory, mapTypeInfo.getMapValueTypeInfo());
return typeFactory.createMapType(keyType, valueType);
}
case STRUCT: {
StructTypeInfo structTypeInfo = (StructTypeInfo)typeInfo;
ArrayList<String> fieldNames = structTypeInfo.getAllStructFieldNames();
ArrayList<TypeInfo> fieldHiveTypeInfoList = structTypeInfo.getAllStructFieldTypeInfos();
List<RelDataType> fieldRelDataTypeList = Lists.newArrayList();
for(TypeInfo fieldHiveType : fieldHiveTypeInfoList) {
fieldRelDataTypeList.add(getRelDataTypeFromHiveType(typeFactory, fieldHiveType));
}
return typeFactory.createStructType(fieldRelDataTypeList, fieldNames);
}
case UNION:
logger.warn("There is no UNION data type in SQL. Converting it to Sql type OTHER to avoid " +
"breaking INFORMATION_SCHEMA queries");
return typeFactory.createSqlType(SqlTypeName.OTHER);
}
throwUnsupportedHiveDataTypeError(typeInfo.getCategory().toString());
return null;
}
示例2: createMapType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public static RelDataType createMapType(
RelDataTypeFactory typeFactory,
RelDataType keyType,
RelDataType valueType,
boolean nullable) {
RelDataType ret = typeFactory.createMapType(keyType, valueType);
return typeFactory.createTypeWithNullability(ret, nullable);
}
示例3: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
final RelDataType mapType =
typeFactory.createMapType(
typeFactory.createSqlType(SqlTypeName.VARCHAR),
typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.ANY), true));
return typeFactory.builder().add("_MAP", mapType).build();
}
示例4: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory relDataTypeFactory) {
final RelDataType mapType = relDataTypeFactory.createMapType(
relDataTypeFactory.createSqlType(SqlTypeName.VARCHAR),
relDataTypeFactory.createTypeWithNullability(
relDataTypeFactory.createSqlType(SqlTypeName.ANY),
true));
return relDataTypeFactory.builder().add("_MAP", mapType).build();
}
示例5: createMapType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public static RelDataType createMapType(
RelDataTypeFactory typeFactory,
RelDataType keyType,
RelDataType valueType,
boolean nullable) {
RelDataType ret = typeFactory.createMapType(keyType, valueType);
return typeFactory.createTypeWithNullability(ret, nullable);
}
示例6: getNullableRelDataTypeFromAvroType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
private RelDataType getNullableRelDataTypeFromAvroType(
RelDataTypeFactory typeFactory, Schema fieldSchema) {
RelDataType relDataType = null;
switch (fieldSchema.getType()) {
case ARRAY:
RelDataType eleType = getNullableRelDataTypeFromAvroType(typeFactory, fieldSchema.getElementType());
relDataType = typeFactory.createArrayType(eleType, -1);
break;
case BOOLEAN:
relDataType = typeFactory.createSqlType(SqlTypeName.BOOLEAN);
break;
case BYTES:
relDataType = typeFactory.createSqlType(SqlTypeName.BINARY);
break;
case DOUBLE:
relDataType = typeFactory.createSqlType(SqlTypeName.DOUBLE);
break;
case FIXED:
logger.error("{} type not supported", fieldSchema.getType());
throw UserException.unsupportedError().message("FIXED type not supported yet").build(logger);
case FLOAT:
relDataType = typeFactory.createSqlType(SqlTypeName.FLOAT);
break;
case INT:
relDataType = typeFactory.createSqlType(SqlTypeName.INTEGER);
break;
case LONG:
relDataType = typeFactory.createSqlType(SqlTypeName.BIGINT);
break;
case MAP:
RelDataType valueType = getNullableRelDataTypeFromAvroType(typeFactory, fieldSchema.getValueType());
RelDataType keyType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
relDataType = typeFactory.createMapType(keyType, valueType);
break;
case NULL:
relDataType = typeFactory.createSqlType(SqlTypeName.NULL);
break;
case RECORD:
// List<String> fieldNameList = Lists.newArrayList();
// List<RelDataType> fieldRelDataTypeList = Lists.newArrayList();
// for(Field field : fieldSchema.getFields()) {
// fieldNameList.add(field.name());
// fieldRelDataTypeList.add(getNullableRelDataTypeFromAvroType(typeFactory, field.schema()));
// }
// relDataType = typeFactory.createStructType(fieldRelDataTypeList, fieldNameList);
//TODO This has to be mapped to struct type but because of calcite issue,
//for now mapping it to map type.
keyType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
valueType = typeFactory.createSqlType(SqlTypeName.ANY);
relDataType = typeFactory.createMapType(keyType, valueType);
break;
case ENUM:
case STRING:
relDataType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
break;
case UNION:
RelDataType optinalType = getNullableRelDataTypeFromAvroType(typeFactory, fieldSchema.getTypes().get(1));
relDataType = typeFactory.createTypeWithNullability(optinalType, true);
break;
}
return relDataType;
}
示例7: toType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
private RelDataType toType(Ast.MapType type) {
final RelDataTypeFactory typeFactory = builder.getTypeFactory();
final RelDataType k = toType(type.keyType);
final RelDataType v = toType(type.valueType);
return typeFactory.createMapType(k, v);
}