forked from databricks/dbt-databricks
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drop bespoke mat, intro simpler macros #1
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 0 additions & 9 deletions
9
...lude/databricks/macros/materializations/materialized_view/create_materialized_view_as.sql
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
dbt/include/databricks/macros/materializations/materialized_view/materialized_view.sql
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...nclude/databricks/macros/materializations/materialized_view/refresh_materialized_view.sql
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
dbt/include/databricks/macros/relations/materialized_view/alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{% macro databricks__get_alter_materialized_view_as_sql( | ||
relation, | ||
configuration_changes, | ||
sql, | ||
existing_relation, | ||
backup_relation, | ||
intermediate_relation | ||
) %} | ||
|
||
-- apply a full refresh immediately if needed | ||
{% if configuration_changes.requires_full_refresh %} | ||
|
||
{{ get_replace_sql(existing_relation, relation, sql) }} | ||
|
||
-- otherwise apply individual changes as needed | ||
{% else %} | ||
|
||
{{ databricks__update_indexes_on_materialized_view(relation, configuration_changes.indexes) }} | ||
|
||
{%- endif -%} | ||
|
||
{% endmacro %} | ||
|
||
|
||
{%- macro databricks__update_indexes_on_materialized_view(relation, index_changes) -%} | ||
{{- log("Applying UPDATE INDEXES to: " ~ relation) -}} | ||
|
||
{%- for _index_change in index_changes -%} | ||
{%- set _index = _index_change.context -%} | ||
|
||
{%- if _index_change.action == "drop" -%} | ||
|
||
{{ databricks__get_drop_index_sql(relation, _index.name) }}; | ||
|
||
{%- elif _index_change.action == "create" -%} | ||
|
||
{{ databricks__get_create_index_sql(relation, _index.as_node_config) }} | ||
|
||
{%- endif -%} | ||
|
||
{%- endfor -%} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{% macro databricks__get_materialized_view_configuration_changes(existing_relation, new_config) %} | ||
{% set _existing_materialized_view = databricks__describe_materialized_view(existing_relation) %} | ||
{% set _configuration_changes = existing_relation.get_materialized_view_config_change_collection(_existing_materialized_view, new_config) %} | ||
{% do return(_configuration_changes) %} | ||
{% endmacro %} |
8 changes: 8 additions & 0 deletions
8
dbt/include/databricks/macros/relations/materialized_view/create.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% macro databricks__get_create_materialized_view_as_sql(relation, sql) %} | ||
create materialized view if not exists {{ relation }} as {{ sql }}; | ||
|
||
{% for _index_dict in config.get('indexes', []) -%} | ||
{{- get_create_index_sql(relation, _index_dict) -}} | ||
{%- endfor -%} | ||
|
||
{% endmacro %} |
5 changes: 5 additions & 0 deletions
5
dbt/include/databricks/macros/relations/materialized_view/describe.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% macro databricks__describe_materialized_view(relation) %} | ||
-- for now just get the indexes, we don't need the name or the query yet | ||
{% set _indexes = run_query(get_show_indexes_sql(relation)) %} | ||
{% do return({'indexes': _indexes}) %} | ||
{% endmacro %} |
3 changes: 3 additions & 0 deletions
3
dbt/include/databricks/macros/relations/materialized_view/drop.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro databricks__drop_materialized_view(relation) -%} | ||
drop materialized view if exists {{ relation }} cascade | ||
{%- endmacro %} |
3 changes: 3 additions & 0 deletions
3
dbt/include/databricks/macros/relations/materialized_view/refresh.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro databricks__refresh_materialized_view(relation) %} | ||
refresh materialized view {{ relation }} | ||
{% endmacro %} |
3 changes: 3 additions & 0 deletions
3
dbt/include/databricks/macros/relations/materialized_view/rename.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro databricks__get_rename_materialized_view_sql(relation, new_name) %} | ||
alter materialized view {{ relation }} rename to {{ new_name }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MVs in Databricks cannot be renamed. What should we do instead? |
||
{% endmacro %} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Databricks doesn't have traditional indexes.