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
Fix mismatch in generated run_id and logical date of DAG run #18707
Fix mismatch in generated run_id and logical date of DAG run #18707
Conversation
When execution_date is None, the generated name for the run_id contains the execution_date in isoformat. This fixes a mismatch between the execution_date in run_id and the actual execution_date of the dag run.
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.
LGTM. We should have a test case preventing future regression. I suspect the current test only covers cases where isinstance(self.execution_date, datetime.datetime)
is True and thus never detect the bug.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
This also allows us to remove the Mypy override in the operator's __init__ since we now allow the type to be str in the first place, and the local variable has the correct type.
I added a couple of checks to existing tests to ensure the run ID is generated consistently. I also expanded the refactoring a little to strighten up the type of |
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease. |
Two checks are added to the TriggerDagRunOperator to ensure the operator always generates a run_id (if not explicitly specified) from the same date as execution_date, for consistency.
tests seem to fail :( |
I merged main and removed the full-test-needed label, this should help us see where test failures are from. |
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease. |
I just merged main and the mssql failures are also happening in main. Still, I'm going to wait on merging this just to be safe. |
Hmm, looks like MSSQL has some issues with datetime values added in this PR. |
Looks good now! |
Co-authored-by: Tzu-ping Chung <tp@astronomer.io> Co-authored-by: Jed Cunningham <jedcunningham@apache.org> (cherry picked from commit 1f08d28)
Co-authored-by: Tzu-ping Chung <tp@astronomer.io> Co-authored-by: Jed Cunningham <jedcunningham@apache.org> (cherry picked from commit 1f08d28)
Co-authored-by: Tzu-ping Chung <tp@astronomer.io> Co-authored-by: Jed Cunningham <jedcunningham@apache.org> (cherry picked from commit 1f08d28)
When execution_date is
None
, the generated name for therun_id
contains the a generatedexecution_date
in isoformat.That
execution_date
should be passed totrigger_dag
, otherwise we have a mismatch between theexecution_date
inrun_id
and the actualexecution_date
of the dag run.This didn't cause any issues per se, but I thought it should be fixed for consistency.