uranusjr commented on code in PR #47381:
URL: https://github.com/apache/airflow/pull/47381#discussion_r1986666742
##########
airflow/models/asset.py:
##########
@@ -96,6 +98,30 @@ def resolve_ref_to_asset(
return session.scalar(stmt)
+def resolve_assets_as_dag_dependencies(
+ *,
+ assets: list[Asset],
+ source: str,
+ target: str,
+ session: Session,
+) -> list[DagDependency]:
+ asset_id_names = session.scalars(
+ select(AssetModel.id, AssetAliasModel.name).where(
+ tuple_(AssetModel.name, AssetModel.uri).in_((asset.name,
asset.uri) for asset in assets)
+ )
+ ).all()
+ return [
+ DagDependency(
+ source=source,
+ target=target,
+ label=asset_name,
+ dependency_type="asset",
+ dependency_id=str(asset_id),
+ )
+ for (asset_id, asset_name) in asset_id_names
+ ]
Review Comment:
```suggestion
asset_id_names = session.execute(
select(AssetModel.id, AssetAliasModel.name).where(
tuple_(AssetModel.name, AssetModel.uri).in_((asset.name,
asset.uri) for asset in assets)
)
)
return [
DagDependency(
source=source,
target=target,
label=asset_name,
dependency_type="asset",
dependency_id=str(asset_id),
)
for (asset_id, asset_name) in asset_id_names
]
```
I don’t think using `scalars` here is correct since it only returns the
first column?
--
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]