Skip to content
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

AIP-83 Restore uniqueness constraint on logical date and make logical date nullable #46232

Conversation

vatsrahul1001
Copy link
Collaborator

@vatsrahul1001 vatsrahul1001 commented Jan 29, 2025

Closes: #46187


^ 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.

@vatsrahul1001 vatsrahul1001 marked this pull request as ready for review January 29, 2025 10:16
@vatsrahul1001 vatsrahul1001 marked this pull request as draft January 29, 2025 10:42
@vatsrahul1001
Copy link
Collaborator Author

Few tests are failing looking into it

@vatsrahul1001
Copy link
Collaborator Author

Failing test cases will require change in backfill reprocess behaviour, I have create PR which will fix these failing tests

@uranusjr
Copy link
Member

uranusjr commented Feb 3, 2025

What’s the order we should merge the two PRs? Tests are not passing on this one, but the other PR needs this to be merged first.

--

Edit: Talked to Rahul, this should be made greeen and go in first.

Comment on lines 1308 to 1315
or (
task.start_date is None
or (self.logical_date is not None and task.start_date <= self.logical_date)
)
and (
task.end_date is None
or (self.logical_date is not None and self.logical_date <= task.end_date)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
or (
task.start_date is None
or (self.logical_date is not None and task.start_date <= self.logical_date)
)
and (
task.end_date is None
or (self.logical_date is not None and self.logical_date <= task.end_date)
)
or (
task.start_date is None
or self.logical_date is None
or task.start_date <= self.logical_date
)
and (task.end_date is None or self.logical_date is None or self.logical_date <= task.end_date)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this "might" be the correct condition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this one is correct. Thanks @Lee-W

@vatsrahul1001
Copy link
Collaborator Author

vatsrahul1001 commented Feb 3, 2025

What’s the order we should merge the two PRs? Tests are not passing on this one, but the other PR needs this to be merged first.

--

Edit: Talked to Rahul, this should be made greeen and go in first.

@uranusjr Fixed failing tests now only failing tests are now related to backfill test_reprocess_behavior which are fixed in #46295 .

@vatsrahul1001 vatsrahul1001 requested a review from Lee-W February 3, 2025 12:45
@@ -49,10 +49,15 @@ def upgrade():
"execution_date",
new_column_name="logical_date",
existing_type=TIMESTAMP(timezone=True),
existing_nullable=False,
existing_nullable=True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
existing_nullable=True,
nullable=True,

existing_nullable is for specifying the nullable property we don’t want to change. Here we want to change nullability.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I Implemented this change.

@@ -63,7 +68,9 @@ def downgrade():
existing_type=TIMESTAMP(timezone=True),
existing_nullable=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
existing_nullable=False,
nullable=False,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I Implemented this change.

Comment on lines 1750 to 1751
if logical_date is not None:
logical_date = timezone.coerce_datetime(logical_date)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if logical_date is not None:
logical_date = timezone.coerce_datetime(logical_date)
logical_date = timezone.coerce_datetime(logical_date)

This function handles None on its own

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I Implemented this change.

Comment on lines -354 to 359
dr2 = dag_maker.create_dagrun_after(
dr,
next_date = DEFAULT_DATE + datetime.timedelta(days=1)
dr2 = dag_maker.create_dagrun(
run_id="test_dagrun_no_deadlock_2",
start_date=DEFAULT_DATE + datetime.timedelta(days=1),
logical_date=next_date,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this shouldn’t need to be changed. How does this fail originally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uranusjr When we pass the dr object to create_dagrun_after, it fails with a unique constraint error on the dag_run table. In dag_maker, we set logical_date to start_date if it's None here, and we are passing the same logical_date in create_dagrun_after due to which it fails.

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test is still failing 🤔 Please re-request for review once fixed. Thanks!

@vatsrahul1001
Copy link
Collaborator Author

@uranusjr Fixed failing tests now only failing tests are now related to backfill test_reprocess_behavior which are fixed in #46295 .

test is still failing 🤔 Please re-request for review once fixed. Thanks!

@Lee-W as mentioned here, failing tests are now related to backfill test_reprocess_behavior which are fixed in #46295 .

@vatsrahul1001 vatsrahul1001 requested a review from Lee-W February 4, 2025 06:34
@vatsrahul1001
Copy link
Collaborator Author

Discussed with @Lee-W as #46295 is based on this PR and have changes with CI green. Its better to close this PR in favour of #46295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AIP-83 Restore uniqueness constraint on logical date and make logical date nullable
3 participants