This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 0668d12e3b chore(trino): remove unnecessary index checks (#25211)
0668d12e3b is described below
commit 0668d12e3baf1eb74481f0349f9d2552422f54d8
Author: Ville Brofeldt <[email protected]>
AuthorDate: Fri Sep 8 18:15:45 2023 -0700
chore(trino): remove unnecessary index checks (#25211)
---
superset/db_engine_specs/presto.py | 10 +++++++---
superset/db_engine_specs/trino.py | 6 +++++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/superset/db_engine_specs/presto.py
b/superset/db_engine_specs/presto.py
index c05865b871..dfb82877a6 100644
--- a/superset/db_engine_specs/presto.py
+++ b/superset/db_engine_specs/presto.py
@@ -527,12 +527,13 @@ class PrestoBaseEngineSpec(BaseEngineSpec,
metaclass=ABCMeta):
@classmethod
@cache_manager.data_cache.memoize(timeout=60)
- def latest_partition(
+ def latest_partition( # pylint: disable=too-many-arguments
cls,
table_name: str,
schema: str | None,
database: Database,
show_first: bool = False,
+ indexes: list[dict[str, Any]] | None = None,
) -> tuple[list[str], list[str] | None]:
"""Returns col name and the latest (max) partition value for a table
@@ -542,12 +543,15 @@ class PrestoBaseEngineSpec(BaseEngineSpec,
metaclass=ABCMeta):
:type database: models.Database
:param show_first: displays the value for the first partitioning key
if there are many partitioning keys
+ :param indexes: indexes from the database
:type show_first: bool
>>> latest_partition('foo_table')
(['ds'], ('2018-01-01',))
"""
- indexes = database.get_indexes(table_name, schema)
+ if indexes is None:
+ indexes = database.get_indexes(table_name, schema)
+
if not indexes:
raise SupersetTemplateException(
f"Error getting partition for {schema}.{table_name}. "
@@ -1221,7 +1225,7 @@ class PrestoEngineSpec(PrestoBaseEngineSpec):
if indexes := database.get_indexes(table_name, schema_name):
col_names, latest_parts = cls.latest_partition(
- table_name, schema_name, database, show_first=True
+ table_name, schema_name, database, show_first=True,
indexes=indexes
)
if not latest_parts:
diff --git a/superset/db_engine_specs/trino.py
b/superset/db_engine_specs/trino.py
index cc8e531dc2..425137e302 100644
--- a/superset/db_engine_specs/trino.py
+++ b/superset/db_engine_specs/trino.py
@@ -60,7 +60,11 @@ class TrinoEngineSpec(PrestoBaseEngineSpec):
if indexes := database.get_indexes(table_name, schema_name):
col_names, latest_parts = cls.latest_partition(
- table_name, schema_name, database, show_first=True
+ table_name,
+ schema_name,
+ database,
+ show_first=True,
+ indexes=indexes,
)
if not latest_parts: