Lee-W commented on code in PR #41325:
URL: https://github.com/apache/airflow/pull/41325#discussion_r1827213326
##########
airflow/models/asset.py:
##########
@@ -37,8 +39,30 @@
from airflow.models.base import Base, StringID
from airflow.settings import json
from airflow.utils import timezone
+from airflow.utils.session import NEW_SESSION, provide_session
from airflow.utils.sqlalchemy import UtcDateTime
+if TYPE_CHECKING:
+ from typing import Sequence
+
+ from sqlalchemy.orm import Session
+
+
+@provide_session
+def _fetch_active_assets_by_name(
+ names: Sequence[str],
+ session: Session = NEW_SESSION,
+) -> dict[str, Asset]:
+ return {
+ asset_row[0]: Asset(name=asset_row[0], uri=asset_row[1],
group=asset_row[2], extra=asset_row[3])
+ for asset_row in session.execute(
+ select(AssetModel.name, AssetModel.uri, AssetModel.group,
AssetModel.extra)
+ .join(AssetActive, AssetActive.name == AssetModel.name)
+ .where(AssetActive.name.in_(name for name in names))
+ )
+ }
Review Comment:
Oh, I thought we didn't want to expose anything model-related and didn't
have this method, but it turns out we did have to_public. Thanks!
--
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]