Fix config change detection not working for multiple sortkey in materialized views #1
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#838
Problem
Having multiple sort keys and without changes between the model and the Materialized View, the change check between model and view ends up returning as a result that it has changes. This is because svv_table_info.sortkey1 is being used instead of use the list of sort key that the Materialized View have
Solution
We can get the list of SortKeys using the
mv_tbl
related tableChecklist
Steps To Reproduce:
Make sure to delete the MV first.
drop materialized view if exists dev.public.mv_double_sort
Add an mv to the project with more than 1 sort key:
$ dbt --debug build -s my_double_sort
Should create the materialized view$ dbt --debug build -s my_double_sort
and should refresh the materialized view instead of drop and recreate the view