-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datasets, next_run_datasets, remove unnecessary timestamp filter #29441
datasets, next_run_datasets, remove unnecessary timestamp filter #29441
Conversation
@@ -3715,7 +3715,6 @@ def next_run_datasets(self, dag_id): | |||
DatasetEvent, | |||
and_( | |||
DatasetEvent.dataset_id == DatasetModel.id, | |||
DatasetEvent.timestamp > DatasetDagRunQueue.created_at, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬 It's been a long minute since I wrote this, but...
I believe when I wrote this the intent with the lastUpdate
field was to only show last updates since the last time the dag was queued/run. But yeah, the lastUpdate
label isn't descriptive enough for that.
Option 1: Personally, I would consider changing the name of what the lastUpdate
field is rendered to, something like "Last update since last run" or something more wordy.
Option 2: But if you don't want to do that, and you want to display the last update for every dataset regardless of whether has already been "consumed" by a DagRun (eg: in either the DatasetDagRunQueue or actually scheduled into a DagRun), then yeah it makes sense to remove this filter. However, I would also remove the and_
around it since then there would only be one filter condition in that join:
.join(
DatasetEvent,
DatasetEvent.dataset_id == DatasetModel.id,
isouter=True,
)
If you go for option 2, I think you should be able to compare the existence and creation time of the DDRQ with the DatasetEvent timestamp to figure out whether or not the last update time has already triggered a DDRQ/DagRun or if it has partially satisfied the conditions of a future DagRun.
Hope this makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I would also remove the and_ around it since then there would only be one filter condition in that join:
Yes, you're right the and
becomes unnecessary.
I think there might be some confusion around DDRQ. My understanding is that when a DatasetEvent
is created, a DDRQ record is created per consuming DAG. Then, once a DAG has an associated DDRQ record for each Dataset
that it depends on, a dag_run is created and then all DDRQ records associated with that DAG are deleted.
If you go for option 2, I think you should be able to compare the existence and creation time of the DDRQ with the DatasetEvent timestamp to figure out whether or not the last update time has already triggered a DDRQ/DagRun or if it has partially satisfied the conditions of a future DagRun.
As I understand it, if there are DDRQ records for a DAG, we can assume that there hasn't been a DagRun triggered since the last DatasetEvent (because we delete DDRQ records on the creation of a DagRun).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blag Does that make sense to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just dug through the code in more detail, and yes, your understanding seems to be correct. 😄
@ephraimbuddy @ashb Is this good to merge? |
@potiuk is this good to merge? |
) * datasets, next_run_datasets, remove unnecessary timestamp filter * remove redundant `_and` (cherry picked from commit 6f9efbd)
) * datasets, next_run_datasets, remove unnecessary timestamp filter * remove redundant `_and` (cherry picked from commit 6f9efbd)
Closes: #26892
I'm not sure what the intention of this filter was:
DatasetEvent.timestamp > DatasetDagRunQueue.created_at
When a dataset is updated,
DatasetEvent
is created (and saved)DatasetDagRunQueue
row is added for each dependant DAG.I don't think we need this filter, and have confirmed that it prevents the last update from being shown.
By removing this filter, it resolves #26892
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.