forked from databricks/dbt-databricks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drop bespoke mat, intro simpler macros
- Loading branch information
Showing
9 changed files
with
72 additions
and
59 deletions.
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 }} | ||
{% endmacro %} |