jroachgolf84 commented on code in PR #50060:
URL: https://github.com/apache/airflow/pull/50060#discussion_r2070629200
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -135,20 +135,55 @@ def get_assets(
session: SessionDep,
) -> AssetCollectionResponse:
"""Get assets."""
+ # First, we're pulling the Asset ID, AssetEvent ID, and AssetEvent
timestamp for the latest (last)
+ # AssetEvent. We'll eventually OUTER JOIN this to the AssetModel
+ asset_event_query = (
+ select(
+ AssetEvent.asset_id, # The ID of the Asset, which we'll need to
JOIN to the AssetModel
+ func.max(AssetEvent.id).label("last_asset_event_id"), # The ID of
the last AssetEvent
+ func.max(AssetEvent.timestamp).label("last_asset_event_timestamp"),
+ )
+ .group_by(AssetEvent.asset_id)
+ .subquery()
Review Comment:
Can you clarify that a bit more? Is the thought here that the max
`AssetEvent.id` might not have the latest timestamp?
There is a unit-test validating this - would you just approach this with a
self-JOIN?
--
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]