Integrating with Databricks Unity Catalog
You can bring metadata from a Databricks Unity Catalog into the AWS Glue Data Catalog and query the synced assets from your analytics engines. You create a Databricks connection, register it with Lake Formation, create a top-level catalog on the connection, and turn on sync. This topic uses the AWS CLI. For an overview of external catalog integration, see Integrating with external catalogs.
In the examples, replace each value with your own value. Use
for your 12-digit AWS account ID and
account-id for the AWS Region of the catalog.region
Create the connection
A Databricks connection is an AWS Glue connection of type DATABRICKS. It
authenticates with OAuth 2.0 and the client credentials grant. You store the OAuth
client secret in an AWS Secrets Manager secret and give the connection the secret ARN, so the
connection holds no inline credentials.
-
Create an Secrets Manager secret that holds the Databricks OAuth client secret. Save the following to a file named
secret.json.{ "USER_MANAGED_CLIENT_APPLICATION_CLIENT_SECRET": "client-secret" }Create the secret and note the secret ARN from the response.
aws secretsmanager create-secret \ --namedatabricks-secret-name\ --secret-string file://secret.jsonThe connector adds an
ACCESS_TOKENvalue to the same secret and refreshes it. You don't addACCESS_TOKENyourself. -
Save the connection definition to a file named
connection.json. TheINSTANCE_URLis your Databricks workspace URL, andWAREHOUSE_IDis the ID of a Databricks SQL warehouse. TheTokenUrlis your workspace token endpoint, andUserManagedClientApplicationClientIdis the client ID of your Databricks OAuth client. Thescopedefaults toall-apis.{ "CatalogId": "account-id", "ConnectionInput": { "Name": "connection-name", "ConnectionType": "DATABRICKS", "ConnectionProperties": { "INSTANCE_URL": "https://workspace.cloud.databricks.com", "WAREHOUSE_ID": "warehouse-id" }, "AuthenticationConfiguration": { "AuthenticationType": "OAUTH2", "SecretArn": "secret-arn", "OAuth2Properties": { "OAuth2GrantType": "CLIENT_CREDENTIALS", "OAuth2ClientApplication": { "UserManagedClientApplicationClientId": "client-id" }, "TokenUrl": "https://workspace.cloud.databricks.com/oidc/v1/token", "TokenUrlParametersMap": { "scope": "all-apis" } } } } }Create the connection and note the connection ARN for the next steps.
aws glue create-connection --cli-input-json file://connection.json
Add a ROLE_ARN property to the connection only when the connection
reaches Databricks through a virtual private cloud (VPC). For instructions on setting up a VPC
connection, see Connecting to data.
Set up discovery and asset cataloging
After the connection exists, register it with Lake Formation, create a top-level catalog on it, and turn on sync. A managed crawler then reads metadata from Databricks and writes it to the Data Catalog as synced assets. Follow the steps in order.
-
Register the connection with Lake Formation for federation. You must register the connection before you can create a catalog on it. If you skip this step,
create-catalogfails with the errorThe data source [Save the following to a file namedconnection-arn] is not registered.register.json.{ "ResourceArn": "connection-arn", "RoleArn": "credential-vending-role-arn", "UseServiceLinkedRole": false, "WithFederation": true, "WithPrivilegedAccess": true }aws lakeformation register-resource --cli-input-json file://register.json -
Create the top-level catalog on the connection. You create one top-level catalog for each connection. The Databricks catalogs appear as child catalogs under it. Set
ConnectionNameandConnectionType, and always sendCreateTableDefaultPermissionsandCreateDatabaseDefaultPermissionsas empty lists. Save the following to a file namedcatalog.json.{ "Name": "catalog-name", "CatalogInput": { "CreateTableDefaultPermissions": [], "CreateDatabaseDefaultPermissions": [], "FederatedCatalog": { "ConnectionName": "connection-name", "ConnectionType": "DATABRICKS" } } }aws glue create-catalog --cli-input-json file://catalog.json -
Grant the crawler role the Lake Formation
DESCRIBEpermission on the catalog. The crawler role is the role that the managed crawler runs as. Grant this permission before you turn on sync, because the crawler role needs access to the catalog before AWS Glue creates the managed crawler. For the grant steps, see Granting permissions on Data Catalog resources in the AWS Lake Formation Developer Guide. -
Turn on sync by adding a
SyncConfigurationto the catalog withupdate-catalog. SetRoleArnto the crawler role. ForRefreshIntervalMinutes, use1440for a 24-hour interval or10080for a 7-day interval. IncludeConnectionNameandConnectionTypein the update. Save the following to a file namedupdate-catalog.json.{ "CatalogId": "account-id:catalog-name", "CatalogInput": { "CreateTableDefaultPermissions": [], "CreateDatabaseDefaultPermissions": [], "FederatedCatalog": { "ConnectionName": "connection-name", "ConnectionType": "DATABRICKS", "SyncConfiguration": { "RoleArn": "crawler-role-arn", "AssetsSyncConfiguration": { "Status": "ENABLED", "RefreshIntervalMinutes": 1440 } } } } }aws glue update-catalog --cli-input-json file://update-catalog.json -
Check the managed crawler status with
get-cataloguntil it reachesPROVISIONED.aws glue get-catalog \ --catalog-idaccount-id:catalog-name\ --query 'Catalog.FederatedCatalog.SyncConfiguration.AssetsSyncConfiguration.ManagedCrawlerDetails'The response shows the crawler ARN and status.
{ "CrawlerArn": "arn:aws:glue:region:account-id:crawler/catalog-sync-assets-id", "Status": "PROVISIONED" }
After the crawler reaches PROVISIONED, the first crawl starts
automatically. The start time isn't guaranteed. For instructions on changing the refresh interval,
turning sync off, or turning on lineage sync, see Managing an external catalog integration.
Set up query access from analytics engines
You choose how an analytics engine gets credentials to read the source data when you
create the connection. Set the credential vending mode with the
CREDENTIAL_VENDING_MODE connection property. The mode is one of the
following values.
AWS_VENDED-
The default. Lake Formation assumes the registered resource role and vends credentials to the engine.
SOURCE_VENDED-
The source vends the credentials. This mode is available to first-party engines only. Spark on Amazon EMR and AWS Glue Spark act as a third party, so they can't use
SOURCE_VENDED.
The following example sets CREDENTIAL_VENDING_MODE to
AWS_VENDED in the connection properties. Because AWS_VENDED is
the default, you can also leave the property out.
{ "CatalogId": "account-id", "ConnectionInput": { "Name": "connection-name", "ConnectionType": "DATABRICKS", "ConnectionProperties": { "INSTANCE_URL": "https://workspace.cloud.databricks.com", "WAREHOUSE_ID": "warehouse-id", "CREDENTIAL_VENDING_MODE": "AWS_VENDED" }, "AuthenticationConfiguration": { "AuthenticationType": "OAUTH2", "SecretArn": "secret-arn", "OAuth2Properties": { "OAuth2GrantType": "CLIENT_CREDENTIALS", "OAuth2ClientApplication": { "UserManagedClientApplicationClientId": "client-id" }, "TokenUrl": "https://workspace.cloud.databricks.com/oidc/v1/token", "TokenUrlParametersMap": { "scope": "all-apis" } } } } }
aws glue create-connection --cli-input-json file://connection.json
The following example sets CREDENTIAL_VENDING_MODE to
SOURCE_VENDED. Use this mode for first-party engines. The rest of the
connection is the same.
{ "CatalogId": "account-id", "ConnectionInput": { "Name": "connection-name", "ConnectionType": "DATABRICKS", "ConnectionProperties": { "INSTANCE_URL": "https://workspace.cloud.databricks.com", "WAREHOUSE_ID": "warehouse-id", "CREDENTIAL_VENDING_MODE": "SOURCE_VENDED" }, "AuthenticationConfiguration": { "AuthenticationType": "OAUTH2", "SecretArn": "secret-arn", "OAuth2Properties": { "OAuth2GrantType": "CLIENT_CREDENTIALS", "OAuth2ClientApplication": { "UserManagedClientApplicationClientId": "client-id" }, "TokenUrl": "https://workspace.cloud.databricks.com/oidc/v1/token", "TokenUrlParametersMap": { "scope": "all-apis" } } } } }
aws glue create-connection --cli-input-json file://connection.json
To query synced Databricks assets from Spark on Amazon EMR or AWS Glue Spark, you create a Data Catalog database resource link for the child catalog that you want to query.
Considerations and limitations for Databricks Unity Catalog
Consider the following when you query synced Databricks assets. For considerations that apply to every external catalog integration, see Considerations and limitations.
-
Athena engine version 3 supports all Databricks table types. These are Iceberg tables, Delta tables with Uniform, and Delta tables without Uniform.
-
Spark on Amazon EMR and AWS Glue Spark don't support multiple catalogs for third-party catalogs. To use Databricks assets from Spark, you create a Data Catalog database resource link.
-
Spark can't query Delta tables without Uniform. This isn't currently supported. Use Athena engine version 3 to query those tables.