diff --git a/dbt/adapters/clickhouse/impl.py b/dbt/adapters/clickhouse/impl.py index 1eea8d8b..09047502 100644 --- a/dbt/adapters/clickhouse/impl.py +++ b/dbt/adapters/clickhouse/impl.py @@ -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} """ diff --git a/dbt/include/clickhouse/macros/schema_tests/relationships.sql b/dbt/include/clickhouse/macros/schema_tests/relationships.sql index a0f09fd3..f602fecc 100644 --- a/dbt/include/clickhouse/macros/schema_tests/relationships.sql +++ b/dbt/include/clickhouse/macros/schema_tests/relationships.sql @@ -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 %} diff --git a/dbt/include/clickhouse/macros/utils/utils.sql b/dbt/include/clickhouse/macros/utils/utils.sql index aa65abff..d81e6da3 100644 --- a/dbt/include/clickhouse/macros/utils/utils.sql +++ b/dbt/include/clickhouse/macros/utils/utils.sql @@ -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}}