Skip to content

Conversation

@Rhiyo
Copy link

@Rhiyo Rhiyo commented Mar 11, 2025

Only had access to databricks via oauth so needed to implement more connection methods.

Based on the official databricks sql connector docs: https://docs.databricks.com/aws/en/dev-tools/python-sql-connector

Solves the issue: #2087

This adds no new properties but the databricks connection will now make use of auth_method and configuration dict properties.

Token authentication:
If supplying token will work as normal and use personal access token authentication.

user to machine oauth
If supplying auth_method and setting it to "databricks-oauth" will be u2m authentication

machine to machine oauth
If neither the above are supplied it will work with the docs m2m authentication method. This configuration property gets supplied to the config class in which the user can supply the host/client_id/client_secret.

I tried to set this up in a way that enables flexability. The config class has a very large amount of options so if a more tech savvy user wants to change these settings they are not blocked from doing so and can supply them to the configuration property.

The oauth_type also has an azure oauth method that can be switched to instead.

If neither oauth_method or token are supplied, and configuration is empty, it will still use the empty Config object. This can be beneficial as the config class, if not supplied a parameter value, will look for environment variables instead. See the source code.

A caveat of how this is configured is that the if using m2m you will probably need to input host twice. once outside configuration and once inside. A way of resolving this is if host isn't set as a property, it will try and get the hostname from the instantiated config object and set it as that instead. This mean host comes from config meaning it can be from the environment variable or configuration property and doesn't have to be supplied twice.

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2025

CLA assistant check
All committers have signed the CLA.

@sonarqubecloud
Copy link

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants