Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbt/adapters/fabric/fabric_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FabricAdapter(SQLAdapter):

@classmethod
def quote(cls, identifier):
return "[{}]".format(identifier)
return "[{}]".format(identifier.replace("]", "]]"))

AdapterSpecificConfigs = FabricConfigs
Relation = FabricRelation
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/fabric/fabric_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class FabricColumn(Column):
@property
def quoted(self) -> str:
return "[{}]".format(self.column)
return "[{}]".format(self.column.replace("]", "]]"))

TYPE_LABELS: ClassVar[Dict[str, str]] = {
"STRING": "VARCHAR(8000)",
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/fabric/fabric_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FabricRelation(BaseRelation):
require_alias: bool = True

def quoted(self, identifier):
return "[{}]".format(identifier)
return "[{}]".format(identifier.replace("]", "]]"))

@classproperty
def get_relation_type(cls) -> Type[FabricRelationType]:
Expand Down
6 changes: 3 additions & 3 deletions dbt/include/fabric/macros/adapters/columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

{% set tempTable %}
CREATE TABLE {{tempTableName}}
AS SELECT {{query_result_text}}, CAST([{{ column_name }}] AS {{new_column_type}}) AS [{{column_name}}] FROM {{ relation.schema }}.{{ relation.identifier }}
AS SELECT {{query_result_text}}, CAST([{{ column_name | replace(']', ']]') }}] AS {{new_column_type}}) AS [{{ column_name | replace(']', ']]') }}] FROM {{ relation.schema }}.{{ relation.identifier }}
{{ apply_label() }}
{% endset %}

Expand Down Expand Up @@ -129,12 +129,12 @@
{% call statement('add_drop_columns') -%}
{% if add_columns %}
alter {{ relation.type }} {{ relation }}
add {% for column in add_columns %}[{{ column.name }}] {{ column.data_type }}{{ ', ' if not loop.last }}{% endfor %};
add {% for column in add_columns %}[{{ column.name | replace(']', ']]') }}] {{ column.data_type }}{{ ', ' if not loop.last }}{% endfor %};
{% endif %}

{% if remove_columns %}
alter {{ relation.type }} {{ relation }}
drop column {% for column in remove_columns %}[{{ column.name }}]{{ ',' if not loop.last }}{% endfor %};
drop column {% for column in remove_columns %}[{{ column.name | replace(']', ']]') }}]{{ ',' if not loop.last }}{% endfor %};
{% endif %}
{%- endcall -%}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{ get_assert_columns_equivalent(sql) }}
{% set listColumns %}
{% for column in model['columns'] %}
{{ "["~column~"]" }}{{ ", " if not loop.last }}
{{ "["~column|replace(']', ']]')~"]" }}{{ ", " if not loop.last }}
{% endfor %}
{%endset%}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% macro fabric__create_columns(relation, columns) %}
{% for column in columns %}
{% call statement() %}
alter table {{ relation.render() }} add [{{ column.name }}] {{ column.data_type }} NULL;
alter table {{ relation.render() }} add [{{ column.name | replace(']', ']]') }}] {{ column.data_type }} NULL;
{% endcall %}
{% endfor %}
{% endmacro %}
Expand Down
Loading