Skip to content

Commit

Permalink
rename end of query flag
Browse files Browse the repository at this point in the history
  • Loading branch information
BentsiLeviav committed Feb 4, 2024
1 parent 047308e commit 36303c3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dbt/adapters/clickhouse/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def get_model_settings(self, model):
else:
settings_str = 'SETTINGS ' + ', '.join(res) + '\n'
return f"""
-- settings_section
-- end_of_sql
{settings_str}
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ left join parent
on child.from_field = parent.to_field

where parent.to_field is null
-- settings_section
-- end_of_sql
settings join_use_nulls = 1

{% endmacro %}
8 changes: 4 additions & 4 deletions dbt/include/clickhouse/macros/utils/utils.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
-- When multiple queries are nested, the limit will be attached to the outer query
{% macro clickhouse__place_limit(query, limit) -%}
{% if 'settings' in query.lower()%}
{% if '-- settings_section' not in query.lower()%}
{{exceptions.raise_compiler_error("-- settings_section must be set when using ClickHouse settings")}}
{% if '-- end_of_sql' not in query.lower()%}
{{exceptions.raise_compiler_error("-- end_of_sql must be set when using ClickHouse settings")}}
{% endif %}
{% set split_by_settings_sections = query.split("-- settings_section")%}
{% set split_by_settings_sections = query.split("-- end_of_sql")%}
{% set split_by_settings_sections_with_limit = split_by_settings_sections[-2] + "\n LIMIT " + limit|string + "\n" %}
{% set query_with_limit = "-- settings_section".join(split_by_settings_sections[:-2] + [split_by_settings_sections_with_limit, split_by_settings_sections[-1]])%}
{% set query_with_limit = "-- end_of_sql".join(split_by_settings_sections[:-2] + [split_by_settings_sections_with_limit, split_by_settings_sections[-1]])%}
{{query_with_limit}}
{% else %}
{{query}}
Expand Down

0 comments on commit 36303c3

Please sign in to comment.