Search in sources :

Example 1 with InvalidProtocolBufferException

use of alluxio.shaded.client.com.google.protobuf.InvalidProtocolBufferException in project presto by prestodb.

the class AlluxioProtoUtils method fromProto.

public static Table fromProto(alluxio.grpc.table.TableInfo table) {
    if (!table.hasLayout()) {
        throw new UnsupportedOperationException("Unsupported table metadata. missing layout.");
    }
    Layout layout = table.getLayout();
    if (!alluxio.table.ProtoUtils.isHiveLayout(layout)) {
        throw new UnsupportedOperationException("Unsupported table layout: " + layout);
    }
    try {
        PartitionInfo partitionInfo = alluxio.table.ProtoUtils.toHiveLayout(layout);
        // compute the data columns
        Set<String> partitionColumns = table.getPartitionColsList().stream().map(FieldSchema::getName).collect(toImmutableSet());
        List<FieldSchema> dataColumns = table.getSchema().getColsList().stream().filter((field) -> !partitionColumns.contains(field.getName())).collect(toImmutableList());
        Table.Builder builder = Table.builder().setDatabaseName(table.getDbName()).setTableName(table.getTableName()).setOwner(table.getOwner()).setTableType(PrestoTableType.OTHER).setDataColumns(dataColumns.stream().map(AlluxioProtoUtils::fromProto).collect(toImmutableList())).setPartitionColumns(table.getPartitionColsList().stream().map(AlluxioProtoUtils::fromProto).collect(toImmutableList())).setParameters(table.getParametersMap()).setViewOriginalText(Optional.empty()).setViewExpandedText(Optional.empty());
        alluxio.grpc.table.layout.hive.Storage storage = partitionInfo.getStorage();
        // TODO: We should also set storage parameters here when they are available in alluxio.grpc.table.layout.hive.Storage
        builder.getStorageBuilder().setSkewed(storage.getSkewed()).setStorageFormat(fromProto(storage.getStorageFormat())).setLocation(storage.getLocation()).setBucketProperty(storage.hasBucketProperty() ? fromProto(storage.getBucketProperty()) : Optional.empty()).setSerdeParameters(storage.getStorageFormat().getSerdelibParametersMap());
        return builder.build();
    } catch (InvalidProtocolBufferException e) {
        throw new IllegalArgumentException("Failed to extract PartitionInfo from TableInfo", e);
    }
}
Also used : Date(alluxio.grpc.table.Date) HIVE_COMPATIBLE(com.facebook.presto.hive.BucketFunctionType.HIVE_COMPATIBLE) ThriftMetastoreUtil.fromMetastoreNullsCount(com.facebook.presto.hive.metastore.thrift.ThriftMetastoreUtil.fromMetastoreNullsCount) MetastoreUtil.fromMetastoreDistinctValuesCount(com.facebook.presto.hive.metastore.MetastoreUtil.fromMetastoreDistinctValuesCount) DoubleColumnStatsData(alluxio.grpc.table.DoubleColumnStatsData) HiveColumnStatistics.createDoubleColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics.createDoubleColumnStatistics) BigDecimal(java.math.BigDecimal) BigInteger(java.math.BigInteger) BinaryColumnStatsData(alluxio.grpc.table.BinaryColumnStatsData) StorageFormat(com.facebook.presto.hive.metastore.StorageFormat) HIVE_INVALID_METADATA(com.facebook.presto.hive.HiveErrorCode.HIVE_INVALID_METADATA) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Layout(alluxio.grpc.table.Layout) Set(java.util.Set) DecimalColumnStatsData(alluxio.grpc.table.DecimalColumnStatsData) PartitionInfo(alluxio.grpc.table.layout.hive.PartitionInfo) List(java.util.List) ROLE(com.facebook.presto.spi.security.PrincipalType.ROLE) PrestoTableType(com.facebook.presto.hive.metastore.PrestoTableType) LocalDate(java.time.LocalDate) HiveColumnStatistics.createBinaryColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics.createBinaryColumnStatistics) Optional(java.util.Optional) HiveColumnStatistics.createBooleanColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics.createBooleanColumnStatistics) Table(com.facebook.presto.hive.metastore.Table) HiveColumnStatistics.createIntegerColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics.createIntegerColumnStatistics) Column(com.facebook.presto.hive.metastore.Column) Database(com.facebook.presto.hive.metastore.Database) DateColumnStatsData(alluxio.grpc.table.DateColumnStatsData) HiveType(com.facebook.presto.hive.HiveType) OptionalDouble(java.util.OptionalDouble) LongColumnStatsData(alluxio.grpc.table.LongColumnStatsData) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) PrestoException(com.facebook.presto.spi.PrestoException) Partition(com.facebook.presto.hive.metastore.Partition) OptionalLong(java.util.OptionalLong) FieldSchema(alluxio.grpc.table.FieldSchema) Lists(com.google.common.collect.Lists) ThriftMetastoreUtil.getTotalSizeInBytes(com.facebook.presto.hive.metastore.thrift.ThriftMetastoreUtil.getTotalSizeInBytes) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) SortingColumn(com.facebook.presto.hive.metastore.SortingColumn) Nullable(javax.annotation.Nullable) ColumnStatisticsData(alluxio.grpc.table.ColumnStatisticsData) USER(com.facebook.presto.spi.security.PrincipalType.USER) InvalidProtocolBufferException(alluxio.shaded.client.com.google.protobuf.InvalidProtocolBufferException) HiveColumnStatistics.createStringColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics.createStringColumnStatistics) BooleanColumnStatsData(alluxio.grpc.table.BooleanColumnStatsData) Decimal(alluxio.grpc.table.Decimal) StringColumnStatsData(alluxio.grpc.table.StringColumnStatsData) HiveBucketProperty(com.facebook.presto.hive.HiveBucketProperty) HiveColumnStatistics.createDecimalColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics.createDecimalColumnStatistics) HiveColumnStatistics.createDateColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics.createDateColumnStatistics) Table(com.facebook.presto.hive.metastore.Table) FieldSchema(alluxio.grpc.table.FieldSchema) InvalidProtocolBufferException(alluxio.shaded.client.com.google.protobuf.InvalidProtocolBufferException) Layout(alluxio.grpc.table.Layout) PartitionInfo(alluxio.grpc.table.layout.hive.PartitionInfo)

Aggregations

BinaryColumnStatsData (alluxio.grpc.table.BinaryColumnStatsData)1 BooleanColumnStatsData (alluxio.grpc.table.BooleanColumnStatsData)1 ColumnStatisticsData (alluxio.grpc.table.ColumnStatisticsData)1 Date (alluxio.grpc.table.Date)1 DateColumnStatsData (alluxio.grpc.table.DateColumnStatsData)1 Decimal (alluxio.grpc.table.Decimal)1 DecimalColumnStatsData (alluxio.grpc.table.DecimalColumnStatsData)1 DoubleColumnStatsData (alluxio.grpc.table.DoubleColumnStatsData)1 FieldSchema (alluxio.grpc.table.FieldSchema)1 Layout (alluxio.grpc.table.Layout)1 LongColumnStatsData (alluxio.grpc.table.LongColumnStatsData)1 StringColumnStatsData (alluxio.grpc.table.StringColumnStatsData)1 PartitionInfo (alluxio.grpc.table.layout.hive.PartitionInfo)1 InvalidProtocolBufferException (alluxio.shaded.client.com.google.protobuf.InvalidProtocolBufferException)1 HIVE_COMPATIBLE (com.facebook.presto.hive.BucketFunctionType.HIVE_COMPATIBLE)1 HiveBucketProperty (com.facebook.presto.hive.HiveBucketProperty)1 HIVE_INVALID_METADATA (com.facebook.presto.hive.HiveErrorCode.HIVE_INVALID_METADATA)1 HiveType (com.facebook.presto.hive.HiveType)1 Column (com.facebook.presto.hive.metastore.Column)1 Database (com.facebook.presto.hive.metastore.Database)1