Add glue.batch_update_partition (#3534)

* Add glue.batch_update_partition

* Fix error output for glue.batch_update_partition and add test case for non-existent partition in the batch update
This commit is contained in:
Don Kuntz 2020-12-10 14:03:37 -06:00 committed by GitHub
commit effb075b62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 142 additions and 0 deletions

View file

@ -208,6 +208,35 @@ class GlueResponse(BaseResponse):
return ""
def batch_update_partition(self):
database_name = self.parameters.get("DatabaseName")
table_name = self.parameters.get("TableName")
table = self.glue_backend.get_table(database_name, table_name)
errors_output = []
for entry in self.parameters.get("Entries"):
part_to_update = entry["PartitionValueList"]
part_input = entry["PartitionInput"]
try:
table.update_partition(part_to_update, part_input)
except PartitionNotFoundException:
errors_output.append(
{
"PartitionValueList": part_to_update,
"ErrorDetail": {
"ErrorCode": "EntityNotFoundException",
"ErrorMessage": "Partition not found.",
},
}
)
out = {}
if errors_output:
out["Errors"] = errors_output
return json.dumps(out)
def delete_partition(self):
database_name = self.parameters.get("DatabaseName")
table_name = self.parameters.get("TableName")