[Feature] Deterministic Field Order for Generate Surrogate Key Macro
sha2fiddy opened this issue · 2 comments
Is this your first time submitting a feature request?
- I have read the expectations for open source contributors
- I have searched the existing issues, and I could not find an existing issue for this feature
- I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion
Describe the feature
When using the dbt_utils.generate_surrogate_key
macro, the same set of fields passed in a different order will generate different keys. It would be nice if the field names were sorted in some deterministic way (IE alphabetically) before they were hashed, so that the order in which they are passed to the macro has no effect.
Perhaps this could be a configurable option, if there are reasons why this behavior would not be preferred in some situations.
Describe alternatives you've considered
Using a custom macro to sort the list of fields, then passed the sorted list to generate_surrogate_key
.
Who will this benefit?
This would be useful for any case where a Surrogate Key is being generated in multiple models, where the expectation is that the same set of fields will produce the same key, regardless of the order they are passed to the generate_surrogate_key
macro.
A common example of this is generating the same key in a FACT and DIM table, where consumers will be joining on this key.
Are you interested in contributing this feature?
No response
Anything else?
No response