Skip to content

DatabricksSqlHook fails to run related queries #31898

Description

@dimonchik-suvorov

Apache Airflow version

main (development)

What happened

After refactoring DatabricksSqlHook lost it's ability to run multiple queries in one Airflow connection (basically same Spark Session). Now it doesn't care what the smart get_conn returns and simply creates new connection for each query in the queries list. It is wrong and breaks logic like:

USE your_database;
select from table_in_your_database;

In this case it will create first connection and as consequence Databricks session, runs USE your_database statement, then recreate connection/session which doesn't know anything about first query and runs select from table_in_your_database statement and obviously it fails because second session doesn't know anything about first query...
image

This is a breaking change and cost us some time to understand what went wrong after our upgrade from 2.2.0 to 2.5.3

What you think should happen instead

smart get_conn functions should decide when to create new connection and when not to. Otherwise why do we need so complex logic there?

How to reproduce

Try to send (using DatabricksSqlHook) to the Databricks Warehouse a string with two queries:

USE your_database;
select from table_in_your_database;

Operating System

Debian GNU/Linux 11 (bullseye)

Versions of Apache Airflow Providers

databricks 3.4.0

Deployment

Other Docker-based deployment

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions