diff --git a/CHANGELOG.md b/CHANGELOG.md index 22957077..6104c99a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## v0.65 + +- [#393](https://github.com/awslabs/amazon-s3-find-and-forget/issues/393): Fix + for a bug affecting Create Data Mapper API with manually created Glue Tables + that don't contain SerdeInfo Parameters metadata + ## v0.64 - [#390](https://github.com/awslabs/amazon-s3-find-and-forget/issues/390): diff --git a/backend/lambdas/data_mappers/handlers.py b/backend/lambdas/data_mappers/handlers.py index dab5307e..f469714b 100644 --- a/backend/lambdas/data_mappers/handlers.py +++ b/backend/lambdas/data_mappers/handlers.py @@ -166,9 +166,10 @@ def get_glue_table_location(t): def get_glue_table_format(t): + serde_info = t["Table"].get("StorageDescriptor", {}).get("SerdeInfo", {}) return ( - t["Table"]["StorageDescriptor"]["SerdeInfo"]["SerializationLibrary"], - t["Table"]["StorageDescriptor"]["SerdeInfo"]["Parameters"], + serde_info.get("SerializationLibrary", ""), + serde_info.get("Parameters", {}), ) diff --git a/templates/template.yaml b/templates/template.yaml index d30cba73..94e717b3 100644 --- a/templates/template.yaml +++ b/templates/template.yaml @@ -1,6 +1,6 @@ AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 -Description: Amazon S3 Find and Forget (uksb-1q2j8beb0) (version:v0.64) (tag:main) +Description: Amazon S3 Find and Forget (uksb-1q2j8beb0) (version:v0.65) (tag:main) Parameters: AccessControlAllowOriginOverride: @@ -206,7 +206,7 @@ Conditions: Mappings: Solution: Constants: - Version: 'v0.64' + Version: 'v0.65' Resources: TempBucket: diff --git a/tests/unit/data_mappers/test_data_mappers.py b/tests/unit/data_mappers/test_data_mappers.py index d187ae1e..ecf3248d 100644 --- a/tests/unit/data_mappers/test_data_mappers.py +++ b/tests/unit/data_mappers/test_data_mappers.py @@ -559,6 +559,20 @@ def test_it_gets_glue_table_format_info(): ) == handlers.get_glue_table_format(get_table_stub()) +def test_it_gets_glue_table_parametersless(): + table = { + "Table": { + "StorageDescriptor": { + "Location": "s3://bucket/", + "InputFormat": "org.apache.hadoop.mapred.TextInputFormat", + "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", + } + } + } + + assert ("", {}) == handlers.get_glue_table_format(table) + + @patch("backend.lambdas.data_mappers.handlers.glue_client") def test_it_gets_details_for_table(mock_client): mock_client.get_table.return_value = get_table_stub()