Open thesuperzapper opened 3 days ago
Hello @thesuperzapper,
I have made some changes to the RedshiftDataOperator to address the issue with handling multiple SQL statements. Please review my pull request https://github.com/apache/airflow/pull/40443 and let me know if my approach is correct.
Apache Airflow Provider(s)
amazon
Versions of Apache Airflow Providers
Affects all current versions of
apache-airflow-providers-amazon
, including8.24.0
Apache Airflow version
N/A - all versions
Operating System
NA
Deployment
Other
Deployment details
No response
What happened
There is a bug in
RedshiftDataOperator
if multiplesql
queries are passed, andreturn_sql_result
is set totrue
, then you will get the following error:What you think should happen instead
No response
How to reproduce
Run a
RedshiftDataOperator
like this:Anything else
To fix this we will need to record the length of
sql
list, and loop throughget_statement_result
for each sub-statement id because you can only get one statement result at a time.For example, if there are three, you would get the results of the following queries, starting from
:1
:d9b6c0c9-0747-4bf4-b142-e8883122f766:1
d9b6c0c9-0747-4bf4-b142-e8883122f766:2
d9b6c0c9-0747-4bf4-b142-e8883122f766:3
There are TWO difference places where we call
get_statement_result
that need to be updated:execute()
:execute_complete()
__yield TriggerEvent(
responseAre you willing to submit PR?
Code of Conduct