use of com.amazonaws.services.glue.model.StorageDescriptor 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;
}
use of com.amazonaws.services.glue.model.StorageDescriptor in project presto by prestodb.
the class GlueToPrestoConverter method convertTable.
public static Table convertTable(com.amazonaws.services.glue.model.Table glueTable, String dbName) {
requireNonNull(glueTable.getStorageDescriptor(), "Table StorageDescriptor is null");
StorageDescriptor sd = glueTable.getStorageDescriptor();
Table.Builder tableBuilder = Table.builder().setDatabaseName(dbName).setTableName(glueTable.getName()).setOwner(nullToEmpty(glueTable.getOwner())).setTableType(PrestoTableType.optionalValueOf(glueTable.getTableType()).orElse(EXTERNAL_TABLE)).setDataColumns(convertColumns(sd.getColumns())).setParameters(convertParameters(glueTable.getParameters())).setViewOriginalText(Optional.ofNullable(glueTable.getViewOriginalText())).setViewExpandedText(Optional.ofNullable(glueTable.getViewExpandedText()));
if (glueTable.getPartitionKeys() != null) {
tableBuilder.setPartitionColumns(convertColumns(glueTable.getPartitionKeys()));
} else {
tableBuilder.setPartitionColumns(ImmutableList.of());
}
new StorageConverter().setConvertedStorage(sd, tableBuilder.getStorageBuilder());
return tableBuilder.build();
}
Aggregations