Skip to content

Fix(databricks): Materialized view drop failure due to incorrect type#5351

Merged
themisvaltinos merged 4 commits intomainfrom
themis/fix_mv_drop_databricks
Sep 11, 2025
Merged

Fix(databricks): Materialized view drop failure due to incorrect type#5351
themisvaltinos merged 4 commits intomainfrom
themis/fix_mv_drop_databricks

Conversation

@themisvaltinos
Copy link
Contributor

This fixes #5249 and correctly maps MATERIALIZED_VIEW to materialized_view instead of view in the case statement of _get_data_objects.

Previously the Databricks adapter was incorrectly identifying materialized views as regular views. This caused DROP VIEW to be issued instead of DROP MATERIALIZED VIEW resulting in the error:

Cannot drop a materialized view with DROP VIEW. Please use DROP MATERIALIZED VIEW instead


failure scenatio

So this wasn't exercised before #5087 but now since drop_data_object_on_type_mismatch is called like this inside create_view:

self.drop_data_object_on_type_mismatch(
      self.get_data_object(view_name),
      DataObjectType.VIEW if not materialized else DataObjectType.MATERIALIZED_VIEW,
)
  • get_data_object internally would return a materialised view's type as view while the conditional would correctly map as materialised view
  • this incorrect mismatch would result in the drop_data_object operation inside drop_data_object_on_type_mismatch
  • the drop would use the type returned from the query which would be view thus resulting in the error

@themisvaltinos themisvaltinos requested a review from a team September 11, 2025 09:17
@themisvaltinos themisvaltinos merged commit 00547b0 into main Sep 11, 2025
36 checks passed
@themisvaltinos themisvaltinos deleted the themis/fix_mv_drop_databricks branch September 11, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLMesh v0.211.2 - Databricks Materialised View cannot be dropped

2 participants