本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeFactory.createStructType方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeFactory.createStructType方法的具体用法?Java RelDataTypeFactory.createStructType怎么用?Java RelDataTypeFactory.createStructType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.type.RelDataTypeFactory
的用法示例。
在下文中一共展示了RelDataTypeFactory.createStructType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* This method constructs a {@link org.apache.calcite.rel.type.RelDataType} based on the
* {@link org.apache.drill.exec.store.RecordDataType}'s field sql types and field names.
*
* @param factory helps construct a {@link org.apache.calcite.rel.type.RelDataType}
* @return the constructed type
*/
public final RelDataType getRowType(RelDataTypeFactory factory) {
final List<SqlTypeName> types = getFieldSqlTypeNames();
final List<String> names = getFieldNames();
final List<RelDataType> fields = Lists.newArrayList();
for (final SqlTypeName typeName : types) {
switch (typeName) {
case VARCHAR:
fields.add(factory.createSqlType(typeName, Integer.MAX_VALUE));
break;
default:
fields.add(factory.createSqlType(typeName));
}
}
return factory.createStructType(fields, names);
}
示例2: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
List<RelDataType> typeList = Lists.newArrayList();
List<String> fieldNameList = Lists.newArrayList();
List<FieldSchema> hiveFields = hiveTable.getCols();
for(FieldSchema hiveField : hiveFields) {
fieldNameList.add(hiveField.getName());
typeList.add(getNullableRelDataTypeFromHiveType(
typeFactory, TypeInfoUtils.getTypeInfoFromTypeString(hiveField.getType())));
}
for (FieldSchema field : hiveTable.getPartitionKeys()) {
fieldNameList.add(field.getName());
typeList.add(getNullableRelDataTypeFromHiveType(
typeFactory, TypeInfoUtils.getTypeInfoFromTypeString(field.getType())));
}
return typeFactory.createStructType(typeList, fieldNameList);
}
示例3: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* This method constructs a {@link org.apache.calcite.rel.type.RelDataType} based on the
* {@link com.dremio.exec.store.RecordDataType}'s field sql types and field names.
*
* @param factory helps construct a {@link org.apache.calcite.rel.type.RelDataType}
* @return the constructed type
*/
public final RelDataType getRowType(RelDataTypeFactory factory) {
final List<SqlTypeName> types = getFieldSqlTypeNames();
final List<String> names = getFieldNames();
final List<RelDataType> fields = Lists.newArrayList();
for (final SqlTypeName typeName : types) {
switch (typeName) {
case VARCHAR:
fields.add(factory.createSqlType(typeName, Integer.MAX_VALUE));
break;
default:
fields.add(factory.createSqlType(typeName));
}
}
return factory.createStructType(fields, names);
}
示例4: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
List<RelDataType> typeList = Lists.newArrayList();
List<String> fieldNameList = Lists.newArrayList();
List<FieldSchema> hiveFields = hiveTable.getColumnListsCache().getColumns(0);
for(FieldSchema hiveField : hiveFields) {
fieldNameList.add(hiveField.getName());
typeList.add(getNullableRelDataTypeFromHiveType(
typeFactory, TypeInfoUtils.getTypeInfoFromTypeString(hiveField.getType())));
}
for (FieldSchema field : hiveTable.getPartitionKeys()) {
fieldNameList.add(field.getName());
typeList.add(getNullableRelDataTypeFromHiveType(
typeFactory, TypeInfoUtils.getTypeInfoFromTypeString(field.getType())));
}
return typeFactory.createStructType(typeList, fieldNameList);
}
示例5: toSql
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/** Converts a type in Java format to a SQL-oriented type. */
public static RelDataType toSql(final RelDataTypeFactory typeFactory,
RelDataType type) {
if (type instanceof RelRecordType) {
return typeFactory.createStructType(
Lists.transform(type.getFieldList(),
new Function<RelDataTypeField, RelDataType>() {
public RelDataType apply(RelDataTypeField a0) {
return toSql(typeFactory, a0.getType());
}
}),
type.getFieldNames());
}
if (type instanceof JavaType) {
return typeFactory.createTypeWithNullability(
typeFactory.createSqlType(type.getSqlTypeName()),
type.isNullable());
}
return type;
}
示例6: createDmlRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* Creates the row type descriptor for the result of a DML operation, which
* is a single column named ROWCOUNT of type BIGINT for INSERT;
* a single column named PLAN for EXPLAIN.
*
* @param kind Kind of node
* @param typeFactory factory to use for creating type descriptor
* @return created type
*/
public static RelDataType createDmlRowType(
SqlKind kind,
RelDataTypeFactory typeFactory) {
switch (kind) {
case INSERT:
case DELETE:
case UPDATE:
return typeFactory.createStructType(
ImmutableList.of(
Pair.of(AvaticaConnection.ROWCOUNT_COLUMN_NAME,
typeFactory.createSqlType(SqlTypeName.BIGINT))));
case EXPLAIN:
return typeFactory.createStructType(
ImmutableList.of(
Pair.of(AvaticaConnection.PLAN_COLUMN_NAME,
typeFactory.createSqlType(
SqlTypeName.VARCHAR,
RelDataType.PRECISION_NOT_SPECIFIED))));
default:
throw Util.unexpected(kind);
}
}
示例7: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
Collection<SqlTypeName> values = columns.values();
List<RelDataType> relDateTypeList = new ArrayList<>();
for (SqlTypeName sqlTypeName : values) {
relDateTypeList.add(typeFactory.createSqlType(sqlTypeName));
}
return typeFactory.createStructType(relDateTypeList, new ArrayList<>(columns.keySet()));
}
示例8: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory factory) {
// if there are no fields defined, this is a dynamic view.
if (isDynamic()) {
return new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory);
}
List<RelDataType> types = Lists.newArrayList();
List<String> names = Lists.newArrayList();
for (FieldType field : fields) {
names.add(field.getName());
RelDataType type;
if ( SqlTypeFamily.INTERVAL_YEAR_MONTH == field.getType().getFamily()
|| SqlTypeFamily.INTERVAL_DAY_TIME == field.getType().getFamily() ) {
type = factory.createSqlIntervalType( field.getIntervalQualifier() );
} else if (field.getPrecision() == null && field.getScale() == null) {
type = factory.createSqlType(field.getType());
} else if (field.getPrecision() != null && field.getScale() == null) {
type = factory.createSqlType(field.getType(), field.getPrecision());
} else {
type = factory.createSqlType(field.getType(), field.getPrecision(), field.getScale());
}
if (field.getIsNullable()) {
types.add(factory.createTypeWithNullability(type, true));
} else {
types.add(type);
}
}
return factory.createStructType(types, names);
}
示例9: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
// Convert the array of Drill types to an array of Optiq types
List<RelDataType> relTypes = Lists.newArrayList();
List<String> fieldNames = Lists.newArrayList();
for (Field field : fields) {
relTypes.add(getRelDataType(typeFactory, field.type));
fieldNames.add(field.name);
}
return typeFactory.createStructType(relTypes, fieldNames);
}
示例10: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
ArrayList<RelDataType> typeList = new ArrayList<>();
ArrayList<String> fieldNameList = new ArrayList<>();
fieldNameList.add(ROW_KEY);
typeList.add(typeFactory.createSqlType(SqlTypeName.ANY));
Set<byte[]> families = table.getFamiliesKeys();
for (byte[] family : families) {
fieldNameList.add(Bytes.toString(family));
typeList.add(typeFactory.createMapType(typeFactory.createSqlType(SqlTypeName.VARCHAR), typeFactory.createSqlType(SqlTypeName.ANY)));
}
return typeFactory.createStructType(typeList, fieldNameList);
}
示例11: createNativeScanRel
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* Helper method which creates a DrillScalRel with native HiveScan.
*/
private DrillScanRel createNativeScanRel(final Map<String, String> partitionColMapping,
final DrillScanRel hiveScanRel) throws Exception{
final RelDataTypeFactory typeFactory = hiveScanRel.getCluster().getTypeFactory();
final RelDataType varCharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
final List<String> nativeScanColNames = Lists.newArrayList();
final List<RelDataType> nativeScanColTypes = Lists.newArrayList();
for (RelDataTypeField field : hiveScanRel.getRowType().getFieldList()) {
final String dirColName = partitionColMapping.get(field.getName());
if (dirColName != null) { // partition column
nativeScanColNames.add(dirColName);
nativeScanColTypes.add(varCharType);
} else {
nativeScanColNames.add(field.getName());
nativeScanColTypes.add(field.getType());
}
}
final RelDataType nativeScanRowType = typeFactory.createStructType(nativeScanColTypes, nativeScanColNames);
// Create the list of projected columns set in HiveScan. The order of this list may not be same as the order of
// columns in HiveScan row type. Note: If the HiveScan.getColumn() contains a '*', we just need to add it as it is,
// unlike above where we expanded the '*'. HiveScan and related (subscan) can handle '*'.
final List<SchemaPath> nativeScanCols = Lists.newArrayList();
for(SchemaPath colName : hiveScanRel.getColumns()) {
final String partitionCol = partitionColMapping.get(colName.getAsUnescapedPath());
if (partitionCol != null) {
nativeScanCols.add(SchemaPath.getSimplePath(partitionCol));
} else {
nativeScanCols.add(colName);
}
}
final HiveScan hiveScan = (HiveScan) hiveScanRel.getGroupScan();
final HiveDrillNativeParquetScan nativeHiveScan =
new HiveDrillNativeParquetScan(
hiveScan.getUserName(),
hiveScan.hiveReadEntry,
hiveScan.storagePlugin,
nativeScanCols);
return new DrillScanRel(
hiveScanRel.getCluster(),
hiveScanRel.getTraitSet(),
hiveScanRel.getTable(),
nativeHiveScan,
nativeScanRowType,
nativeScanCols);
}
示例12: 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;
}
示例13: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory factory) {
List<RelDataType> types = Lists.newArrayList();
List<String> names = Lists.newArrayList();
for (FieldType field : fields) {
names.add(field.getName());
RelDataType type;
if ( SqlTypeFamily.INTERVAL_YEAR_MONTH == field.getType().getFamily()
|| SqlTypeFamily.INTERVAL_DAY_TIME == field.getType().getFamily() ) {
type = factory.createSqlIntervalType( field.getIntervalQualifier() );
} else if (field.getType().equals(SqlTypeName.ARRAY) || field.getType().equals(SqlTypeName.MAP)) {
type = factory.createSqlType(SqlTypeName.ANY);
} else if (field.getPrecision() == null && field.getScale() == null) {
type = factory.createSqlType(field.getType());
} else if (field.getPrecision() != null && field.getScale() == null) {
type = factory.createSqlType(field.getType(), field.getPrecision());
} else {
type = factory.createSqlType(field.getType(), field.getPrecision(), field.getScale());
}
if (field.getIsNullable()) {
types.add(factory.createTypeWithNullability(type, true));
} else {
types.add(type);
}
}
return factory.createStructType(types, names);
}
示例14: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
// Convert the array of Dremio types to an array of Calcite types
List<RelDataType> relTypes = Lists.newArrayList();
List<String> fieldNames = Lists.newArrayList();
for (Field field : fields) {
relTypes.add(getRelDataType(typeFactory, field.type));
fieldNames.add(field.name);
}
return typeFactory.createStructType(relTypes, fieldNames);
}
示例15: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
List<RelDataType> typeList = Lists.newArrayList();
List<String> fieldNameList = Lists.newArrayList();
convertToRelDataType(typeFactory, fieldNameList, typeList);
return typeFactory.createStructType(typeList, fieldNameList);
}