Add batch_create_partition endpoint to Glue client (#2232)

* Add batch_create_partition endpoint to Glue client

* Remove exception as e from glue batch_create_partition, because it's unused
This commit is contained in:
Don Kuntz 2019-06-07 03:28:10 -05:00 committed by Terry Cain
commit 3833449b36
2 changed files with 89 additions and 0 deletions

View file

@ -4,6 +4,9 @@ import json
from moto.core.responses import BaseResponse
from .models import glue_backend
from .exceptions import (
PartitionAlreadyExistsException
)
class GlueResponse(BaseResponse):
@ -124,6 +127,26 @@ class GlueResponse(BaseResponse):
return ""
def batch_create_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 part_input in self.parameters.get('PartitionInputList'):
try:
table.create_partition(part_input)
except PartitionAlreadyExistsException:
errors_output.append({
'PartitionValues': part_input['Values'],
'ErrorDetail': {
'ErrorCode': 'AlreadyExistsException',
'ErrorMessage': 'Partition already exists.'
}
})
return json.dumps({"Errors": errors_output})
def update_partition(self):
database_name = self.parameters.get('DatabaseName')
table_name = self.parameters.get('TableName')