Skip to content

Conversation

sthulb
Copy link
Contributor

@sthulb sthulb commented May 24, 2024

Issue number: #4219

Summary

Changes

Please provide a summary of what's being changed

This change adds deserialisation to DynamoDBStreamChangedRecordModel, allowing for rapid access to:

  • Keys
  • OldImage
  • NewImage

It also adds properties for existing fields.

User experience

Please share what the user experience looks like before and after this change

Before

change = DynamoDBStreamChangedRecordModel(
    ApproximateCreationDateTime=None, 
    Keys={'Timestamp': {'S': 'foo'}}, 
    NewImage=None, 
    OldImage=None, 
    SequenceNumber='123', 
    SizeBytes=112, 
    StreamViewType='NEW_IMAGE'
)

change.Keys['Timestamp']['S'] # returns 'foo'
change.SequenceNumber # returns '123'
...

After

change = DynamoDBStreamChangedRecordModel(
    ApproximateCreationDateTime=None, 
    Keys={'Timestamp': {'S': 'foo'}}, 
    NewImage=None, 
    OldImage=None, 
    SequenceNumber='123', 
    SizeBytes=112, 
    StreamViewType='NEW_IMAGE'
)

change.keys.get('Timestamp') # returns 'foo'
change.sequence_number # returns '123'
...

This change also relocates the DDB deserialiser work introduced in #1619 to it's own file located in aws_lambda_powertools.shared.dynamodb_deseraiizer

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

This is a breaking change.

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@sthulb sthulb requested a review from a team May 24, 2024 17:37
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 24, 2024
@github-actions github-actions bot added the feature New feature or functionality label May 24, 2024
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sthulb! This PR will introduce a great developer experience in Powertools V3, that's super cool!!

Before I review, can you pls add some tests?

@boring-cyborg boring-cyborg bot added the tests label May 27, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@leandrodamascena leandrodamascena self-requested a review May 28, 2024 17:39
@leandrodamascena leandrodamascena changed the title feat(parser): Adds DDB deserialisation to DynamoDBStreamChangedRecordModel feat(parser): Adds DDB deserialization to DynamoDBStreamChangedRecordModel May 28, 2024
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work @sthulb! Approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commons feature New feature or functionality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Unmarshal DynamoDB fields when using DynamoDBStreamModel in the parser utility
2 participants