dstandish commented on code in PR #44456:
URL: https://github.com/apache/airflow/pull/44456#discussion_r1876228520


##########
airflow/dag_processing/collection.py:
##########
@@ -435,14 +456,17 @@ def add_asset_trigger_references(
         refs_to_add: dict[tuple[str, str], set[str]] = {}
         refs_to_remove: dict[tuple[str, str], set[str]] = {}
         triggers: dict[str, BaseTrigger] = {}
+        active_assets = _find_active_assets(self.assets.keys(), 
session=session)

Review Comment:
   after refactoring like this
   ```
       return {
           (asset_model.name, asset_model.uri)
           for asset_model in _get_assets(session, name_uri_assets, active_dags)
       }
   
   
   def _get_assets(session, name_uri_assets: Iterable[tuple[str, str]], 
active_dags: Iterable[str]):
       return session.scalars(
           select(AssetModel)
           .join(
               AssetActive,
               and_(
                   AssetActive.name == AssetModel.name,
                   AssetActive.uri == AssetModel.uri,
               ),
           )
           .where(
               tuple_(AssetActive.name, AssetActive.uri).in_(name_uri_assets),
               
AssetModel.consuming_dags.any(DagScheduleAssetReference.dag_id.in_(active_dags)),
           )
           .options(
               
joinedload(AssetModel.consuming_dags).joinedload(DagScheduleAssetReference.dag),
           )
       )
   
   ```
   
   SO -- hopefully I have helped enable you to look into whether there's an 
optimal way to query, but i will go back to my day job until summoned again



-- 
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]

Reply via email to