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:
parent
4aff7147b5
commit
effb075b62
2 changed files with 142 additions and 0 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue