Skip to content

Conversation

@BrianLii
Copy link
Contributor


Related Issue

related: #38195

Why

The default implementation of DbApiHook.get_uri does not conform to the standard Databricks connection format. Databricks typically uses token-based authentication (token:TOKEN) and expects the schema to be passed as a URL parameter, not directly in the path.

How

Override sqlalchemy_url property to follow the official Databricks SQLAlchemy URI format documented here:
https://docs.databricks.com/aws/en/dev-tools/sqlalchemy#authentication

Return the properly rendered SQLAlchemy URL in get_uri.

@boring-cyborg
Copy link

boring-cyborg bot commented Jul 12, 2025

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@BrianLii BrianLii force-pushed the issue-38195-databricks branch from 3c1f1be to 8272fc2 Compare July 12, 2025 03:38
@BrianLii BrianLii marked this pull request as ready for review July 12, 2025 17:25
@BrianLii BrianLii force-pushed the issue-38195-databricks branch from 2d1514b to eca4ae5 Compare July 13, 2025 17:17
Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for the PR and it LGTM overall

The conflict still need to be resolved, thanks.

@jason810496 jason810496 merged commit 8fb6116 into apache:main Jul 22, 2025
3 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 22, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@kacpermuda
Copy link
Contributor

I'm seeing a problem with OpenLineage extraction after that change when using DatabricksSqlOperator. OpenLineage is calling hook.get_sqlalchemy_engine() here, and it stopped working after this changes with error 'Connection' object has no attribute 'password'. The connection I have looks like databricks://@adb-XXX.10.azuredatabricks.net?token=XXX&http_path=/sql/1.0/warehouses/XXX. Is this a path you tested as well @BrianLii ? Will try to fix it, so appreciate any help.

@BrianLii
Copy link
Contributor Author

@kacpermuda Thanks for pointing that out. I found the issue: during testing, I mistakenly mocked get_conn to return an Airflow Connection, which allowed the incorrect sqlalchemy_url implementation to pass. I should be using self._get_token() (as get_conn does) to retrieve the tokens. I’m working on fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants