nicob3y commented on code in PR #35662:
URL: https://github.com/apache/superset/pull/35662#discussion_r4204315462
##########
superset/daos/dataset.py:
##########
@@ -676,24 +677,45 @@ def get_table_by_name(database_id: int, table_name: str)
-> SqlaTable | None:
@staticmethod
def get_table_by_catalog_schema_and_name(
- database_id: int,
- schema: str | None,
table_name: str,
- catalog: str | None = None,
+ database_id: int | str | _Unset = _UNSET,
+ schema: str | _Unset | None = _UNSET,
+ catalog: str | _Unset | None = _UNSET,
+ skip_base_filter: bool = False,
) -> SqlaTable | None:
- # Filter by the full ``(database_id, catalog, schema, table_name)``
- # uniqueness key so callers can disambiguate datasets that share a
- # ``table_name`` across schemas or catalogs (#30377).
- return (
- db.session.query(SqlaTable)
- .filter_by(
- database_id=database_id,
- catalog=catalog,
- schema=schema,
- table_name=table_name,
+ # Filter by ``table_name`` and any additional identification attributes
+ # provided (``database_id``, ``catalog``, ``schema``). The full
+ # ``(database_id, catalog, schema, table_name)`` uniqueness key can be
used
+ # to disambiguate datasets sharing the same ``table_name`` (#30377),
while
+ # partial criteria may match multiple datasets (#35662).
+ query = db.session.query(SqlaTable).filter(SqlaTable.table_name ==
table_name)
+
+ if not skip_base_filter:
+ query = DatasetDAO._apply_base_filter(query)
+
+ if database_id is not _UNSET:
+ if isinstance(database_id, int):
+ query = query.filter(SqlaTable.database_id == database_id)
+ else:
+ query = query.join(Database).filter(
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]