Skip to content

Commit

Permalink
Parametersless metadata bugfix (#393)
Browse files Browse the repository at this point in the history
* Parametersless metadata bugfix

* Update changelog

* More validation
  • Loading branch information
matteofigus committed Jan 23, 2024
1 parent 843f32b commit 2d7fd40
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
5 changes: 3 additions & 2 deletions backend/lambdas/data_mappers/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {}),
)


Expand Down
4 changes: 2 additions & 2 deletions templates/template.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -206,7 +206,7 @@ Conditions:
Mappings:
Solution:
Constants:
Version: 'v0.64'
Version: 'v0.65'

Resources:
TempBucket:
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/data_mappers/test_data_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2d7fd40

Please sign in to comment.