Skip to content

Conversation

@potiuk
Copy link
Member

@potiuk potiuk commented Nov 29, 2022

The change #27912 fixed and unified behaviour of DBApiHooks across the board, but it missed two places where sql was mis-used and overridden in exasol and snowflake hooks.

The check for "sql" type did not use the original sql parameter value but the one that was overridden later in the run method implementation.

The fix is the same as applied in Databricks Hook and DBAPI generic run methods - using consistent typing and separate variable to convert the sql string into sql list.

Related: astronomer/astro-sdk#1324


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

The change apache#27912 fixed and unified behaviour of DBApiHooks
across the board, but it missed two places where sql was mis-used
and overridden in exasol and snowflake hooks.

The check for "sql" type did not use the original sql parameter
value but the one that was overridden later in the run method
implementation.

The fix is the same as applied in Databricks Hook and DBAPI
generic run methods - using consistent typing and separate
variable to convert the sql string into sql list.

Related: astronomer/astro-sdk#1324
if isinstance(sql, str):
if split_statements:
sql = self.split_sql_string(sql)
sql_list: Iterable[str] = self.split_sql_string(sql)
Copy link
Member Author

Choose a reason for hiding this comment

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

The root cause of the problem is line https://github.com/apache/airflow/pull/27997/files#diff-00b215634013629b320a263630bf6948ed33c2a8528754fc78d69484e1320845R191

thesql parameter changed it type - when it was passed as "string", it was always converted to list and that caused the return to be wrapped in list as well. So when sql was used in return_single_query_results, it was already a list and return_single_query_resuts is always false when you pass list of queries.

@potiuk
Copy link
Member Author

potiuk commented Nov 29, 2022

@kazanzhy @denimalpaca -> this was the problem I introduced when fixing common.sql for 1.3.1 . Still looking for what caused the #27978 and #27976.

@potiuk potiuk merged commit 2e7a4bc into apache:main Nov 30, 2022
@potiuk potiuk deleted the fix-exasol-snowflake-hook-return-last-behaviour branch November 30, 2022 01:13
jrggggg pushed a commit to jrggggg/airflow that referenced this pull request Dec 1, 2022
…pache#27997)

The change apache#27912 fixed and unified behaviour of DBApiHooks
across the board, but it missed two places where sql was mis-used
and overridden in exasol and snowflake hooks.

The check for "sql" type did not use the original sql parameter
value but the one that was overridden later in the run method
implementation.

The fix is the same as applied in Databricks Hook and DBAPI
generic run methods - using consistent typing and separate
variable to convert the sql string into sql list.

Related: astronomer/astro-sdk#1324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:snowflake Issues related to Snowflake provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants