mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(glue): let the Glue catalog client read back tables and partitions (#7329)
The Glue Data Catalog client, which Spark's Glue catalog and Hive's Glue metastore use on EMR, could not read back a table it had just created on Floci: "NullPointerException: Cannot invoke java.lang.Integer.intValue() because the return value of Table.retention() is null". Floci's Table had no Retention, and its StorageDescriptor no StoredAsSubDirectories, SortColumns, BucketColumns, SkewedInfo or AdditionalLocations, so what the client wrote was dropped, and the client unboxes Retention, Compressed, NumberOfBuckets, StoredAsSubDirectories and an Order's SortOrder without a null check. Past that, a partitioned table came back with each partition, and so each row, five times: the client reads a table's partitions in five GetPartitions segments by default, and Floci answered every segment with all of them. Now: - Table keeps Retention and IsRegisteredWithLakeFormation, and StorageDescriptor keeps AdditionalLocations, BucketColumns, SortColumns, SkewedInfo and StoredAsSubDirectories, and the table and descriptor copies carry them. - every table and partition a catalog action returns (GetTable, GetTables, SearchTables, GetTableVersion, GetTableVersions, GetPartition, GetPartitions, BatchGetPartition) reads Retention as 0, IsRegisteredWithLakeFormation as false, and a storage descriptor's Compressed, NumberOfBuckets, SortColumns and StoredAsSubDirectories as false, 0, an empty list and false when they were written without them, as the CLI reference's get-tables output shows Glue doing. The stored records keep their nulls: Spectrum reads a partition's missing Compressed as its table's. - GetPartitions honours Segment, "a non-overlapping region of a table's partitions": a partition is in the one segment its values hash to, a SegmentNumber past the last holds none, and TotalSegments outside 1 to 10, a negative SegmentNumber or a missing member is a ValidationException, and a member that is not an integer a SerializationException. - a SortColumns entry that is null, lacks Column or SortOrder, or has a SortOrder other than 0 or 1 fails the whole CreateTable, UpdateTable, CreatePartition, UpdatePartition, BatchCreatePartition or BatchUpdatePartition with a ValidationException before anything is stored, as the client unboxes SortOrder on read. - the EMR runner gives the client the job's account as its hive.metastore.glue.catalogid, on a cluster and in an EMR Serverless run. Given none, the client in emr-7.10.0 asks STS GetCallerIdentity for it through an STS client no setting points at Floci, so a step reached real AWS STS and failed. The job's own account is what an unset one means, and a cluster's spark-hive-site or a run's spark-defaults one, for a Data Catalog in another account, still wins. IsRegisteredWithLakeFormation is always false, as Floci does not tie a table to a location registered with Lake Formation.
This commit is contained in:
1 parent
0e9f3402f2
commit
cfd7e83776
11 files changed
+712
-14
No files matched your search
+3
-1
@@ -741,7 +741,8 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
|
||||
return escaped.toString();
|
||||
}
|
||||
|
||||
// Floci's Hadoop settings: S3A on Floci's S3, and the Glue Data Catalog client on Floci's Glue.
|
||||
// Floci's Hadoop settings: S3A on Floci's S3, and the Glue Data Catalog client on Floci's Glue, in the job's
|
||||
// account. Given none, the client from emr-7.10.0 asks STS for it, through a client no setting points at Floci.
|
||||
private static List<SparkSetting> hadoopSettings(Job job, String flociEndpoint) {
|
||||
return List.of(
|
||||
new SparkSetting("fs.s3a.endpoint", flociEndpoint),
|
||||
@@ -751,6 +752,7 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
|
||||
new SparkSetting("fs.s3.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem"),
|
||||
new SparkSetting("fs.AbstractFileSystem.s3.impl", "org.apache.hadoop.fs.s3a.S3A"),
|
||||
new SparkSetting("aws.glue.endpoint", flociEndpoint),
|
||||
new SparkSetting("hive.metastore.glue.catalogid", job.accountId()),
|
||||
new SparkSetting("aws.region", job.region()));
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class GlueJsonHandler {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
String tableName = request.get("Name").asText();
|
||||
Table table = glueService.getTable(dbName, tableName);
|
||||
yield Response.ok(Map.of("Table", table)).build();
|
||||
yield Response.ok(Map.of("Table", GlueService.withReadDefaults(table))).build();
|
||||
}
|
||||
case "CreatePartitionIndex" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
@@ -142,7 +142,8 @@ public class GlueJsonHandler {
|
||||
}
|
||||
case "GetTables" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
yield Response.ok(Map.of("TableList", glueService.getTables(dbName))).build();
|
||||
List<Table> tables = glueService.getTables(dbName).stream().map(GlueService::withReadDefaults).toList();
|
||||
yield Response.ok(Map.of("TableList", tables)).build();
|
||||
}
|
||||
case "UpdateTable" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
@@ -205,7 +206,10 @@ public class GlueJsonHandler {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
String tableName = request.get("TableName").asText();
|
||||
String expression = request.path("Expression").asText(null);
|
||||
yield Response.ok(Map.of("Partitions", glueService.getPartitions(dbName, tableName, expression))).build();
|
||||
GlueService.Segment segment = request.hasNonNull("Segment") ? segment(request.get("Segment")) : null;
|
||||
List<Partition> partitions = glueService.getPartitions(dbName, tableName, expression, segment).stream()
|
||||
.map(GlueService::withReadDefaults).toList();
|
||||
yield Response.ok(Map.of("Partitions", partitions)).build();
|
||||
}
|
||||
case "DeletePartition" -> handleDeletePartition(request);
|
||||
case "BatchDeletePartition" -> handleBatchDeletePartition(request);
|
||||
@@ -701,13 +705,37 @@ public class GlueJsonHandler {
|
||||
return Response.ok(Map.of("Errors", glueService.batchUpdatePartitions(dbName, tableName, entries))).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* A Segment that is not a structure of integers is a malformed request, refused with SerializationException
|
||||
* before its constraints are checked, as the awsJson1_1 protocol refuses a member of the wrong type; the
|
||||
* message is Floci's.
|
||||
*/
|
||||
private static GlueService.Segment segment(JsonNode segment) {
|
||||
if (!segment.isObject()) {
|
||||
throw new AwsException("SerializationException", "Segment must be a structure", 400);
|
||||
}
|
||||
return new GlueService.Segment(
|
||||
integerMember(segment, "SegmentNumber"), integerMember(segment, "TotalSegments"));
|
||||
}
|
||||
|
||||
private static Integer integerMember(JsonNode segment, String member) {
|
||||
JsonNode value = segment.get(member);
|
||||
if (value == null || value.isNull()) {
|
||||
return null;
|
||||
}
|
||||
if (!value.isIntegralNumber() || !value.canConvertToInt()) {
|
||||
throw new AwsException("SerializationException", "Segment." + member + " must be an integer", 400);
|
||||
}
|
||||
return value.intValue();
|
||||
}
|
||||
|
||||
private Response handleGetPartition(JsonNode request) {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
String tableName = request.get("TableName").asText();
|
||||
List<String> partitionValues = mapper.convertValue(request.get("PartitionValues"), STRING_LIST);
|
||||
return Response.ok(Map.of(
|
||||
"Partition",
|
||||
glueService.getPartition(dbName, tableName, partitionValues)))
|
||||
GlueService.withReadDefaults(glueService.getPartition(dbName, tableName, partitionValues))))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -718,8 +746,10 @@ public class GlueJsonHandler {
|
||||
List<List<String>> partitionValues = partitionsToGet.stream()
|
||||
.map(partition -> mapper.convertValue(partition.get("Values"), STRING_LIST))
|
||||
.toList();
|
||||
List<Partition> partitions = glueService.batchGetPartitions(dbName, tableName, partitionValues).stream()
|
||||
.map(GlueService::withReadDefaults).toList();
|
||||
return Response.ok(Map.of(
|
||||
"Partitions", glueService.batchGetPartitions(dbName, tableName, partitionValues),
|
||||
"Partitions", partitions,
|
||||
"UnprocessedKeys", List.of()))
|
||||
.build();
|
||||
}
|
||||
@@ -746,7 +776,8 @@ public class GlueJsonHandler {
|
||||
GlueService.Page<Table> page = glueService.searchTables(
|
||||
request.path("SearchText").asText(null), filters, sortCriteria,
|
||||
readMaxResults(request), readNextToken(request));
|
||||
return Response.ok(pageResponse("TableList", page.items(), page.nextToken())).build();
|
||||
List<Table> tables = page.items().stream().map(GlueService::withReadDefaults).toList();
|
||||
return Response.ok(pageResponse("TableList", tables, page.nextToken())).build();
|
||||
}
|
||||
|
||||
private Response handleDeletePartition(JsonNode request) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Base64Url;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.glue.model.Classifier;
|
||||
@@ -433,6 +434,7 @@ public class GlueService {
|
||||
}
|
||||
|
||||
public void createTable(String databaseName, Table table) {
|
||||
requireValidSortColumns(sortColumnViolations("tableInput", table.getStorageDescriptor()));
|
||||
Database database = getDatabase(databaseName);
|
||||
String key = tableKey(databaseName, table.getName());
|
||||
if (tableStore.get(key).isPresent()) {
|
||||
@@ -658,6 +660,7 @@ public class GlueService {
|
||||
}
|
||||
|
||||
public synchronized void updateTable(String databaseName, Table table, String versionId, boolean skipArchive) {
|
||||
requireValidSortColumns(sortColumnViolations("tableInput", table.getStorageDescriptor()));
|
||||
Database database = getDatabase(databaseName);
|
||||
String key = tableKey(databaseName, table.getName());
|
||||
Table existing = tableStore.get(key)
|
||||
@@ -691,7 +694,7 @@ public class GlueService {
|
||||
.toList());
|
||||
return versions.stream()
|
||||
.map(table -> Map.<String, Object>of(
|
||||
"Table", withResolvedSchemaReference(table),
|
||||
"Table", withReadDefaults(withResolvedSchemaReference(table)),
|
||||
"VersionId", table.getVersionId()))
|
||||
.toList();
|
||||
}
|
||||
@@ -708,7 +711,7 @@ public class GlueService {
|
||||
.map(this::withResolvedSchemaReference)
|
||||
.orElseThrow(() -> new AwsException("EntityNotFoundException", "Version not found.", 400));
|
||||
}
|
||||
return Map.of("Table", version, "VersionId", version.getVersionId());
|
||||
return Map.of("Table", withReadDefaults(version), "VersionId", version.getVersionId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,6 +847,7 @@ public class GlueService {
|
||||
}
|
||||
|
||||
public void createPartition(String databaseName, String tableName, Partition partition) {
|
||||
requireValidSortColumns(sortColumnViolations("partitionInput", partition.getStorageDescriptor()));
|
||||
Table table = getTable(databaseName, tableName);
|
||||
String key = partitionKey(databaseName, tableName, partition.getValues());
|
||||
partition.setDatabaseName(table.getDatabaseName());
|
||||
@@ -858,6 +862,12 @@ public class GlueService {
|
||||
String databaseName,
|
||||
String tableName,
|
||||
List<Partition> partitions) {
|
||||
List<String> violations = new ArrayList<>();
|
||||
for (int index = 0; index < partitions.size(); index++) {
|
||||
violations.addAll(sortColumnViolations("partitionInputList." + (index + 1) + ".member",
|
||||
descriptorOf(partitions.get(index))));
|
||||
}
|
||||
requireValidSortColumns(violations);
|
||||
getTable(databaseName, tableName);
|
||||
List<BatchCreatePartitionError> errors = new ArrayList<>();
|
||||
for (Partition partition : partitions) {
|
||||
@@ -896,6 +906,13 @@ public class GlueService {
|
||||
String databaseName,
|
||||
String tableName,
|
||||
List<BatchUpdatePartitionEntry> entries) {
|
||||
List<String> violations = new ArrayList<>();
|
||||
for (int index = 0; index < entries.size(); index++) {
|
||||
BatchUpdatePartitionEntry entry = entries.get(index);
|
||||
violations.addAll(sortColumnViolations("entries." + (index + 1) + ".member.partitionInput",
|
||||
entry == null ? null : descriptorOf(entry.partitionInput())));
|
||||
}
|
||||
requireValidSortColumns(violations);
|
||||
Table table = getTable(databaseName, tableName);
|
||||
List<BatchUpdatePartitionError> errors = new ArrayList<>();
|
||||
for (BatchUpdatePartitionEntry entry : entries) {
|
||||
@@ -916,14 +933,57 @@ public class GlueService {
|
||||
}
|
||||
|
||||
public List<Partition> getPartitions(String databaseName, String tableName, String expression) {
|
||||
return getPartitions(databaseName, tableName, expression, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* A segment is "a non-overlapping region of a table's partitions, allowing multiple requests to be run in
|
||||
* parallel", so each partition falls in the one segment its values hash to, which stays the same while other
|
||||
* partitions come and go between those requests, and a SegmentNumber past the last segment holds none. The
|
||||
* Glue Data Catalog client for Hive and Spark asks for five.
|
||||
*/
|
||||
public List<Partition> getPartitions(String databaseName, String tableName, String expression, Segment segment) {
|
||||
validateSegment(segment);
|
||||
Table table = getTable(databaseName, tableName);
|
||||
String prefix = tableKey(databaseName, tableName) + ":";
|
||||
return partitionStore.scan(k -> k.startsWith(prefix)).stream()
|
||||
.filter(partition -> segment == null || Math.floorMod(Objects.hashCode(partition.getValues()),
|
||||
segment.totalSegments()) == segment.segmentNumber())
|
||||
.filter(partition -> matchesPartitionExpression(table, partition, expression))
|
||||
.sorted(GlueService::comparePartitionValues)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static void validateSegment(Segment segment) {
|
||||
if (segment == null) {
|
||||
return;
|
||||
}
|
||||
List<String> violations = new ArrayList<>();
|
||||
if (segment.segmentNumber() == null) {
|
||||
violations.add(SmithyValidationErrors.notNull("segment.segmentNumber"));
|
||||
} else if (segment.segmentNumber() < 0) {
|
||||
violations.add(SmithyValidationErrors.valueTooSmall(
|
||||
"segment.segmentNumber", segment.segmentNumber().toString(), 0));
|
||||
}
|
||||
if (segment.totalSegments() == null) {
|
||||
violations.add(SmithyValidationErrors.notNull("segment.totalSegments"));
|
||||
} else {
|
||||
String violation = SmithyValidationErrors.outOfRange(
|
||||
"segment.totalSegments", segment.totalSegments(), 1, 10);
|
||||
if (violation != null) {
|
||||
violations.add(violation);
|
||||
}
|
||||
}
|
||||
if (!violations.isEmpty()) {
|
||||
throw SmithyValidationErrors.validationException(violations);
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public record Segment(
|
||||
@JsonProperty("SegmentNumber") Integer segmentNumber,
|
||||
@JsonProperty("TotalSegments") Integer totalSegments) {}
|
||||
|
||||
/**
|
||||
* Registers a partition index on a table.
|
||||
*
|
||||
@@ -1121,6 +1181,7 @@ public class GlueService {
|
||||
}
|
||||
|
||||
public void updatePartition(String databaseName, String tableName, List<String> partitionValues, Partition partition) {
|
||||
requireValidSortColumns(sortColumnViolations("partitionInput", partition.getStorageDescriptor()));
|
||||
Table table = getTable(databaseName, tableName);
|
||||
String key = partitionKey(databaseName, tableName, partitionValues);
|
||||
Partition existing = partitionStore.get(key)
|
||||
@@ -1674,6 +1735,7 @@ public class GlueService {
|
||||
copy.setCreateTime(source.getCreateTime());
|
||||
copy.setUpdateTime(source.getUpdateTime());
|
||||
copy.setLastAccessTime(source.getLastAccessTime());
|
||||
copy.setRetention(source.getRetention());
|
||||
copy.setPartitionKeys(copyColumns(source.getPartitionKeys()));
|
||||
copy.setStorageDescriptor(copyStorageDescriptor(source.getStorageDescriptor()));
|
||||
copy.setTableType(source.getTableType());
|
||||
@@ -1684,6 +1746,98 @@ public class GlueService {
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Glue reads back a table's Retention, and a storage descriptor's Compressed, NumberOfBuckets, SortColumns
|
||||
* and StoredAsSubDirectories, as 0, false, 0, an empty list and false when the writer left them out, and the
|
||||
* Glue Data Catalog client for Hive and Spark unboxes them without a null check, as it does
|
||||
* IsRegisteredWithLakeFormation, which is false: Floci ties no table to a location registered with Lake
|
||||
* Formation. So every table and partition a catalog action returns carries them, while the stored record keeps
|
||||
* its nulls, which Spectrum reads as a partition taking its table's value.
|
||||
*/
|
||||
static Table withReadDefaults(Table table) {
|
||||
Table copy = copyTable(table);
|
||||
if (copy.getRetention() == null) {
|
||||
copy.setRetention(0);
|
||||
}
|
||||
copy.setRegisteredWithLakeFormation(false);
|
||||
fillReadDefaults(copy.getStorageDescriptor());
|
||||
return copy;
|
||||
}
|
||||
|
||||
static Partition withReadDefaults(Partition partition) {
|
||||
Partition copy = new Partition();
|
||||
copy.setValues(copyStrings(partition.getValues()));
|
||||
copy.setDatabaseName(partition.getDatabaseName());
|
||||
copy.setTableName(partition.getTableName());
|
||||
copy.setCreationTime(partition.getCreationTime());
|
||||
copy.setLastAccessTime(partition.getLastAccessTime());
|
||||
copy.setStorageDescriptor(copyStorageDescriptor(partition.getStorageDescriptor()));
|
||||
copy.setParameters(copyMap(partition.getParameters()));
|
||||
fillReadDefaults(copy.getStorageDescriptor());
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* An Order's Column and SortOrder are required, and SortOrder is 0 or 1 (the model's IntegerFlag); the Glue Data
|
||||
* Catalog client unboxes SortOrder on read. So a sort column breaking them fails the whole request, a batch's
|
||||
* included, before anything is stored.
|
||||
*/
|
||||
private static List<String> sortColumnViolations(String path, StorageDescriptor descriptor) {
|
||||
List<String> violations = new ArrayList<>();
|
||||
if (descriptor == null || descriptor.getSortColumns() == null) {
|
||||
return violations;
|
||||
}
|
||||
List<StorageDescriptor.Order> orders = descriptor.getSortColumns();
|
||||
for (int index = 0; index < orders.size(); index++) {
|
||||
String member = path + ".storageDescriptor.sortColumns." + (index + 1) + ".member";
|
||||
StorageDescriptor.Order order = orders.get(index);
|
||||
if (order == null) {
|
||||
violations.add(SmithyValidationErrors.notNull(member));
|
||||
continue;
|
||||
}
|
||||
if (order.getColumn() == null) {
|
||||
violations.add(SmithyValidationErrors.notNull(member + ".column"));
|
||||
}
|
||||
if (order.getSortOrder() == null) {
|
||||
violations.add(SmithyValidationErrors.notNull(member + ".sortOrder"));
|
||||
} else {
|
||||
String violation = SmithyValidationErrors.outOfRange(member + ".sortOrder", order.getSortOrder(), 0, 1);
|
||||
if (violation != null) {
|
||||
violations.add(violation);
|
||||
}
|
||||
}
|
||||
}
|
||||
return violations;
|
||||
}
|
||||
|
||||
private static StorageDescriptor descriptorOf(Partition partition) {
|
||||
return partition == null ? null : partition.getStorageDescriptor();
|
||||
}
|
||||
|
||||
private static void requireValidSortColumns(List<String> violations) {
|
||||
if (!violations.isEmpty()) {
|
||||
throw SmithyValidationErrors.validationException(violations);
|
||||
}
|
||||
}
|
||||
|
||||
private static void fillReadDefaults(StorageDescriptor descriptor) {
|
||||
if (descriptor == null) {
|
||||
return;
|
||||
}
|
||||
if (descriptor.getCompressed() == null) {
|
||||
descriptor.setCompressed(false);
|
||||
}
|
||||
if (descriptor.getNumberOfBuckets() == null) {
|
||||
descriptor.setNumberOfBuckets(0);
|
||||
}
|
||||
if (descriptor.getSortColumns() == null) {
|
||||
descriptor.setSortColumns(new ArrayList<>());
|
||||
}
|
||||
if (descriptor.getStoredAsSubDirectories() == null) {
|
||||
descriptor.setStoredAsSubDirectories(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static String nextVersionId(String versionId) {
|
||||
if (versionId == null) {
|
||||
return "1";
|
||||
@@ -1707,16 +1861,46 @@ public class GlueService {
|
||||
StorageDescriptor copy = new StorageDescriptor();
|
||||
copy.setColumns(copyColumns(source.getColumns()));
|
||||
copy.setLocation(source.getLocation());
|
||||
copy.setAdditionalLocations(copyStrings(source.getAdditionalLocations()));
|
||||
copy.setInputFormat(source.getInputFormat());
|
||||
copy.setOutputFormat(source.getOutputFormat());
|
||||
copy.setCompressed(source.getCompressed());
|
||||
copy.setNumberOfBuckets(source.getNumberOfBuckets());
|
||||
copy.setSerdeInfo(copySerDeInfo(source.getSerdeInfo()));
|
||||
copy.setBucketColumns(copyStrings(source.getBucketColumns()));
|
||||
copy.setSortColumns(copySortColumns(source.getSortColumns()));
|
||||
copy.setParameters(copyMap(source.getParameters()));
|
||||
copy.setSkewedInfo(copySkewedInfo(source.getSkewedInfo()));
|
||||
copy.setStoredAsSubDirectories(source.getStoredAsSubDirectories());
|
||||
copy.setSchemaReference(copySchemaReference(source.getSchemaReference()));
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static List<StorageDescriptor.Order> copySortColumns(List<StorageDescriptor.Order> source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
List<StorageDescriptor.Order> copy = new ArrayList<>(source.size());
|
||||
for (StorageDescriptor.Order order : source) {
|
||||
StorageDescriptor.Order orderCopy = new StorageDescriptor.Order();
|
||||
orderCopy.setColumn(order.getColumn());
|
||||
orderCopy.setSortOrder(order.getSortOrder());
|
||||
copy.add(orderCopy);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static StorageDescriptor.SkewedInfo copySkewedInfo(StorageDescriptor.SkewedInfo source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
StorageDescriptor.SkewedInfo copy = new StorageDescriptor.SkewedInfo();
|
||||
copy.setSkewedColumnNames(copyStrings(source.getSkewedColumnNames()));
|
||||
copy.setSkewedColumnValues(copyStrings(source.getSkewedColumnValues()));
|
||||
copy.setSkewedColumnValueLocationMaps(copyMap(source.getSkewedColumnValueLocationMaps()));
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static StorageDescriptor.SerDeInfo copySerDeInfo(StorageDescriptor.SerDeInfo source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
@@ -1763,6 +1947,10 @@ public class GlueService {
|
||||
return source != null ? new LinkedHashMap<>(source) : null;
|
||||
}
|
||||
|
||||
private static List<String> copyStrings(List<String> source) {
|
||||
return source != null ? new ArrayList<>(source) : null;
|
||||
}
|
||||
|
||||
private void validateRequired(String value, String fieldName) {
|
||||
if (value == null || value.isBlank()) {
|
||||
throw new AwsException("InvalidInputException", fieldName + " is required.", 400);
|
||||
|
||||
@@ -12,6 +12,8 @@ public class StorageDescriptor {
|
||||
private List<Column> columns;
|
||||
@JsonProperty("Location")
|
||||
private String location;
|
||||
@JsonProperty("AdditionalLocations")
|
||||
private List<String> additionalLocations;
|
||||
@JsonProperty("InputFormat")
|
||||
private String inputFormat;
|
||||
@JsonProperty("OutputFormat")
|
||||
@@ -22,8 +24,16 @@ public class StorageDescriptor {
|
||||
private Integer numberOfBuckets;
|
||||
@JsonProperty("SerdeInfo")
|
||||
private SerDeInfo serdeInfo;
|
||||
@JsonProperty("BucketColumns")
|
||||
private List<String> bucketColumns;
|
||||
@JsonProperty("SortColumns")
|
||||
private List<Order> sortColumns;
|
||||
@JsonProperty("Parameters")
|
||||
private Map<String, String> parameters;
|
||||
@JsonProperty("SkewedInfo")
|
||||
private SkewedInfo skewedInfo;
|
||||
@JsonProperty("StoredAsSubDirectories")
|
||||
private Boolean storedAsSubDirectories;
|
||||
@JsonProperty("SchemaReference")
|
||||
private SchemaReference schemaReference;
|
||||
|
||||
@@ -33,6 +43,10 @@ public class StorageDescriptor {
|
||||
public void setColumns(List<Column> columns) { this.columns = columns; }
|
||||
public String getLocation() { return location; }
|
||||
public void setLocation(String location) { this.location = location; }
|
||||
public List<String> getAdditionalLocations() { return additionalLocations; }
|
||||
public void setAdditionalLocations(List<String> additionalLocations) {
|
||||
this.additionalLocations = additionalLocations;
|
||||
}
|
||||
public String getInputFormat() { return inputFormat; }
|
||||
public void setInputFormat(String inputFormat) { this.inputFormat = inputFormat; }
|
||||
public String getOutputFormat() { return outputFormat; }
|
||||
@@ -43,8 +57,18 @@ public class StorageDescriptor {
|
||||
public void setNumberOfBuckets(Integer numberOfBuckets) { this.numberOfBuckets = numberOfBuckets; }
|
||||
public SerDeInfo getSerdeInfo() { return serdeInfo; }
|
||||
public void setSerdeInfo(SerDeInfo serdeInfo) { this.serdeInfo = serdeInfo; }
|
||||
public List<String> getBucketColumns() { return bucketColumns; }
|
||||
public void setBucketColumns(List<String> bucketColumns) { this.bucketColumns = bucketColumns; }
|
||||
public List<Order> getSortColumns() { return sortColumns; }
|
||||
public void setSortColumns(List<Order> sortColumns) { this.sortColumns = sortColumns; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
public SkewedInfo getSkewedInfo() { return skewedInfo; }
|
||||
public void setSkewedInfo(SkewedInfo skewedInfo) { this.skewedInfo = skewedInfo; }
|
||||
public Boolean getStoredAsSubDirectories() { return storedAsSubDirectories; }
|
||||
public void setStoredAsSubDirectories(Boolean storedAsSubDirectories) {
|
||||
this.storedAsSubDirectories = storedAsSubDirectories;
|
||||
}
|
||||
public SchemaReference getSchemaReference() { return schemaReference; }
|
||||
public void setSchemaReference(SchemaReference schemaReference) { this.schemaReference = schemaReference; }
|
||||
|
||||
@@ -64,4 +88,38 @@ public class StorageDescriptor {
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public static class Order {
|
||||
@JsonProperty("Column")
|
||||
private String column;
|
||||
@JsonProperty("SortOrder")
|
||||
private Integer sortOrder;
|
||||
|
||||
public String getColumn() { return column; }
|
||||
public void setColumn(String column) { this.column = column; }
|
||||
public Integer getSortOrder() { return sortOrder; }
|
||||
public void setSortOrder(Integer sortOrder) { this.sortOrder = sortOrder; }
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public static class SkewedInfo {
|
||||
@JsonProperty("SkewedColumnNames")
|
||||
private List<String> skewedColumnNames;
|
||||
@JsonProperty("SkewedColumnValues")
|
||||
private List<String> skewedColumnValues;
|
||||
@JsonProperty("SkewedColumnValueLocationMaps")
|
||||
private Map<String, String> skewedColumnValueLocationMaps;
|
||||
|
||||
public List<String> getSkewedColumnNames() { return skewedColumnNames; }
|
||||
public void setSkewedColumnNames(List<String> skewedColumnNames) { this.skewedColumnNames = skewedColumnNames; }
|
||||
public List<String> getSkewedColumnValues() { return skewedColumnValues; }
|
||||
public void setSkewedColumnValues(List<String> skewedColumnValues) {
|
||||
this.skewedColumnValues = skewedColumnValues;
|
||||
}
|
||||
public Map<String, String> getSkewedColumnValueLocationMaps() { return skewedColumnValueLocationMaps; }
|
||||
public void setSkewedColumnValueLocationMaps(Map<String, String> skewedColumnValueLocationMaps) {
|
||||
this.skewedColumnValueLocationMaps = skewedColumnValueLocationMaps;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,8 @@ public class Table {
|
||||
@JsonProperty("LastAccessTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant lastAccessTime;
|
||||
@JsonProperty("Retention")
|
||||
private Integer retention;
|
||||
@JsonProperty("PartitionKeys")
|
||||
private List<Column> partitionKeys;
|
||||
@JsonProperty("StorageDescriptor")
|
||||
@@ -41,6 +43,8 @@ public class Table {
|
||||
private String versionId;
|
||||
@JsonProperty("Parameters")
|
||||
private Map<String, String> parameters;
|
||||
@JsonProperty("IsRegisteredWithLakeFormation")
|
||||
private Boolean registeredWithLakeFormation;
|
||||
|
||||
public Table() {}
|
||||
|
||||
@@ -58,6 +62,8 @@ public class Table {
|
||||
public void setUpdateTime(Instant updateTime) { this.updateTime = updateTime; }
|
||||
public Instant getLastAccessTime() { return lastAccessTime; }
|
||||
public void setLastAccessTime(Instant lastAccessTime) { this.lastAccessTime = lastAccessTime; }
|
||||
public Integer getRetention() { return retention; }
|
||||
public void setRetention(Integer retention) { this.retention = retention; }
|
||||
public List<Column> getPartitionKeys() { return partitionKeys; }
|
||||
public void setPartitionKeys(List<Column> partitionKeys) { this.partitionKeys = partitionKeys; }
|
||||
public StorageDescriptor getStorageDescriptor() { return storageDescriptor; }
|
||||
@@ -72,4 +78,8 @@ public class Table {
|
||||
public void setVersionId(String versionId) { this.versionId = versionId; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
public Boolean getRegisteredWithLakeFormation() { return registeredWithLakeFormation; }
|
||||
public void setRegisteredWithLakeFormation(Boolean registeredWithLakeFormation) {
|
||||
this.registeredWithLakeFormation = registeredWithLakeFormation;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user