All Products
Search
Document Center

AnalyticDB:Azure Databricks DDL migration

Last Updated:Mar 28, 2026

This tutorial walks you through migrating a Databricks schema — and all its tables — to AnalyticDB for MySQL using an automated Python script. The script handles schema-only migration (DDL); for data migration, see Load data into Delta Lake tables.

How it works

Azure Databricks organizes metadata in three layers: catalog.schema.table. AnalyticDB for MySQL uses two layers: database.table. The script bridges this gap by:

  1. Connecting to Databricks and parsing all Delta table structures in a target schema

  2. Generating Spark SQL Data Definition Language (DDL) statement files compliant with the open-source Delta Lake standard

  3. Creating a matching database and tables in AnalyticDB for MySQL using a Spark Interactive resource group

image

Each script run migrates one schema and creates one database in AnalyticDB for MySQL. To migrate multiple schemas, run the script once per schema.

Prerequisites

Before you begin, ensure the following resources are in place.

On the Azure Databricks side:

On the AnalyticDB for MySQL side:

On the local machine:

  • Python 3.6 or later is installed

  • The IP address of the machine is added to the whitelist of the AnalyticDB for MySQL cluster

Migrate a schema

Step 1: Install dependencies

pip install pyhive
pip install thrift
pip install thrift_sasl

Step 2: Configure the script

Download GetDDLFromDatabricksV01.py and update the following parameters:

ParameterDescriptionExample
databricks_workspace_urlWorkspace URL of Azure Databricks. Format: https://adb-<id>.azuredatabricks.net/?o=<id>. See Workspace URL.https://adb-28944**.9.azuredatabricks.net/?o=28944**
databricks_tokenAccess token for Azure Databricks. Must have read permission on the catalog or schema.dapi****
databricks_catalogCatalog name in Azure Databricks.databricks****
databricks_schemaSchema name to migrate.adbmysql
databricks_warehouse_idWarehouse ID in Azure Databricks.42****
ddl_output_root_pathLocal path where the script writes temporary .sql files. The AnalyticDB for MySQL Spark engine runs these files sequentially./root/databricks/
adb_spark_hostPublic endpoint of the Spark Interactive resource group.amv-uf648****sparkwho.ads.aliyuncs.com
adb_usernameDatabase account name for the AnalyticDB for MySQL cluster.user
adb_passwordPassword for the database account.password****
adb_spark_resource_groupName of the Spark Interactive resource group.Interactive
adb_database_oss_locationOSS path for Delta Lake table data. This path must be empty — a non-empty path causes table creation to fail. The Location parameter applies at the database level in this tutorial, so all tables share this path.oss://testBucketName/adbmysql/

Step 3: Run the script

python GetDDLFromDatabricksV01.py

Step 4: Verify the migration

Verify schema structure in the console

  1. Log on to the AnalyticDB for MySQL console. In the upper-left corner, select a region. In the left-side navigation pane, click Clusters, then click the cluster ID.

  2. In the left-side navigation pane, choose Data Management > Data Catalog.

  3. Click the target database and table to review details such as table type, storage data size, and column names.

    image

  4. In the left-side navigation pane, choose Job Development > SQL Development.

  5. Select the Spark engine and the Interactive resource group, then run the following command to confirm the table schema:

    DESCRIBE DETAIL adbmysql.table_name;

What's next