Skip to content

Commit f40fc4d

Browse files
committed
updated tests
1 parent 9c0a2dd commit f40fc4d

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

sqlmesh/core/config/connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,12 +1596,14 @@ def _extra_engine_config(self) -> t.Dict[str, t.Any]:
15961596
class FabricConnectionConfig(MSSQLConnectionConfig):
15971597
"""
15981598
Fabric Connection Configuration.
1599-
16001599
Inherits most settings from MSSQLConnectionConfig and sets the type to 'fabric'.
16011600
It is recommended to use the 'pyodbc' driver for Fabric.
16021601
"""
16031602

16041603
type_: t.Literal["fabric"] = Field(alias="type", default="fabric") # type: ignore
1604+
DIALECT: t.ClassVar[t.Literal["fabric"]] = "fabric"
1605+
DISPLAY_NAME: t.ClassVar[t.Literal["Fabric"]] = "Fabric"
1606+
DISPLAY_ORDER: t.ClassVar[t.Literal[17]] = 17
16051607
driver: t.Literal["pyodbc"] = "pyodbc"
16061608
autocommit: t.Optional[bool] = True
16071609

tests/core/engine_adapter/test_fabric.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ def test_table_exists(adapter: FabricAdapter):
5353
assert not adapter.table_exists("db.table")
5454

5555

56-
def test_insert_overwrite_by_time_partition(
57-
adapter: FabricAdapter, assert_exp_eq
58-
): # Add assert_exp_eq fixture
56+
def test_insert_overwrite_by_time_partition(adapter: FabricAdapter):
5957
adapter.insert_overwrite_by_time_partition(
6058
"test_table",
6159
parse_one("SELECT a, b FROM tbl"),
@@ -66,27 +64,11 @@ def test_insert_overwrite_by_time_partition(
6664
columns_to_types={"a": exp.DataType.build("INT"), "b": exp.DataType.build("STRING")},
6765
)
6866

69-
# Get the list of generated SQL strings
70-
actual_sql_calls = to_sql_calls(adapter)
71-
72-
# There should be two calls: DELETE and INSERT
73-
assert len(actual_sql_calls) == 2
74-
75-
# Assert the DELETE statement is correct (string comparison is fine for this simple one)
76-
assert (
77-
actual_sql_calls[0]
78-
== "DELETE FROM [test_table] WHERE [b] BETWEEN '2022-01-01' AND '2022-01-02';"
79-
)
80-
81-
# Assert the INSERT statement is semantically correct
82-
expected_insert_sql = """
83-
INSERT INTO [test_table] ([a], [b])
84-
SELECT [a], [b] FROM (SELECT [a], [b] FROM [tbl]) AS [_subquery]
85-
WHERE [b] BETWEEN '2022-01-01' AND '2022-01-02';
86-
"""
87-
88-
# Use assert_exp_eq to compare the parsed SQL expressions
89-
assert_exp_eq(actual_sql_calls[1], expected_insert_sql)
67+
# Fabric adapter should use DELETE/INSERT strategy, not MERGE.
68+
assert to_sql_calls(adapter) == [
69+
"""DELETE FROM [test_table] WHERE [b] BETWEEN '2022-01-01' AND '2022-01-02';""",
70+
"""INSERT INTO [test_table] ([a], [b]) SELECT [a], [b] FROM (SELECT [a] AS [a], [b] AS [b] FROM [tbl]) AS [_subquery] WHERE [b] BETWEEN '2022-01-01' AND '2022-01-02';""",
71+
]
9072

9173

9274
def test_replace_query(adapter: FabricAdapter):

0 commit comments

Comments
 (0)