-
Notifications
You must be signed in to change notification settings - Fork 116
Labels
type: featureA value-adding code addition that introduce new functionality.A value-adding code addition that introduce new functionality.
Description
A note for the community
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Use Cases
We often perform selective flattening for our payloads, meaning that we often need to exclude certain keys during the flattening operation. Currently this requires a somewhat verbose save/restore dance:
metadata = del(.metadata)
tags = del(.tags)
. = compact(flatten(., "_"))
.metadata = metadata
.tags = tagsThis is also useful for downstream consumers that do not necessarily want to flatten specific fields and instead want to store them within a JSON record/column.
Attempted Solutions
No response
Proposal
Add an optional except parameter to flatten that accepts an array of key names to exclude from flattening:
. = compact(flatten(., "_", except: ["metadata", "tags"]))Keys matching the except list would be preserved as-is while everything else is flattened normally.
References
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: featureA value-adding code addition that introduce new functionality.A value-adding code addition that introduce new functionality.