apache / apache/airflow

Add `run_if`/`skip_if` functionality to non-TaskFlow operators

Open
#44,205 4 comments 0 reactions 0 assignees View on GitHub
kind:feature needs-triage
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 10h
Merged PRs (30d)
483

Description

### Description

Currently, the useful `run_if` and `skip_if` decorators can only be added to tasks that are decorated by the `@task` decorator, aka TaskFlow compatible operators. However, many common operators are not compatible with TaskFlow API, e.g. the `SqlExecuteQueryOperator`. If you try, you will be met with:

```
skip_if can only be used with task. decorate with @task before @skip_if.
```

This request is for `run_if` and `skip_if` to be added to all operators, not just TaskFlow compatible ones.

### Use case/motivation

I want to use `run_if` and `skip_if` for an operator that isn't TaskFlow compatible.

### Related issues

There is a similar issue that I didn't bookmark to make `@task` decorator apply to classes (aka Operators), not just functions. Depending on how that's implemented, it could solve this issue.

### Are you willing to submit a PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Research direction

Start by examining the existing run_if and skip_if decorators and how SqlExecuteQueryOperator is handled, then compare that path with @task-decorated operators. Done means both conditional features work for non-TaskFlow operators, including the stated use case, without requiring @task.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, data-engineering
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.