View a markdown version of this page

Integrating with Databricks Unity Catalog - AWS Glue

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 account-id for your 12-digit AWS account ID and region for the AWS Region of the catalog.

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.

  1. 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 \ --name databricks-secret-name \ --secret-string file://secret.json

    The connector adds an ACCESS_TOKEN value to the same secret and refreshes it. You don't add ACCESS_TOKEN yourself.

  2. Save the connection definition to a file named connection.json. The INSTANCE_URL is your Databricks workspace URL, and WAREHOUSE_ID is the ID of a Databricks SQL warehouse. The TokenUrl is your workspace token endpoint, and UserManagedClientApplicationClientId is the client ID of your Databricks OAuth client. The scope defaults to all-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.

  1. 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-catalog fails with the error The data source [connection-arn] is not registered. Save the following to a file named 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
  2. 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 ConnectionName and ConnectionType, and always send CreateTableDefaultPermissions and CreateDatabaseDefaultPermissions as empty lists. Save the following to a file named catalog.json.

    { "Name": "catalog-name", "CatalogInput": { "CreateTableDefaultPermissions": [], "CreateDatabaseDefaultPermissions": [], "FederatedCatalog": { "ConnectionName": "connection-name", "ConnectionType": "DATABRICKS" } } }
    aws glue create-catalog --cli-input-json file://catalog.json
  3. Grant the crawler role the Lake Formation DESCRIBE permission 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.

  4. Turn on sync by adding a SyncConfiguration to the catalog with update-catalog. Set RoleArn to the crawler role. For RefreshIntervalMinutes, use 1440 for a 24-hour interval or 10080 for a 7-day interval. Include ConnectionName and ConnectionType in the update. Save the following to a file named update-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
  5. Check the managed crawler status with get-catalog until it reaches PROVISIONED.

    aws glue get-catalog \ --catalog-id account-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.