Skip to content

Commit

Permalink
fix: Unable to parse escaped tables (#30560)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored and Michael Molina committed Oct 28, 2024
1 parent b3b960b commit fac8c12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

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
Expand Down Expand Up @@ -231,6 +232,10 @@ def _try_json_readsha(filepath: str, length: int) -> str | 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

Expand Down
5 changes: 5 additions & 0 deletions superset/initialization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
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
Expand Down Expand Up @@ -484,6 +485,7 @@ def init_app(self) -> None:
self.configure_wtf()
self.configure_middlewares()
self.configure_cache()
self.configure_sqlglot_dialects()

with self.superset_app.app_context():
self.init_app_in_ctx()
Expand Down Expand Up @@ -521,6 +523,9 @@ def configure_cache(self) -> None:
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)
Expand Down

0 comments on commit fac8c12

Please sign in to comment.