mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
This reverts commit 964e6db8
This commit is contained in:
parent
2726f21cbc
commit
93bcace20f
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user