dpgaspar commented on a change in pull request #16624:
URL: https://github.com/apache/superset/pull/16624#discussion_r705434809



##########
File path: superset/models/core.py
##########
@@ -721,6 +721,28 @@ def has_table_by_name(self, table_name: str, schema: 
Optional[str] = None) -> bo
         engine = self.get_sqla_engine()
         return engine.has_table(table_name, schema)
 
+    @classmethod
+    def _has_view(
+        cls,
+        conn: Connection,
+        dialect: Dialect,
+        view_name: str,
+        schema: Optional[str] = None,
+    ) -> bool:
+        view_names: List[str] = []
+        try:
+            view_names = dialect.get_view_names(connection=conn, schema=schema)

Review comment:
       bugs me that we were only checking for `has_table` since this should 
just check for tables, the base dialect class on SQLAlchemy:
   ```
       def has_table(self, connection, table_name, schema=None):
           """Check the existence of a particular table in the database.
   
           Given a :class:`.Connection` object and a string
           `table_name`, return True if the given table (possibly within
           the specified `schema`) exists in the database, False
           otherwise.
           """
   
           raise NotImplementedError()
   ```
   
   So this seems like a valid solution to me, kind of surprises me that this 
not happen on other engines.
   @villebro @betodealmeida what do you think?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to