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
|
# show_cols and latest_partition set to false to avoid
|
||||||
# the expensive cost of inspecting the DB
|
# the expensive cost of inspecting the DB
|
||||||
return self.database.select_star(
|
return self.database.select_star(
|
||||||
self.table_name,
|
self.table_name, schema=self.schema, show_cols=False, latest_partition=False
|
||||||
sql=self.sql,
|
|
||||||
schema=self.schema,
|
|
||||||
show_cols=False,
|
|
||||||
latest_partition=False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -611,7 +611,6 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
|||||||
database,
|
database,
|
||||||
table_name: str,
|
table_name: str,
|
||||||
engine: Engine,
|
engine: Engine,
|
||||||
sql: Optional[str] = None,
|
|
||||||
schema: Optional[str] = None,
|
schema: Optional[str] = None,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
show_cols: bool = False,
|
show_cols: bool = False,
|
||||||
@ -624,7 +623,6 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
|||||||
|
|
||||||
:param database: Database instance
|
:param database: Database instance
|
||||||
:param table_name: Table name
|
:param table_name: Table name
|
||||||
:param sql: SQL defining a subselect
|
|
||||||
:param engine: SqlALchemy Engine instance
|
:param engine: SqlALchemy Engine instance
|
||||||
:param schema: Schema
|
:param schema: Schema
|
||||||
:param limit: limit to impose on query
|
: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
|
:param cols: Columns to include in query
|
||||||
:return: SQL 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
|
quote = engine.dialect.identifier_preparer.quote
|
||||||
if schema:
|
if schema:
|
||||||
full_table_name = quote(schema) + "." + quote(table_name)
|
full_table_name = quote(schema) + "." + quote(table_name)
|
||||||
else:
|
else:
|
||||||
full_table_name = quote(table_name)
|
full_table_name = quote(table_name)
|
||||||
|
|
||||||
if sql is not None:
|
qry = select(fields).select_from(text(full_table_name))
|
||||||
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))
|
|
||||||
|
|
||||||
if limit:
|
if limit:
|
||||||
qry = qry.limit(limit)
|
qry = qry.limit(limit)
|
||||||
@ -660,10 +655,10 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
|||||||
)
|
)
|
||||||
if partition_query is not None:
|
if partition_query is not None:
|
||||||
qry = partition_query
|
qry = partition_query
|
||||||
select_star_query = database.compile_sqla_query(qry)
|
sql = database.compile_sqla_query(qry)
|
||||||
if indent:
|
if indent:
|
||||||
select_star_query = sqlparse.format(select_star_query, reindent=True)
|
sql = sqlparse.format(sql, reindent=True)
|
||||||
return select_star_query
|
return sql
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def estimate_statement_cost(
|
def estimate_statement_cost(
|
||||||
|
@ -354,7 +354,6 @@ class HiveEngineSpec(PrestoEngineSpec):
|
|||||||
database,
|
database,
|
||||||
table_name: str,
|
table_name: str,
|
||||||
engine: Engine,
|
engine: Engine,
|
||||||
sql: Optional[str] = None,
|
|
||||||
schema: str = None,
|
schema: str = None,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
show_cols: bool = False,
|
show_cols: bool = False,
|
||||||
@ -368,7 +367,6 @@ class HiveEngineSpec(PrestoEngineSpec):
|
|||||||
database,
|
database,
|
||||||
table_name,
|
table_name,
|
||||||
engine,
|
engine,
|
||||||
sql,
|
|
||||||
schema,
|
schema,
|
||||||
limit,
|
limit,
|
||||||
show_cols,
|
show_cols,
|
||||||
|
@ -394,7 +394,6 @@ class PrestoEngineSpec(BaseEngineSpec):
|
|||||||
database,
|
database,
|
||||||
table_name: str,
|
table_name: str,
|
||||||
engine: Engine,
|
engine: Engine,
|
||||||
sql: Optional[str] = None,
|
|
||||||
schema: str = None,
|
schema: str = None,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
show_cols: bool = False,
|
show_cols: bool = False,
|
||||||
@ -418,7 +417,6 @@ class PrestoEngineSpec(BaseEngineSpec):
|
|||||||
database,
|
database,
|
||||||
table_name,
|
table_name,
|
||||||
engine,
|
engine,
|
||||||
sql,
|
|
||||||
schema,
|
schema,
|
||||||
limit,
|
limit,
|
||||||
show_cols,
|
show_cols,
|
||||||
|
@ -383,7 +383,6 @@ class Database(
|
|||||||
def select_star( # pylint: disable=too-many-arguments
|
def select_star( # pylint: disable=too-many-arguments
|
||||||
self,
|
self,
|
||||||
table_name: str,
|
table_name: str,
|
||||||
sql: Optional[str] = None,
|
|
||||||
schema: Optional[str] = None,
|
schema: Optional[str] = None,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
show_cols: bool = False,
|
show_cols: bool = False,
|
||||||
@ -398,7 +397,6 @@ class Database(
|
|||||||
return self.db_engine_spec.select_star(
|
return self.db_engine_spec.select_star(
|
||||||
self,
|
self,
|
||||||
table_name,
|
table_name,
|
||||||
sql=sql,
|
|
||||||
schema=schema,
|
schema=schema,
|
||||||
engine=eng,
|
engine=eng,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
|
Loading…
Reference in New Issue
Block a user