mistercrunch commented on code in PR #34766:
URL: https://github.com/apache/superset/pull/34766#discussion_r2299246454
##########
superset/models/core.py:
##########
@@ -864,6 +864,45 @@ def get_all_view_names_in_schema(
except Exception as ex:
raise self.db_engine_spec.get_dbapi_mapped_exception(ex) from ex
+ @cache_util.memoized_func(
+
key="db:{self.id}:catalog:{catalog}:schema:{schema}:materialized_view_list",
+ cache=cache_manager.cache,
+ )
+ def get_all_materialized_view_names_in_schema(
+ self,
+ catalog: str | None,
+ schema: str,
+ ) -> set[tuple[str, str, str | None]]:
+ """Get all materialized views in the specified schema.
+
+ Parameters need to be passed as keyword arguments.
+
+ For unused parameters, they are referenced in
+ cache_util.memoized_func decorator.
+
+ :param catalog: optional catalog name
+ :param schema: schema name
+ :param cache: whether cache is enabled for the function
+ :param cache_timeout: timeout in seconds for the cache
+ :param force: whether to force refresh the cache
+ :return: set of materialized views
+ """
+ # Check if the engine spec has a method to get materialized views
+ if hasattr(self.db_engine_spec, "get_materialized_view_names"):
Review Comment:
approving the PR pending this minor tweak. Also ran this to check whether we
do this elsewhere in this package and looked mostly ok
```bash
15:06 $ git grep hasattr superset/db_engine_specs/
superset/db_engine_specs/__init__.py: and hasattr(dialect,
"driver")
superset/db_engine_specs/__init__.py: and hasattr(engine_spec,
"default_driver")
superset/db_engine_specs/base.py: if hasattr(cls,
"extra_table_metadata"):
superset/db_engine_specs/base.py: return g and hasattr(g, "user") and
isinstance(ex, cls.oauth2_exception)
superset/db_engine_specs/base.py: if hasattr(sqla_column_type,
"collation"):
superset/db_engine_specs/base.py: if hasattr(sqla_column_type,
"charset"):
superset/db_engine_specs/base.py: hasattr(dialect,
"requires_name_normalize")
superset/db_engine_specs/bigquery.py: if hasattr(query_job,
"total_bytes_processed"):
superset/db_engine_specs/presto.py: hasattr(ex, "orig")
superset/db_engine_specs/presto.py: if type(ex).__name__ ==
"DatabaseError" and hasattr(ex, "args") and ex.args:
```
--
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]