This is an automated email from the ASF dual-hosted git repository. michaelsmolina pushed a commit to branch 4.0 in repository https://gitbox.apache.org/repos/asf/superset.git
commit fac8c123e3cb188695fe16852764b4a4d5023530 Author: Michael S. Molina <[email protected]> AuthorDate: Wed Oct 9 13:25:44 2024 -0300 fix: Unable to parse escaped tables (#30560) --- superset/config.py | 5 +++++ superset/initialization/__init__.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/superset/config.py b/superset/config.py index 859915c3b5..a5fdd2f4b5 100644 --- a/superset/config.py +++ b/superset/config.py @@ -64,6 +64,7 @@ logger = logging.getLogger(__name__) if TYPE_CHECKING: from flask_appbuilder.security.sqla import models + from sqlglot import Dialect, Dialects from superset.connectors.sqla.models import SqlaTable from superset.models.core import Database @@ -231,6 +232,10 @@ SQLALCHEMY_CUSTOM_PASSWORD_STORE = None SQLALCHEMY_ENCRYPTED_FIELD_TYPE_ADAPTER = ( # pylint: disable=invalid-name SQLAlchemyUtilsAdapter ) + +# Extends the default SQLGlot dialects with additional dialects +SQLGLOT_DIALECTS_EXTENSIONS: map[str, Dialects | type[Dialect]] = {} + # The limit of queries fetched for query search QUERY_SEARCH_LIMIT = 1000 diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py index f39a1ec99d..220a68f4e3 100644 --- a/superset/initialization/__init__.py +++ b/superset/initialization/__init__.py @@ -53,6 +53,7 @@ from superset.extensions import ( talisman, ) from superset.security import SupersetSecurityManager +from superset.sql_parse import SQLGLOT_DIALECTS from superset.superset_typing import FlaskResponse from superset.tags.core import register_sqla_event_listeners from superset.utils.core import is_test, pessimistic_connection_handling @@ -484,6 +485,7 @@ class SupersetAppInitializer: # pylint: disable=too-many-public-methods self.configure_wtf() self.configure_middlewares() self.configure_cache() + self.configure_sqlglot_dialects() with self.superset_app.app_context(): self.init_app_in_ctx() @@ -521,6 +523,9 @@ class SupersetAppInitializer: # pylint: disable=too-many-public-methods def configure_feature_flags(self) -> None: feature_flag_manager.init_app(self.superset_app) + def configure_sqlglot_dialects(self) -> None: + SQLGLOT_DIALECTS.update(self.config["SQLGLOT_DIALECTS_EXTENSIONS"]) + def configure_fab(self) -> None: if self.config["SILENCE_FAB"]: logging.getLogger("flask_appbuilder").setLevel(logging.ERROR)
