-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorg to align with dbt-core: Part II (#528)
- Loading branch information
Showing
19 changed files
with
285 additions
and
270 deletions.
There are no files selected for viewing
21 changes: 0 additions & 21 deletions
21
dbt/include/databricks/macros/catalog.sql → ...de/databricks/macros/adapters/catalog.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
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
dbt/include/databricks/macros/adapters/databricks_catalog.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,20 @@ | ||
{% macro current_catalog() -%} | ||
{{ return(adapter.dispatch('current_catalog', 'dbt')()) }} | ||
{% endmacro %} | ||
|
||
{% macro databricks__current_catalog() -%} | ||
{% call statement('current_catalog', fetch_result=True) %} | ||
select current_catalog() | ||
{% endcall %} | ||
{% do return(load_result('current_catalog').table) %} | ||
{% endmacro %} | ||
|
||
{% macro use_catalog(catalog) -%} | ||
{{ return(adapter.dispatch('use_catalog', 'dbt')(catalog)) }} | ||
{% endmacro %} | ||
|
||
{% macro databricks__use_catalog(catalog) -%} | ||
{% call statement() %} | ||
use catalog {{ adapter.quote(catalog) }} | ||
{% endcall %} | ||
{% endmacro %} |
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,72 @@ | ||
{% macro databricks__list_relations_without_caching(schema_relation) %} | ||
{{ return(adapter.get_relations_without_caching(schema_relation)) }} | ||
{% endmacro %} | ||
|
||
{% macro show_table_extended(schema_relation) %} | ||
{{ return(adapter.dispatch('show_table_extended', 'dbt')(schema_relation)) }} | ||
{% endmacro %} | ||
|
||
{% macro databricks__show_table_extended(schema_relation) %} | ||
{% call statement('show_table_extended', fetch_result=True) -%} | ||
show table extended in {{ schema_relation.without_identifier() }} like '{{ schema_relation.identifier }}' | ||
{% endcall %} | ||
|
||
{% do return(load_result('show_table_extended').table) %} | ||
{% endmacro %} | ||
|
||
{% macro show_tables(relation) %} | ||
{{ return(adapter.dispatch('show_tables', 'dbt')(relation)) }} | ||
{% endmacro %} | ||
|
||
{% macro databricks__show_tables(relation) %} | ||
{% call statement('show_tables', fetch_result=True) -%} | ||
show tables in {{ relation }} | ||
{% endcall %} | ||
|
||
{% do return(load_result('show_tables').table) %} | ||
{% endmacro %} | ||
|
||
{% macro show_views(relation) %} | ||
{{ return(adapter.dispatch('show_views', 'dbt')(relation)) }} | ||
{% endmacro %} | ||
|
||
{% macro databricks__show_views(relation) %} | ||
{% call statement('show_views', fetch_result=True) -%} | ||
show views in {{ relation }} | ||
{% endcall %} | ||
|
||
{% do return(load_result('show_views').table) %} | ||
{% endmacro %} | ||
|
||
{% macro databricks__get_relation_last_modified(information_schema, relations) -%} | ||
|
||
{%- call statement('last_modified', fetch_result=True) -%} | ||
{% if information_schema.is_hive_metastore %} | ||
{%- for relation in relations -%} | ||
select '{{ relation.schema }}' as schema, | ||
'{{ relation.identifier }}' as identifier, | ||
max(timestamp) as last_modified, | ||
{{ current_timestamp() }} as snapshotted_at | ||
from (describe history {{ relation.schema }}.{{ relation.identifier }}) | ||
{% if not loop.last %} | ||
union all | ||
{% endif %} | ||
{%- endfor -%} | ||
{% else %} | ||
select table_schema as schema, | ||
table_name as identifier, | ||
last_altered as last_modified, | ||
{{ current_timestamp() }} as snapshotted_at | ||
from {{ information_schema }}.tables | ||
where ( | ||
{%- for relation in relations -%} | ||
(table_schema = '{{ relation.schema }}' and | ||
table_name = '{{ relation.identifier }}'){%- if not loop.last %} or {% endif -%} | ||
{%- endfor -%} | ||
) | ||
{% endif %} | ||
{%- endcall -%} | ||
|
||
{{ return(load_result('last_modified')) }} | ||
|
||
{% endmacro %} |
File renamed without changes.
File renamed without changes.
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,33 @@ | ||
{% macro databricks__make_temp_relation(base_relation, suffix='__dbt_tmp', as_table=False) %} | ||
{% set tmp_identifier = base_relation.identifier ~ suffix %} | ||
{%- if as_table -%} | ||
{% set tmp_relation = api.Relation.create( | ||
identifier=tmp_identifier, | ||
schema=base_relation.schema, | ||
database=base_relation.database, | ||
type='table') %} | ||
{%- else -%} | ||
{% set tmp_relation = api.Relation.create(identifier=tmp_identifier, type='view') %} | ||
{%- endif -%} | ||
{% do return(tmp_relation) %} | ||
{% endmacro %} | ||
|
||
{% macro databricks__get_or_create_relation(database, schema, identifier, type, needs_information=False) %} | ||
{%- set target_relation = adapter.get_relation( | ||
database=database, | ||
schema=schema, | ||
identifier=identifier, | ||
needs_information=needs_information) %} | ||
|
||
{% if target_relation %} | ||
{% do return([true, target_relation]) %} | ||
{% endif %} | ||
|
||
{%- set new_relation = api.Relation.create( | ||
database=database, | ||
schema=schema, | ||
identifier=identifier, | ||
type=type | ||
) -%} | ||
{% do return([false, new_relation]) %} | ||
{% endmacro %} |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
dbt/include/databricks/macros/get_custom_name/get_custom_database.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,13 @@ | ||
{# | ||
This is identical to the implementation in dbt-core. | ||
We need to override because dbt-spark overrides to something we don't like. | ||
#} | ||
{% macro databricks__generate_database_name(custom_database_name=none, node=none) -%} | ||
{%- set default_database = target.database -%} | ||
{%- if custom_database_name is none -%} | ||
{{ return(default_database) }} | ||
{%- else -%} | ||
{{ return(custom_database_name) }} | ||
{%- endif -%} | ||
{%- endmacro %} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.