Search in sources :

Example 1 with HiveBucketProperty

use of com.facebook.presto.hive.HiveBucketProperty in project presto by prestodb.

the class TestGlueToPrestoConverter method assertStorage.

private static void assertStorage(Storage actual, StorageDescriptor expected) {
    assertEquals(actual.getLocation(), expected.getLocation());
    assertEquals(actual.getStorageFormat().getSerDe(), expected.getSerdeInfo().getSerializationLibrary());
    assertEquals(actual.getStorageFormat().getInputFormat(), expected.getInputFormat());
    assertEquals(actual.getStorageFormat().getOutputFormat(), expected.getOutputFormat());
    if (!isNullOrEmpty(expected.getBucketColumns())) {
        HiveBucketProperty bucketProperty = actual.getBucketProperty().get();
        assertEquals(bucketProperty.getBucketedBy(), expected.getBucketColumns());
        assertEquals(bucketProperty.getBucketCount(), expected.getNumberOfBuckets().intValue());
    }
}
Also used : HiveBucketProperty(com.facebook.presto.hive.HiveBucketProperty)

Example 2 with HiveBucketProperty

use of com.facebook.presto.hive.HiveBucketProperty in project presto by prestodb.

the class GlueInputConverter method convertStorage.

private static StorageDescriptor convertStorage(Storage storage, List<Column> columns) {
    if (storage.isSkewed()) {
        throw new IllegalArgumentException("Writing to skewed table/partition is not supported");
    }
    SerDeInfo serdeInfo = new SerDeInfo().withSerializationLibrary(storage.getStorageFormat().getSerDeNullable()).withParameters(storage.getSerdeParameters());
    StorageDescriptor sd = new StorageDescriptor();
    sd.setLocation(storage.getLocation());
    sd.setColumns(columns.stream().map(GlueInputConverter::convertColumn).collect(toList()));
    sd.setSerdeInfo(serdeInfo);
    sd.setInputFormat(storage.getStorageFormat().getInputFormatNullable());
    sd.setOutputFormat(storage.getStorageFormat().getOutputFormatNullable());
    sd.setParameters(ImmutableMap.of());
    Optional<HiveBucketProperty> bucketProperty = storage.getBucketProperty();
    if (bucketProperty.isPresent()) {
        sd.setNumberOfBuckets(bucketProperty.get().getBucketCount());
        sd.setBucketColumns(bucketProperty.get().getBucketedBy());
        if (!bucketProperty.get().getSortedBy().isEmpty()) {
            sd.setSortColumns(bucketProperty.get().getSortedBy().stream().map(column -> new Order().withColumn(column.getColumnName()).withSortOrder(column.getOrder().getHiveOrder())).collect(toImmutableList()));
        }
    }
    return sd;
}
Also used : Order(com.amazonaws.services.glue.model.Order) HiveBucketProperty(com.facebook.presto.hive.HiveBucketProperty) SerDeInfo(com.amazonaws.services.glue.model.SerDeInfo) StorageDescriptor(com.amazonaws.services.glue.model.StorageDescriptor)

Example 3 with HiveBucketProperty

use of com.facebook.presto.hive.HiveBucketProperty in project presto by prestodb.

the class ThriftMetastoreUtil method makeStorageDescriptor.

private static StorageDescriptor makeStorageDescriptor(String tableName, List<Column> columns, Storage storage, ColumnConverter columnConverter) {
    if (storage.isSkewed()) {
        throw new IllegalArgumentException("Writing to skewed table/partition is not supported");
    }
    SerDeInfo serdeInfo = new SerDeInfo();
    serdeInfo.setName(tableName);
    serdeInfo.setSerializationLib(storage.getStorageFormat().getSerDeNullable());
    serdeInfo.setParameters(storage.getSerdeParameters());
    StorageDescriptor sd = new StorageDescriptor();
    sd.setLocation(emptyToNull(storage.getLocation()));
    sd.setCols(columns.stream().map(col -> ThriftMetastoreUtil.toMetastoreApiFieldSchema(col, columnConverter)).collect(toList()));
    sd.setSerdeInfo(serdeInfo);
    sd.setInputFormat(storage.getStorageFormat().getInputFormatNullable());
    sd.setOutputFormat(storage.getStorageFormat().getOutputFormatNullable());
    sd.setParameters(storage.getParameters());
    Optional<HiveBucketProperty> bucketProperty = storage.getBucketProperty();
    if (bucketProperty.isPresent()) {
        sd.setNumBuckets(bucketProperty.get().getBucketCount());
        sd.setBucketCols(bucketProperty.get().getBucketedBy());
        if (!bucketProperty.get().getSortedBy().isEmpty()) {
            sd.setSortCols(bucketProperty.get().getSortedBy().stream().map(column -> new Order(column.getColumnName(), column.getOrder().getHiveOrder())).collect(toList()));
        }
    }
    return sd;
}
Also used : Order(org.apache.hadoop.hive.metastore.api.Order) HiveBucketProperty(com.facebook.presto.hive.HiveBucketProperty) SerDeInfo(org.apache.hadoop.hive.metastore.api.SerDeInfo) StorageDescriptor(org.apache.hadoop.hive.metastore.api.StorageDescriptor)

Example 4 with HiveBucketProperty

use of com.facebook.presto.hive.HiveBucketProperty in project presto by prestodb.

the class MetastoreUtil method makeStorageDescriptor.

private static StorageDescriptor makeStorageDescriptor(String tableName, List<Column> columns, Storage storage) {
    if (storage.isSorted() || storage.isSkewed()) {
        throw new IllegalArgumentException("Writing to sorted and/or skewed table/partition is not supported");
    }
    SerDeInfo serdeInfo = new SerDeInfo();
    serdeInfo.setName(tableName);
    serdeInfo.setSerializationLib(storage.getStorageFormat().getSerDeNullable());
    serdeInfo.setParameters(storage.getSerdeParameters());
    StorageDescriptor sd = new StorageDescriptor();
    sd.setLocation(emptyToNull(storage.getLocation()));
    sd.setCols(columns.stream().map(MetastoreUtil::toMetastoreApiFieldSchema).collect(toList()));
    sd.setSerdeInfo(serdeInfo);
    sd.setInputFormat(storage.getStorageFormat().getInputFormatNullable());
    sd.setOutputFormat(storage.getStorageFormat().getOutputFormatNullable());
    sd.setParameters(ImmutableMap.of());
    Optional<HiveBucketProperty> bucketProperty = storage.getBucketProperty();
    if (bucketProperty.isPresent()) {
        sd.setNumBuckets(bucketProperty.get().getBucketCount());
        sd.setBucketCols(bucketProperty.get().getBucketedBy());
    }
    return sd;
}
Also used : HiveBucketProperty(com.facebook.presto.hive.HiveBucketProperty) SerDeInfo(org.apache.hadoop.hive.metastore.api.SerDeInfo) StorageDescriptor(org.apache.hadoop.hive.metastore.api.StorageDescriptor)

Example 5 with HiveBucketProperty

use of com.facebook.presto.hive.HiveBucketProperty in project presto by prestodb.

the class TestGlueInputConverter method assertStorage.

private static void assertStorage(StorageDescriptor actual, Storage expected) {
    assertEquals(actual.getLocation(), expected.getLocation());
    assertEquals(actual.getSerdeInfo().getSerializationLibrary(), expected.getStorageFormat().getSerDe());
    assertEquals(actual.getInputFormat(), expected.getStorageFormat().getInputFormat());
    assertEquals(actual.getOutputFormat(), expected.getStorageFormat().getOutputFormat());
    if (expected.getBucketProperty().isPresent()) {
        HiveBucketProperty bucketProperty = expected.getBucketProperty().get();
        assertEquals(actual.getBucketColumns(), bucketProperty.getBucketedBy());
        assertEquals(actual.getNumberOfBuckets().intValue(), bucketProperty.getBucketCount());
    }
}
Also used : HiveBucketProperty(com.facebook.presto.hive.HiveBucketProperty)

Aggregations

HiveBucketProperty (com.facebook.presto.hive.HiveBucketProperty)5 SerDeInfo (org.apache.hadoop.hive.metastore.api.SerDeInfo)2 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)2 Order (com.amazonaws.services.glue.model.Order)1 SerDeInfo (com.amazonaws.services.glue.model.SerDeInfo)1 StorageDescriptor (com.amazonaws.services.glue.model.StorageDescriptor)1 Order (org.apache.hadoop.hive.metastore.api.Order)1