You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by er...@apache.org on 2020/01/06 19:15:27 UTC

[incubator-superset] branch revert-8598-VIZ-1194 created (now 39047f2)

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

erikrit pushed a change to branch revert-8598-VIZ-1194
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git.


      at 39047f2  Revert "Make select_star work with SQL Lab views (#8598)"

This branch includes the following new commits:

     new 39047f2  Revert "Make select_star work with SQL Lab views (#8598)"

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.



[incubator-superset] 01/01: Revert "Make select_star work with SQL Lab views (#8598)"

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erikrit pushed a commit to branch revert-8598-VIZ-1194
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 39047f263fdf6e3e6f3574987141b3e52accf0b0
Author: Erik Ritter <er...@airbnb.com>
AuthorDate: Mon Jan 6 11:15:14 2020 -0800

    Revert "Make select_star work with SQL Lab views (#8598)"
    
    This reverts commit 964e6db800614b32b47eb2f6e6f648c188872967.
---
 superset/connectors/sqla/models.py |  6 +-----
 superset/db_engine_specs/base.py   | 27 +++++++++++----------------
 superset/db_engine_specs/hive.py   |  2 --
 superset/db_engine_specs/presto.py |  2 --
 superset/models/core.py            |  2 --
 5 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 4930a30..deee43f 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -530,11 +530,7 @@ class SqlaTable(Model, BaseDatasource):
         # show_cols and latest_partition set to false to avoid
         # the expensive cost of inspecting the DB
         return self.database.select_star(
-            self.table_name,
-            sql=self.sql,
-            schema=self.schema,
-            show_cols=False,
-            latest_partition=False,
+            self.table_name, schema=self.schema, show_cols=False, latest_partition=False
         )
 
     @property
diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index 77d5aae..a1b31e5 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -611,7 +611,6 @@ class BaseEngineSpec:  # pylint: disable=too-many-public-methods
         database,
         table_name: str,
         engine: Engine,
-        sql: Optional[str] = None,
         schema: Optional[str] = None,
         limit: int = 100,
         show_cols: bool = False,
@@ -624,7 +623,6 @@ class BaseEngineSpec:  # pylint: disable=too-many-public-methods
 
         :param database: Database instance
         :param table_name: Table name
-        :param sql: SQL defining a subselect
         :param engine: SqlALchemy Engine instance
         :param schema: Schema
         :param limit: limit to impose on query
@@ -634,23 +632,20 @@ class BaseEngineSpec:  # pylint: disable=too-many-public-methods
         :param cols: Columns to include in query
         :return: SQL query
         """
+        fields = "*"
+        cols = cols or []
+        if (show_cols or latest_partition) and not cols:
+            cols = database.get_columns(table_name, schema)
+
+        if show_cols:
+            fields = cls._get_fields(cols)
         quote = engine.dialect.identifier_preparer.quote
         if schema:
             full_table_name = quote(schema) + "." + quote(table_name)
         else:
             full_table_name = quote(table_name)
 
-        if sql is not None:
-            subselect = f"(\n{sql}\n) AS {quote(table_name)}"
-            qry = select("*").select_from(text(subselect))
-        else:
-            fields = "*"
-            cols = cols or []
-            if (show_cols or latest_partition) and not cols:
-                cols = database.get_columns(table_name, schema)
-            if show_cols:
-                fields = cls._get_fields(cols)
-            qry = select(fields).select_from(text(full_table_name))
+        qry = select(fields).select_from(text(full_table_name))
 
         if limit:
             qry = qry.limit(limit)
@@ -660,10 +655,10 @@ class BaseEngineSpec:  # pylint: disable=too-many-public-methods
             )
             if partition_query is not None:
                 qry = partition_query
-        select_star_query = database.compile_sqla_query(qry)
+        sql = database.compile_sqla_query(qry)
         if indent:
-            select_star_query = sqlparse.format(select_star_query, reindent=True)
-        return select_star_query
+            sql = sqlparse.format(sql, reindent=True)
+        return sql
 
     @classmethod
     def estimate_statement_cost(
diff --git a/superset/db_engine_specs/hive.py b/superset/db_engine_specs/hive.py
index fd2c85d..7c680cb 100644
--- a/superset/db_engine_specs/hive.py
+++ b/superset/db_engine_specs/hive.py
@@ -354,7 +354,6 @@ class HiveEngineSpec(PrestoEngineSpec):
         database,
         table_name: str,
         engine: Engine,
-        sql: Optional[str] = None,
         schema: str = None,
         limit: int = 100,
         show_cols: bool = False,
@@ -368,7 +367,6 @@ class HiveEngineSpec(PrestoEngineSpec):
             database,
             table_name,
             engine,
-            sql,
             schema,
             limit,
             show_cols,
diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py
index 0cf48a3..2bfe255 100644
--- a/superset/db_engine_specs/presto.py
+++ b/superset/db_engine_specs/presto.py
@@ -394,7 +394,6 @@ class PrestoEngineSpec(BaseEngineSpec):
         database,
         table_name: str,
         engine: Engine,
-        sql: Optional[str] = None,
         schema: str = None,
         limit: int = 100,
         show_cols: bool = False,
@@ -418,7 +417,6 @@ class PrestoEngineSpec(BaseEngineSpec):
             database,
             table_name,
             engine,
-            sql,
             schema,
             limit,
             show_cols,
diff --git a/superset/models/core.py b/superset/models/core.py
index 5730add..d489e01 100755
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -383,7 +383,6 @@ class Database(
     def select_star(  # pylint: disable=too-many-arguments
         self,
         table_name: str,
-        sql: Optional[str] = None,
         schema: Optional[str] = None,
         limit: int = 100,
         show_cols: bool = False,
@@ -398,7 +397,6 @@ class Database(
         return self.db_engine_spec.select_star(
             self,
             table_name,
-            sql=sql,
             schema=schema,
             engine=eng,
             limit=limit,