You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When switching on case sensitivity, the database's case-insensitive comparisons allow the DROP VIEW IF EXISTS to succeed in dropping the newly-created view.
2025-02-27 16:42:18,836 - ThreadPoolExecutor-4_1 - sqlmesh.core.engine_adapter.base - INFO - Executing SQL: CREATE OR ALTER VIEW [a_o].[O] AS SELECT * FROM [sql-prod].[a_o].[a_o__O__641323945]; (base.py:2079)
2025-02-27 16:42:19,635 - ThreadPoolExecutor-5_1 - sqlmesh.core.engine_adapter.base - INFO - Executing SQL: DROP VIEW IF EXISTS [a_o].[o]; (base.py:2079)
The text was updated successfully, but these errors were encountered:
The order of the commands needs to be reversed: first, drop the view, then re-create it.
If we reverse the order like @martinburch said, that should solve this #3649 as well. just curious, is there any specific reason why we do create -> drop not drop -> create.
@martinburch can you provide a complete example that I can use to reproduce the problem you're seeing? I'm not sure I understand what you're trying to achieve. I get that you changed the dialect setting to activate case-sensitivity for the T-SQL dialect, but is your database or your MSSQL server also case-sensitive?
When switching on case sensitivity, the database's case-insensitive comparisons allow the DROP VIEW IF EXISTS to succeed in dropping the newly-created view.
The order of the commands needs to be reversed: first, drop the view, then re-create it.
https://learn.microsoft.com/en-us/sql/relational-databases/views/rename-views?view=sql-server-ver16#TsqlProcedure
As a workaround, I can replay the CREATE OR ALTER VIEW commands from the SQLMesh log.
SQLMesh correctly identifes
However, the commands are in the wrong order:
2025-02-27 16:42:18,836 - ThreadPoolExecutor-4_1 - sqlmesh.core.engine_adapter.base - INFO - Executing SQL: CREATE OR ALTER VIEW [a_o].[O] AS SELECT * FROM [sql-prod].[a_o].[a_o__O__641323945]; (base.py:2079)
2025-02-27 16:42:19,635 - ThreadPoolExecutor-5_1 - sqlmesh.core.engine_adapter.base - INFO - Executing SQL: DROP VIEW IF EXISTS [a_o].[o]; (base.py:2079)
The text was updated successfully, but these errors were encountered: