Skip to content

Commit

Permalink
Switch to render for safest relation str substitution (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-db authored and eric-wang-1990 committed Jan 28, 2025
1 parent 7790ea8 commit d688c6f
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{%- set cols = [cols] -%}
{%- endif -%}
{%- call statement('set_cluster_by_columns') -%}
ALTER {{ target_relation.type }} {{ target_relation }} CLUSTER BY ({{ cols | join(', ') }})
ALTER {{ target_relation.type }} {{ target_relation.render() }} CLUSTER BY ({{ cols | join(', ') }})
{%- endcall -%}
{%- endif %}
{%- endmacro -%}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
{% macro get_alter_mv_internal(relation, configuration_changes) %}
{%- set refresh = configuration_changes.changes["refresh"] -%}
-- Currently only schedule can be altered
ALTER MATERIALIZED VIEW {{ relation }}
ALTER MATERIALIZED VIEW {{ relation.render() }}
{{ get_alter_sql_refresh_schedule(refresh.cron, refresh.time_zone_value, refresh.is_altered) -}}
{% endmacro %}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% macro databricks__drop_materialized_view(relation) -%}
drop materialized view if exists {{ relation }}
drop materialized view if exists {{ relation.render() }}
{%- endmacro %}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% macro databricks__refresh_materialized_view(relation) -%}
refresh materialized view {{ relation }}
refresh materialized view {{ relation.render() }}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
{%- endmacro %}

{% macro default__drop_streaming_table(relation) -%}
drop table if exists {{ relation }}
drop table if exists {{ relation.render() }}
{%- endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{%- endmacro %}

{% macro databricks__refresh_streaming_table(relation, sql) -%}
create or refresh streaming table {{ relation }}
create or refresh streaming table {{ relation.render() }}
as
{{ sql }}
{% endmacro %}
4 changes: 2 additions & 2 deletions dbt/include/databricks/macros/relations/table/create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{%- else -%}
{%- set file_format = config.get('file_format', default='delta') -%}
{% if file_format == 'delta' %}
create or replace table {{ relation }}
create or replace table {{ relation.render() }}
{% else %}
create table {{ relation }}
create table {{ relation.render() }}
{% endif %}
{%- set contract_config = config.get('contract') -%}
{% if contract_config and contract_config.enforced %}
Expand Down
2 changes: 1 addition & 1 deletion dbt/include/databricks/macros/relations/table/drop.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% macro databricks__drop_table(relation) -%}
drop table if exists {{ relation }}
drop table if exists {{ relation.render() }}
{%- endmacro %}
4 changes: 2 additions & 2 deletions dbt/include/databricks/macros/relations/tags.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
{%- endmacro -%}

{% macro alter_set_tags(relation, tags) -%}
ALTER {{ relation.type }} {{ relation }} SET TAGS (
ALTER {{ relation.type }} {{ relation.render() }} SET TAGS (
{% for tag in tags -%}
'{{ tag }}' = '{{ tags[tag] }}' {%- if not loop.last %}, {% endif -%}
{%- endfor %}
)
{%- endmacro -%}

{% macro alter_unset_tags(relation, tags) -%}
ALTER {{ relation.type }} {{ relation }} UNSET TAGS (
ALTER {{ relation.type }} {{ relation.render() }} UNSET TAGS (
{% for tag in tags -%}
'{{ tag }}' {%- if not loop.last %}, {%- endif %}
{%- endfor %}
Expand Down
2 changes: 1 addition & 1 deletion dbt/include/databricks/macros/relations/tblproperties.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% set tblproperty_statment = databricks__tblproperties_clause(tblproperties) %}
{% if tblproperty_statment %}
{%- call statement('apply_tblproperties') -%}
ALTER {{ relation.type }} {{ relation }} SET {{ tblproperty_statment}}
ALTER {{ relation.type }} {{ relation.render() }} SET {{ tblproperty_statment}}
{%- endcall -%}
{% endif %}
{%- endmacro -%}
2 changes: 1 addition & 1 deletion dbt/include/databricks/macros/relations/view/create.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% macro databricks__create_view_as(relation, sql) -%}
create or replace view {{ relation }}
create or replace view {{ relation.render() }}
{% if config.persist_column_docs() -%}
{% set model_columns = model.columns %}
{% set query_columns = get_columns_in_query(sql) %}
Expand Down
2 changes: 1 addition & 1 deletion dbt/include/databricks/macros/relations/view/drop.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% macro databricks__drop_view(relation) -%}
drop view if exists {{ relation }}
drop view if exists {{ relation.render() }}
{%- endmacro %}

0 comments on commit d688c6f

Please sign in to comment.