public TypeSignature getTypeSignature() { return getTypeSignature(typeInfo); }
private static boolean isQuotedType(HiveType type) { return QUOTED_TYPES.contains(type.getTypeSignature().getBase()); } }
public Type getType(TypeManager typeManager) { return typeManager.getType(getTypeSignature()); }
public static List<HiveColumnHandle> toColumnHandles(List<ColumnMapping> regularColumnMappings, boolean doCoercion) { return regularColumnMappings.stream() .map(columnMapping -> { HiveColumnHandle columnHandle = columnMapping.getHiveColumnHandle(); if (!doCoercion || !columnMapping.getCoercionFrom().isPresent()) { return columnHandle; } return new HiveColumnHandle( columnHandle.getName(), columnMapping.getCoercionFrom().get(), columnMapping.getCoercionFrom().get().getTypeSignature(), columnHandle.getHiveColumnIndex(), columnHandle.getColumnType(), Optional.empty()); }) .collect(toList()); } }
public static List<HiveColumnHandle> getRegularColumnHandles(Table table) { ImmutableList.Builder<HiveColumnHandle> columns = ImmutableList.builder(); int hiveColumnIndex = 0; for (Column field : table.getDataColumns()) { // ignore unsupported types rather than failing HiveType hiveType = field.getType(); if (hiveType.isSupportedType()) { columns.add(new HiveColumnHandle(field.getName(), hiveType, hiveType.getTypeSignature(), hiveColumnIndex, REGULAR, field.getComment())); } hiveColumnIndex++; } return columns.build(); }
public static List<HiveColumnHandle> getPartitionKeyColumnHandles(Table table) { ImmutableList.Builder<HiveColumnHandle> columns = ImmutableList.builder(); List<Column> partitionKeys = table.getPartitionColumns(); for (Column field : partitionKeys) { HiveType hiveType = field.getType(); if (!hiveType.isSupportedType()) { throw new PrestoException(NOT_SUPPORTED, format("Unsupported Hive type %s found in partition keys of table %s.%s", hiveType, table.getDatabaseName(), table.getTableName())); } columns.add(new HiveColumnHandle(field.getName(), hiveType, hiveType.getTypeSignature(), -1, PARTITION_KEY, field.getComment())); } return columns.build(); }
private void checkPartitionTypesSupported(List<Column> partitionColumns) { for (Column partitionColumn : partitionColumns) { Type partitionType = typeManager.getType(partitionColumn.getType().getTypeSignature()); verifyPartitionTypeSupported(partitionColumn.getName(), partitionType); } }
case MAP: MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo; TypeSignature keyType = getTypeSignature(mapTypeInfo.getMapKeyTypeInfo()); TypeSignature valueType = getTypeSignature(mapTypeInfo.getMapValueTypeInfo()); return new TypeSignature( StandardTypes.MAP, case LIST: ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo; TypeSignature elementType = getTypeSignature(listTypeInfo.getListElementTypeInfo()); return new TypeSignature( StandardTypes.ARRAY, TypeSignature typeSignature = getTypeSignature(structFieldTypeInfos.get(i));
private static List<HiveColumnHandle> getColumnHandles() { ImmutableList.Builder<HiveColumnHandle> handles = ImmutableList.builder(); List<LineItemColumn> columns = getTestColumns(); for (int i = 0; i < columns.size(); i++) { LineItemColumn column = columns.get(i); HiveType hiveType = getHiveType(column.getType()); handles.add(new HiveColumnHandle(column.getColumnName(), hiveType, hiveType.getTypeSignature(), i, REGULAR, Optional.empty())); } return handles.build(); }
private Type canonicalizeType(Type type) { HiveType hiveType = HiveType.toHiveType(typeTranslator, type); return TYPE_MANAGER.getType(hiveType.getTypeSignature()); }
protected List<HiveColumnHandle> getColumnHandles(List<TestColumn> testColumns) { List<HiveColumnHandle> columns = new ArrayList<>(); int nextHiveColumnIndex = 0; for (int i = 0; i < testColumns.size(); i++) { TestColumn testColumn = testColumns.get(i); int columnIndex = testColumn.isPartitionKey() ? -1 : nextHiveColumnIndex++; HiveType hiveType = HiveType.valueOf(testColumn.getObjectInspector().getTypeName()); columns.add(new HiveColumnHandle(testColumn.getName(), hiveType, hiveType.getTypeSignature(), columnIndex, testColumn.isPartitionKey() ? PARTITION_KEY : REGULAR, Optional.empty())); } return columns; }
@Override public boolean canCoerce(HiveType fromHiveType, HiveType toHiveType) { Type fromType = typeManager.getType(fromHiveType.getTypeSignature()); Type toType = typeManager.getType(toHiveType.getTypeSignature()); if (fromType instanceof VarcharType) { return toHiveType.equals(HIVE_BYTE) || toHiveType.equals(HIVE_SHORT) || toHiveType.equals(HIVE_INT) || toHiveType.equals(HIVE_LONG); } if (toType instanceof VarcharType) { return fromHiveType.equals(HIVE_BYTE) || fromHiveType.equals(HIVE_SHORT) || fromHiveType.equals(HIVE_INT) || fromHiveType.equals(HIVE_LONG); } if (fromHiveType.equals(HIVE_BYTE)) { return toHiveType.equals(HIVE_SHORT) || toHiveType.equals(HIVE_INT) || toHiveType.equals(HIVE_LONG); } if (fromHiveType.equals(HIVE_SHORT)) { return toHiveType.equals(HIVE_INT) || toHiveType.equals(HIVE_LONG); } if (fromHiveType.equals(HIVE_INT)) { return toHiveType.equals(HIVE_LONG); } if (fromHiveType.equals(HIVE_FLOAT)) { return toHiveType.equals(HIVE_DOUBLE); } return canCoerceForList(fromHiveType, toHiveType) || canCoerceForMap(fromHiveType, toHiveType) || canCoerceForStruct(fromHiveType, toHiveType); }
private static Function<Block, Block> createCoercer(TypeManager typeManager, HiveType fromHiveType, HiveType toHiveType) Type fromType = typeManager.getType(fromHiveType.getTypeSignature()); Type toType = typeManager.getType(toHiveType.getTypeSignature()); if (toType instanceof VarcharType && (fromHiveType.equals(HIVE_BYTE) || fromHiveType.equals(HIVE_SHORT) || fromHiveType.equals(HIVE_INT) || fromHiveType.equals(HIVE_LONG))) { return new IntegerNumberToVarcharCoercer(fromType, toType);
private static Coercer createCoercer(TypeManager typeManager, HiveType fromHiveType, HiveType toHiveType, BridgingRecordCursor bridgingRecordCursor) Type fromType = typeManager.getType(fromHiveType.getTypeSignature()); Type toType = typeManager.getType(toHiveType.getTypeSignature()); if (toType instanceof VarcharType && (fromHiveType.equals(HIVE_BYTE) || fromHiveType.equals(HIVE_SHORT) || fromHiveType.equals(HIVE_INT) || fromHiveType.equals(HIVE_LONG))) { return new IntegerNumberToVarcharCoercer();
public static List<HiveColumnHandle> getPartitionKeyColumnHandles(String connectorId, Table table) { ImmutableList.Builder<HiveColumnHandle> columns = ImmutableList.builder(); List<FieldSchema> partitionKeys = table.getPartitionKeys(); for (FieldSchema field : partitionKeys) { HiveType hiveType = HiveType.valueOf(field.getType()); columns.add(new HiveColumnHandle(connectorId, field.getName(), hiveType, HiveType.valueOf(field.getType()).getTypeSignature(), -1, true)); } return columns.build(); }
private Type canonicalizeType(Type type) { HiveType hiveType = HiveType.toHiveType(typeTranslator, type); return TYPE_MANAGER.getType(hiveType.getTypeSignature()); }
private static List<HiveColumnHandle> getColumnHandles() { ImmutableList.Builder<HiveColumnHandle> handles = ImmutableList.builder(); List<LineItemColumn> columns = getTestColumns(); for (int i = 0; i < columns.size(); i++) { LineItemColumn column = columns.get(i); HiveType hiveType = getHiveType(column.getType()); handles.add(new HiveColumnHandle(column.getColumnName(), hiveType, hiveType.getTypeSignature(), i, REGULAR, Optional.empty())); } return handles.build(); }
private static List<HiveColumnHandle> getColumnHandles() { ImmutableList.Builder<HiveColumnHandle> handles = ImmutableList.builder(); List<LineItemColumn> columns = getTestColumns(); for (int i = 0; i < columns.size(); i++) { LineItemColumn column = columns.get(i); HiveType hiveType = getHiveType(column.getType()); handles.add(new HiveColumnHandle(CLIENT_ID, column.getColumnName(), hiveType, hiveType.getTypeSignature(), i, false)); } return handles.build(); }
protected List<HiveColumnHandle> getColumnHandles(List<TestColumn> testColumns) { List<HiveColumnHandle> columns = new ArrayList<>(); int nextHiveColumnIndex = 0; for (int i = 0; i < testColumns.size(); i++) { TestColumn testColumn = testColumns.get(i); int columnIndex = testColumn.isPartitionKey() ? -1 : nextHiveColumnIndex++; HiveType hiveType = HiveType.valueOf(testColumn.getObjectInspector().getTypeName()); columns.add(new HiveColumnHandle(testColumn.getName(), hiveType, hiveType.getTypeSignature(), columnIndex, testColumn.isPartitionKey() ? PARTITION_KEY : REGULAR, Optional.empty())); } return columns; }
protected List<HiveColumnHandle> getColumnHandles(List<TestColumn> testColumns) { List<HiveColumnHandle> columns = new ArrayList<>(); int nextHiveColumnIndex = 0; for (int i = 0; i < testColumns.size(); i++) { TestColumn testColumn = testColumns.get(i); int columnIndex = testColumn.isPartitionKey() ? -1 : nextHiveColumnIndex++; HiveType hiveType = HiveType.valueOf(testColumn.getObjectInspector().getTypeName()); columns.add(new HiveColumnHandle("client_id", testColumn.getName(), hiveType, hiveType.getTypeSignature(), columnIndex, testColumn.isPartitionKey())); } return columns; }