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:
parent
97ab7fd307
commit
3833449b36
2 changed files with 89 additions and 0 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue