Add an optional name field for the Postgres adapter indexes configurations #8999
+71
−41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves dbt-labs/dbt-postgres#52
Problem
Currently Postgres Adapter does not accept a
name
field in the model indexes configurations. This might be unnecessary for some of the users. But for readability and maintenance, a meaningful index name can be helpful. As I understood from the previous threads this is mainly due to the need of unique names of indices within a transaction. I did not test or understood fully what is breaking. However, I wanted to follow the following threads and keep the original idea of uniqueness. So developed a solution bearing this in mind.Solution
Adding an optional
name
field in the Postgres Index Config. If thename
is not provided the index name will be an MD5 hash of the index config contents as it was previously. If thename
is provided then the Unix Time of the index creation will be concatenated to the name provided. This way we will have the benefit of both uniqueness and the semantics.I also edited the relevant tests. This is my first time contribution attempt. Please let me know if there is something over or under developed. Happy to help.
Checklist