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 19:40:36 UTC

[superset] branch robust_has_table_query updated (67f447b0ae -> be6f7dfa99)

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

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


    omit 67f447b0ae Fix lint and tests
     new be6f7dfa99 Fix lint and tests

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (67f447b0ae)
            \
             N -- N -- N   refs/heads/robust_has_table_query (be6f7dfa99)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 tests/unit_tests/sql_parse_tests.py | 4 ----
 1 file changed, 4 deletions(-)


[superset] 01/01: Fix lint and tests

Posted by be...@apache.org.
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 be6f7dfa99836486edbb9ebb268f517e9a02243f
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu May 11 17:26:22 2023 -0700

    Fix lint and tests
---
 superset/connectors/sqla/models.py  |  4 +---
 superset/models/helpers.py          | 10 +++++-----
 superset/sql_parse.py               |  2 +-
 tests/unit_tests/sql_parse_tests.py |  4 ----
 4 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index b0dc302920..0323fee995 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -82,10 +82,8 @@ from superset.db_engine_specs.base import BaseEngineSpec, TimestampExpression
 from superset.exceptions import (
     ColumnNotFoundException,
     DatasetInvalidPermissionEvaluationException,
-    QueryClauseValidationException,
     QueryObjectValidationError,
     SupersetGenericDBErrorException,
-    SupersetSecurityException,
 )
 from superset.jinja_context import (
     BaseTemplateProcessor,
@@ -102,7 +100,7 @@ from superset.models.helpers import (
     QueryResult,
     QueryStringExtended,
 )
-from superset.sql_parse import ParsedQuery, sanitize_clause
+from superset.sql_parse import ParsedQuery
 from superset.superset_typing import (
     AdhocColumn,
     AdhocMetric,
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index 7de361bad3..ac0528bd98 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -118,12 +118,12 @@ def validate_adhoc_subquery(
     :raise SupersetSecurityException if sql contains sub-queries or
     nested sub-queries with table
     """
-    # build a proper SQL query from the expression
-    sql = f"SELECT {expression}"
-
     statements = []
-    for statement in sqlparse.parse(sql):
-        if has_table_query(str(statement), sqla_dialect):
+    for statement in sqlparse.parse(expression):
+        # build a proper SQL query from the expression for sqloxide
+        sql = f"SELECT {expression}"
+
+        if has_table_query(sql, sqla_dialect):
             if not is_feature_enabled("ALLOW_ADHOC_SUBQUERY"):
                 raise SupersetSecurityException(
                     SupersetError(
diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index e7fec3756f..4d1e9d71a0 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -791,7 +791,7 @@ def extract_table_references(
     sql_text = RE_JINJA_VAR.sub("abc", sql_text)
     try:
         tree = parse_sql(sql_text, dialect=sqloxide_dialect)
-    except Exception as ex:  # pylint: disable=broad-except
+    except Exception as ex:
         if show_warning:
             logger.warning(
                 "\nUnable to parse query with sqloxide:\n%s\n%s", sql_text, ex
diff --git a/tests/unit_tests/sql_parse_tests.py b/tests/unit_tests/sql_parse_tests.py
index 69440319ba..9ed919ddf0 100644
--- a/tests/unit_tests/sql_parse_tests.py
+++ b/tests/unit_tests/sql_parse_tests.py
@@ -1618,8 +1618,6 @@ def test_extract_table_references(mocker: MockerFixture) -> None:
         Table(table="table", schema=None, catalog=None),
         Table(table="other_table", schema=None, catalog=None),
     }
-<<<<<<< HEAD
-    logger.warning.assert_not_called()
 
 
 def test_is_select() -> None:
@@ -1637,5 +1635,3 @@ WITH t AS (
 )
 SELECT * FROM t"""
     ).is_select()
-=======
->>>>>>> 748876648e (feat: robust(er) adhoc query validation)