Lake storage
The AnalyticDB for MySQL lake storage feature simplifies data lake construction, storage management, and optimization. It supports storing structured table data in formats like Iceberg and Paimon, and unstructured file objects, making it ideal for scenarios that require both offline batch processing and real-time analytics. This topic describes how to create, modify, and view the data volume of a lake storage.
The lake storage feature is in invitational preview. To enable this feature, submit a ticket.
Prerequisites
An AnalyticDB for MySQL Enterprise Edition, Basic Edition, or Data Lakehouse Edition cluster is created.
Introduction
The AnalyticDB for MySQL lake storage can store structured table data in formats like Iceberg and Paimon, and unstructured file objects. With a fully managed architecture, lake storage automatically handles complex tasks such as data lake construction, metadata governance, and storage optimization. This reduces storage costs and improves query performance. Unified metadata management and service-oriented resource scheduling also allow you to quickly complete data ingestion, storage optimization, and multi-engine collaborative computing without maintaining the underlying infrastructure.
Billing
-
After you create a lake storage, AnalyticDB for MySQL charges you on a pay-as-you-go basis for the data volume and usage duration. For pricing details, see Enterprise Edition and Basic Edition pricing and Data Lakehouse Edition pricing.
-
Reading data from or writing data to a lake storage incurs request fees. These fees include charges for PUT and GET requests. For pricing details, see Enterprise Edition and Basic Edition pricing and Data Lakehouse Edition pricing.
Usage notes
-
An Alibaba Cloud account can create up to five lake storages in the same region.
-
There is a delay in updating the displayed storage usage for lake storage, so you may not see the updated data volume immediately after writing data.
-
Before you delete a lake storage, you must first delete all data in it. Otherwise, the deletion fails.
-
After you create a lake storage, AnalyticDB for MySQL automatically creates a bucket in OSS under its service account. This bucket is in the same region as your AnalyticDB for MySQL cluster and has the same name as the lake storage. You can view this bucket in the OSS console under your Alibaba Cloud account by adding a favorite path.
-
The AnalyticDB for MySQL backup and recovery feature does not support data in lake storage.
Create a lake storage
Log on to the AnalyticDB for MySQL console. In the upper-left corner of the console, select a region. In the left-side navigation pane, click Clusters. Find the cluster that you want to manage and click the cluster ID.
-
In the navigation pane on the left, choose .
-
In the upper-right corner of the page, click Create Lake Storage.
-
In the Create Lake Storage dialog box, click OK.
ImportantThe system automatically generates a globally unique name for the lake storage in the
adb-lake-<Region ID>-<Random String>format. You cannot change the name after creation. -
(Optional) Modify the lake storage description.
The name of a lake storage is automatically generated and cannot be modified. We recommend modifying the description of the lake storage to distinguish it from others used for different business scenarios.
-
In the Lake Storage Description column of the target lake storage, click the
icon. -
In the Change Lake Storage Description dialog box, enter a description and click OK.
-
-
(Optional) Add authorization.
In the Actions column, click Add Authorization and choose to authorize a RAM user or a RAM role.
Note-
Read-only: Allows users to view lake storage data, but not modify or delete it.
-
Read/write: Allows users to read, write, and modify data.
-
Only an Alibaba Cloud account or a RAM user with the required permissions can grant permissions.
-
Permission changes take effect immediately. Confirm the authorization scope before you proceed.
-
Use a lake storage
A lake storage table is a fully managed table provided by the AnalyticDB for MySQL lake storage feature that uses data formats such as Iceberg and Paimon. When you create a lake storage table, the system automatically generates a unique UUID for the table. By default, the data path is oss://<lake_storage_name>/lakehouse/default/tables/<table_uuid>. For example, for the lake storage table test_iceberg_tbl stored in adb-lake-cn-shanghai-6gml****, the generated path is oss://adb-lake-cn-shanghai-6gml****/lakehouse/default/tables/b22cd225-528d-421c-a2****. You can use the XIHE and Spark engines to create, read from, and write to lake storage tables. You can also manage permissions and lifecycles for lake storage tables in the same way as for internal tables. The following sections describe how to read from and write to lake storage tables:
Spark SQL
Prerequisites
Your cluster's kernel version must be 3.2.3.0 or later.
To view and update the minor version, go to the Configuration Information section on the Cluster Information page in the AnalyticDB for MySQL console.
Procedure
-
Navigate to SQL Development.
Log on to the AnalyticDB for MySQL console. In the upper-left corner of the console, select a region. In the left-side navigation pane, click Clusters. Find the cluster that you want to manage and click the cluster ID.
In the left-side navigation pane, click .
In the SQLConsole window, select the Spark engine and a resource group (either a job resource group or an interactive resource group that uses the Spark engine).
-
Create an external database and an Iceberg lake storage table.
Create an external database
CREATE DATABASE adb_external_db_iceberg WITH DBPROPERTIES ( 'adb_lake_bucket' = 'adb-lake-cn-shanghai-6gml****' );adb_lake_bucket: Optional. Specifies the storage location for data in Data Lake Storage tables. If you specify this parameter at the database level, all tables in the database use this Data Lake Storage space by default. You can also specify a storage location when you create a table. The table-level configuration takes precedence over the database-level configuration.-
Create an Iceberg external table.
SET spark.adb.lakehouse.enabled=true; -- Enables lake storage. CREATE TABLE adb_external_db_iceberg.test_iceberg_tbl ( `id` int, `name` string, `age` int ) USING iceberg PARTITIONED BY (age) TBLPROPERTIES ( 'adb_lake_bucket' = 'adb-lake-cn-shanghai-6gml****' );Parameters:
Parameter
Description
adb_lake_bucket
Specifies the storage location for the data of the lake storage table.
-
If you specified a lake storage when you created the database, all tables in the database are stored in that lake storage. You do not need to specify the parameter again when you create a table.
-
If you did not specify a lake storage when you created the database, you must specify this parameter. Otherwise, the table creation fails. After you specify the lake storage, the table's data is stored in it.
-
If you specified a lake storage both when you created the database and when you created the table, the table data is stored in the lake storage specified at the table level. Other tables in the database are stored in the lake storage specified at the database level.
-
-
Write data to the Iceberg table.
SET spark.adb.lakehouse.enabled=true; -- Enables lake storage. INSERT INTO adb_external_db_iceberg.test_iceberg_tbl VALUES (1, 'anna', 10), (2, 'jams', 20); -
(Optional) Delete data from the Iceberg table.
SET spark.adb.lakehouse.enabled=true; -- Enables lake storage. DELETE FROM adb_external_db_iceberg.test_iceberg_tbl WHERE id = 1; DELETE FROM adb_external_db_iceberg.test_iceberg_tbl WHERE age = 20; -
Query data from the external Iceberg table.
SET spark.adb.lakehouse.enabled=true; -- Enables lake storage. SELECT * FROM adb_external_db_iceberg.test_iceberg_tbl;The following result is returned:
+---+----+---+ |id |name|age| +---+----+---+ |1 |anna|10 | |2 |jams|20 | +---+----+---+ -
(Optional) Delete the external Iceberg table.
Run the following statement to delete the external Iceberg table from AnalyticDB for MySQL and its data from OSS.
SET spark.adb.lakehouse.enabled=true; DROP TABLE adb_external_db_iceberg.test_iceberg_tbl;
XIHE SQL
Prerequisites
Your cluster's kernel version must be 3.2.5.3 or later.
To view and update the minor version, go to the Configuration Information section on the Cluster Information page in the AnalyticDB for MySQL console.
Usage notes
With the XIHE engine, you cannot use the DELETE statement to remove specific rows from a lake storage table. You can only delete the entire table by using the DROP TABLE statement.
Procedure
-
Navigate to SQL Development.
Log on to the AnalyticDB for MySQL console. In the upper-left corner of the console, select a region. In the left-side navigation pane, click Clusters. Find the cluster that you want to manage and click the cluster ID.
In the left-side navigation pane, click .
-
In the SQL Console window, select the XIHE engine and an interactive resource group.
-
Create an external database and an external Iceberg table.
-
Create an external database.
CREATE EXTERNAL DATABASE test_db WITH DBPROPERTIES ('adb_lake_bucket' = 'adb-lake-cn-shanghai-6gml****');Parameters:
Parameter
Description
adb_lake_bucket
Specifies the storage location for the data of the lake storage table.
After you specify a lake storage in the CREATE DATABASE statement, all tables in the database are stored in that lake storage. If you do not want all tables in the database to be stored in the lake storage, set this parameter when you create a table instead.
-
Create an external Iceberg table.
CREATE TABLE test_db.test_iceberg_tbl ( `id` int, `name` string )PARTITIONED BY (age int) STORED AS ICEBERG TBLPROPERTIES ( 'catalog_type' = 'ADB', 'adb_lake_bucket' = 'adb-lake-cn-shanghai-6gml****' );Parameters:
Parameter
Description
catalog_type
The catalog type. Set this parameter to ADB.
adb_lake_bucket
Specifies the storage location for the data of the lake storage table.
-
If you specified a lake storage when you created the database, all tables in the database are stored in that lake storage. You do not need to specify the parameter again when you create a table.
-
If you did not specify a lake storage when you created the database, you must specify this parameter. Otherwise, the table creation fails. After you specify the lake storage, the table's data is stored in it.
-
If you specified a lake storage both when you created the database and when you created the table, the table data is stored in the lake storage specified at the table level. Other tables in the database are stored in the lake storage specified at the database level.
-
-
-
Write data to the Iceberg table.
INSERT INTO test_db.test_iceberg_tbl select 1, 'anna', 10; INSERT INTO test_db.test_iceberg_tbl select 2, 'jams', 20; -
Query data from the external Iceberg table.
SELECT * FROM test_db.test_iceberg_tbl;The following result is returned:
+---+----+---+ |id |name|age| +---+----+---+ |1 |anna|10 | |2 |jams|20 | +---+----+---+ -
(Optional) Delete the external Iceberg table.
Run the following statement to delete the external Iceberg table from AnalyticDB for MySQL and its data from OSS.
DROP TABLE test_db.test_iceberg_tbl;
View lake storage data volume
-
In the navigation pane on the left, choose .
-
View the data volume in the Storage Usage column of the target lake storage.
ImportantThere is a delay in updating the displayed storage usage for lake storage, so you may not see the updated data volume immediately after writing data.
Delete a lake storage
-
In the navigation pane on the left, choose .
-
In the Actions column of the target lake storage, click Delete.
-
In the Delete dialog box that appears, click OK.
ImportantBefore you delete a lake storage, you must first delete all data in it. Otherwise, the deletion fails.
icon next to Favorite Paths.