You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/10/03 22:46:31 UTC

[superset] 01/01: Fix query error

This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch robust_has_table_query
in repository https://gitbox.apache.org/repos/asf/superset.git

commit b51aec2b5a63be6bc426f404975de1da26923092
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Tue Oct 3 14:34:20 2023 -0700

    Fix query error
---
 superset/models/helpers.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index 81650c2dd6..762c05ef03 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -1608,6 +1608,9 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
         columns = [col for col in columns if col != utils.DTTM_ALIAS]
         dttm_col = columns_by_name.get(granularity) if granularity else None
 
+        dialect = self.db_engine_spec.get_engine().dialect
+        quoter = dialect.identifier_preparer.quote
+
         if need_groupby:
             # dedup columns while preserving order
             columns = groupby or columns
@@ -1629,7 +1632,7 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
                         )
                     else:
                         selected = validate_adhoc_subquery(
-                            selected,
+                            quoter(selected),
                             self.database_id,
                             self.schema,
                             self.db_engine_spec.engine,
@@ -1652,7 +1655,7 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
                     _sql = selected["sqlExpression"]
                     _column_label = selected["label"]
                 elif isinstance(selected, str):
-                    _sql = selected
+                    _sql = quoter(selected)
                     _column_label = selected
 
                 selected = validate_adhoc_subquery(