We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c5dbce5 commit 9f25d23Copy full SHA for 9f25d23
1 file changed
sqlmesh/core/engine_adapter/duckdb.py
@@ -218,3 +218,23 @@ def _create_table(
218
@property
219
def _is_motherduck(self) -> bool:
220
return self._extra_config.get("is_motherduck", False)
221
+
222
+ def drop_table(
223
+ self,
224
+ table_name: t.Any,
225
+ exists: bool = True,
226
+ **kwargs: t.Any,
227
+ ) -> None:
228
+ """
229
+ DuckDB will raise an error if you try to DROP TABLE on a view.
230
+ Fallback to DROP VIEW if the execution of DROP TABLE fails.
231
232
+ from duckdb import Error
233
234
+ # Safety: Remove 'exists' from kwargs so we don't pass it twice
235
+ kwargs.pop("exists", None)
236
237
+ try:
238
+ super().drop_table(table_name, exists=exists, **kwargs)
239
+ except Error:
240
+ self.drop_view(table_name, **kwargs)
0 commit comments