pierrejeambrun commented on code in PR #49994:
URL: https://github.com/apache/airflow/pull/49994#discussion_r2068583738
##########
airflow-core/src/airflow/models/asset.py:
##########
@@ -276,6 +276,19 @@ class AssetModel(Base):
producing_tasks = relationship("TaskOutletAssetReference",
back_populates="asset")
triggers = relationship("Trigger",
secondary=asset_trigger_association_table, back_populates="assets")
+ # ForeignKey("asset_event.id") -> this was originally in the
last_asset_event_id definition
+ # The default value should be None. When an Asset is defined, it is not
yet tied to an AssetEvent
+ last_asset_event_id = Column(Integer, default=None)
+ last_asset_event_timestamp = Column(UtcDateTime, default=None)
+
+ last_event = relationship(
+ "AssetEvent",
+ primaryjoin="AssetModel.last_asset_event_id == foreign(AssetEvent.id)",
+ viewonly=True,
+ lazy="select",
+ uselist=False,
+ )
Review Comment:
Do we really need to update the db schema ? (You'll need a migration too if
you do that).
I would recommend just fetching the related asset event information with a
subquery or CTE at query time in the endpoint directly, that will save you a
lot of effort.
--
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]