-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Introducing Logical Operators for dataset conditional logic #37101
Introducing Logical Operators for dataset conditional logic #37101
Conversation
b4ca8da
to
ee9de54
Compare
ee9de54
to
5189828
Compare
c6ce4c7
to
caca0f0
Compare
e95321c
to
e64450f
Compare
ef19e0f
to
fedc169
Compare
As #37016 has been merged, I think we might need to rebase from the main branch and resolve the conflicts before we can review it. |
2440c8c
to
428087e
Compare
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
f441e90
to
6b2fdab
Compare
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 added a commit to put __and__
and __or__
in the base class instead, and add comment on the optimized __and__
and __or__
for clarity to avoid future readers needing to ask #37101 (comment) again.
…7101) * Implement | and & operators so that they can be used instead of DatasetAll and DatasetAny * Refactor dataset class inheritance (apache#37590) * Refactor DatasetAll and DatasetAny inheritance They are moved from airflow.models.datasets to airflow.datasets since the intention is to use them with Dataset, not DatasetModel. It is more natural for users to import from the latter module instead. A new (abstract) base class is added for the two classes, plus the OG Dataset class, to inherit from. This allows us to replace a few isinstance checks with simple molymorphism and make the logic a bit simpler. Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> Co-authored-by: Wei Lee <weilee.rx@gmail.com> Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
…7101) * Implement | and & operators so that they can be used instead of DatasetAll and DatasetAny * Refactor dataset class inheritance (apache#37590) * Refactor DatasetAll and DatasetAny inheritance They are moved from airflow.models.datasets to airflow.datasets since the intention is to use them with Dataset, not DatasetModel. It is more natural for users to import from the latter module instead. A new (abstract) base class is added for the two classes, plus the OG Dataset class, to inherit from. This allows us to replace a few isinstance checks with simple molymorphism and make the logic a bit simpler. Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> Co-authored-by: Wei Lee <weilee.rx@gmail.com> Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
We've expanded the dataset dependency handling in Airflow, building on PR #37016. This PR introduces the use of logical operators (
|
for OR and&
for AND) to linkDataset
instances, simplifying the expression of complex dependencies.Key Enhancements:
|
and&
for combiningDataset
objects.Dataset
class.DatasetAny
andDatasetAll
classes for OR/AND conditions.DatasetsExpression
class for building dataset condition trees.extract_datasets
function to interpret these expression trees.Example:
This update offers a more intuitive way of expressing dataset dependencies in Airflow workflows.
Depends on the merge of PR #37016.
Dependency Checklist
^ 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.