Credentials
DirectQuery passes both the connection string parameters and the explicitly set JDBC properties to the Databricks JDBC driverDataSource. An explicitly set property takes precedence over a connection string parameter of the same name.
How to authenticate with OAuth machine-to-machine
OAuth machine-to-machine is the recommended authentication type for a self-hosted Atoti Server. A Databricks service principal authenticates with a client ID and a client secret. The driver obtains and renews access tokens by itself. No operator action is needed for the lifetime of a long-running server. SetAuthMech=11, Auth_Flow=1 and OAuth2ClientId in the connection string:
How to authenticate with a service principal private key
This type replaces the shared client secret with a private key held by the service principal. AddUseJWTAssertion=1 to
the OAuth machine-to-machine parameters. The driver then signs a
JWT assertion with the key. Access tokens are still renewed by the driver itself.
These parameters describe the key:
Auth_JWT_Key_File: path to the private key file.Auth_KID: key identifier.Auth_JWT_Alg: signing algorithm. Defaults toRS256.Auth_JWT_Key_Passphrase: passphrase, when the key file is encrypted.
Auth_Scope=sql as well, because the driver sends no scope of its own on this type.
On Azure, a connection that sets
AzureTenantId uses the Azure service principal type instead, which ignores
UseJWTAssertion.How to authenticate with an Azure managed identity
An Atoti Server running on Azure compute can authenticate to an Azure Databricks workspace with an Azure managed identity. This type is only available on Azure. No secret has to be stored in the Atoti Server configuration. Access tokens are renewed by the driver itself. SetAuthMech=11 and Auth_Flow=3, together with azure_workspace_resource_id, which the driver requires for this
type. For a user-assigned managed identity, add OAuth2ClientId to select which identity to use.
How to authenticate with a personal access token
A Databricks personal access token is the quickest type to set up. SetAuthMech=3 and UID=token in the connection
string:
PWD property, available as DatabricksConnectionProperties.PASSWORD_PROPERTY_KEY:
How to authenticate with browser-based OAuth
Browser-based OAuth usesAuthMech=11 with Auth_Flow=2. It requires a person to sign in through a browser.
It is therefore unsuitable for a server deployment. Use it for local development and exploration only.
The driver caches the resulting token on disk by default, and refuses to connect until that cache is configured.
Either set TokenCachePassPhrase, which encrypts the cache, or turn the cache off with EnableTokenCache=0.
How does Databricks token federation apply?
Token federation is not an authentication type. It is a layer that the driver applies on top of the configured authentication type. Token federation is enabled by default, because the driver’sEnableTokenFederation parameter defaults to 1.
When the workspace is set up for
OAuth token federation, the driver exchanges the
token for a workspace token automatically. The Identity_Federation_Client_Id parameter names the OAuth application
used for the exchange.
No extra configuration is needed. Configure OAuth machine-to-machine as described in How to authenticate with OAuth
machine-to-machine, and token federation applies on top of it. The
exchange only takes place when the token was issued by a provider other than the Databricks workspace itself.
Permissions
The user or service principal used by DirectQuery needs read access to the queried data, granted through Unity Catalog. The minimum privileges are:USE CATALOGon the target catalogUSE SCHEMAon the target schemaSELECTon the queried tables and views
CREATE TABLE and INSERT INTO statements but never executes them: they are run separately, under whichever Databricks
identity is chosen for that purpose.
How to create the service principal and OAuth application
- Create a service principal in the Databricks account console. See Manage service principals.
- Grant the service principal
USE CATALOG,USE SCHEMA, andSELECTon the target catalog, schema, and tables. See Manage privileges in Unity Catalog. - Create an OAuth secret for the service principal. This step yields the client ID and the client secret. See Authorize service principal access to Databricks with OAuth.
- Supply the client ID as
OAuth2ClientIdand the client secret asOAuth2Secret, as described in How to authenticate with OAuth machine-to-machine.
CAN USE permission on
the target SQL warehouse or cluster.
See SQL warehouse ACLs.
The compute types and the Databricks runtime versions that DirectQuery supports are listed in the
compatibility matrix.