Skip to content

Commit

Permalink
Fix output property missing for airflow version < 2.4.0 (#1385)
Browse files Browse the repository at this point in the history
# Description
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
The output was implemented in 2.4.0 according to the release notes (see
[here](https://airflow.apache.org/docs/apache-airflow/stable/release_notes.html#id13))

Add output property to MappedOperator
apache/airflow#25604

<!--
Issues are required for both bug fixes and features.
Reference it using one of the following:

closes: #ISSUE
related: #ISSUE
-->
closes: #1359

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Catch exception for airflow version < 2.4.0 and use `XComArg(...)`
instead.

## Does this introduce a breaking change?
No

### Checklist
- [x] Created tests which fail without the change (if possible)
- [x] Extended the README / documentation, if necessary

Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 0f5ff62)
  • Loading branch information
sunank200 authored and kaxil committed Dec 13, 2022
1 parent 621fa5b commit 2d4bc37
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python-sdk/src/astro/sql/operators/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ def resolve_tables_from_tasks( # noqa: C901
and isinstance(task, MappedOperator)
and issubclass(task.operator_class, OPERATOR_CLASSES_WITH_TABLE_OUTPUT)
):
for t in task.output.resolve(context):
from airflow.models.xcom_arg import XComArg

try:
task_output = task.output
except AttributeError:
task_output = XComArg(operator=task)

for t in task_output.resolve(context):
if isinstance(t, BaseTable):
res.append(t)
except AirflowException: # pragma: no cover
Expand Down

0 comments on commit 2d4bc37

Please sign in to comment.