Access OSS Tables by using EMR Serverless StarRocks
Access OSS Tables from Alibaba Cloud EMR Serverless StarRocks, a fully managed service. Use standard SQL to create tables, write data, and query data.
Prerequisites
An Alibaba Cloud AccessKey pair (AccessKey ID and AccessKey secret)
A Table Bucket in OSS Tables. If you have not created one, see OSS tables.
StarRocks Community Edition has a known issue in which the specified S3FileIO does not take effect (see GitHub Issue #78141). Before you use it, contact an OSS O&M engineer to enable the ListObjectsV2 permission for the OSS Table Bucket.
Step 1: Prepare the environment
Purchase an EMR Serverless StarRocks instance
Log on to the EMR console and purchase an EMR Serverless StarRocks instance.
Configure access credentials
To access the data files in OSS Tables, configure the AccessKey pair (AccessKey ID and AccessKey secret) of your Alibaba Cloud account.
In the EMR Serverless StarRocks console, go to the product page of the target instance, click the Parameter Settings tab, and then perform the following steps:
Disable the existing password-free access. Delete the values of the corresponding configuration items in the following files and leave the configuration items blank.
In
core-site.xml:fs.oss.credentials.provider =jindosdk.cfg:fs.oss.provider.format = fs.oss.provider.endpoint =Add the AccessKey pair of your Alibaba Cloud account. On the Parameter Settings tab, click Add Configuration Item and add the following configuration items:
In
core-site.xml:fs.oss.accessKeyId = <Alibaba Cloud AccessKey ID> fs.oss.accessKeySecret = <Alibaba Cloud AccessKey secret>jindosdk.cfg:fs.oss.accessKeyId = <Alibaba Cloud AccessKey ID> fs.oss.accessKeySecret = <Alibaba Cloud AccessKey secret>Apply the configurations. On the Parameter Settings tab, click Submit Parameters. After the configurations take effect, you can access the data files in OSS Tables.
For complete information about custom AccessKey configuration in EMR Serverless StarRocks, see EMR Serverless StarRocks FAQ.
Step 2: Create an Iceberg REST catalog
The following example uses the Table Bucket name my-data-lake and the region cn-hangzhou. The corresponding Table Bucket ARN is acs:osstables:cn-hangzhou:{accountId}:bucket/my-data-lake.
Unlike StarRocks Community Edition, EMR Serverless StarRocks requires no additional aws.s3.* parameters on the data plane. EMR automatically handles the access credentials and endpoint of the data plane.
Run the following statement to create an Iceberg REST catalog:
CREATE EXTERNAL CATALOG starrocks_osstables PROPERTIES(
"type" = "iceberg",
"iceberg.catalog.type" = "rest",
-- Metadata plane
"iceberg.catalog.uri" = "https://cn-hangzhou-internal.oss-tables.aliyuncs.com/iceberg",
"iceberg.catalog.rest.sigv4-enabled" = "true",
"iceberg.catalog.rest.signing-name" = "osstables",
"iceberg.catalog.rest.signing-region" = "cn-hangzhou",
"iceberg.catalog.rest.access-key-id" = "<Alibaba Cloud AccessKey ID>",
"iceberg.catalog.rest.secret-access-key" = "<Alibaba Cloud AccessKey secret>",
"iceberg.catalog.warehouse" = "acs:osstables:cn-hangzhou:{accountId}:bucket/my-data-lake",
"iceberg.catalog.io-impl" = "org.apache.iceberg.aws.s3.S3FileIO"
);Catalog parameters
The following table describes the parameters in the statement.
Parameter | Required | Description |
| Yes | The implementation type of the Iceberg catalog. Set the value to |
| Yes | The endpoint of the OSS Tables metadata service. Internal: |
| Yes | Set the value to |
| Yes | The name of the signing service. Set the value to |
| Yes | The signing region. Set the value to the region where the Table Bucket resides, for example, |
| Yes | The ARN of the Table Bucket. Format: |
| Yes | The FileIO implementation. Set the value to |
Step 3: Use SQL to manage data
After the catalog is created, use standard SQL statements to manage data.
Create a database and table
Run the following SQL statements:
-- Switch the catalog
SET CATALOG starrocks_osstables;
-- Create a database
CREATE DATABASE starrocks_osstables_db;
-- Create a table
CREATE TABLE starrocks_osstables_db.users (
id BIGINT NOT NULL COMMENT 'User ID',
name STRING COMMENT 'Username',
email STRING COMMENT 'Email',
created_at DATETIME COMMENT 'Creation time'
);Write and query data
Run the following SQL statements to write and query data:
-- Insert data
INSERT INTO starrocks_osstables_db.users VALUES
(1, 'Alice', 'alice@example.com', '2024-01-15 10:30:00'),
(2, 'Bob', 'bob@example.com', '2024-01-16 14:20:00'),
(3, 'Carol', 'carol@example.com', '2024-01-17 09:15:00');
-- Query the entire table
SELECT * FROM starrocks_osstables_db.users;
-- Conditional query
SELECT * FROM starrocks_osstables_db.users WHERE id = 2;
-- Aggregate query
SELECT COUNT(*) AS total FROM starrocks_osstables_db.users;The conditional query returns the row where id is 2, and the aggregate query returns the total number of rows in the table.
Usage notes
Data plane configuration — When you run
CREATE CATALOGin EMR Serverless StarRocks, you do not need to configure theaws.s3.*data plane parameters. EMR handles them automatically. Configure only the metadata plane parameters.Data maintenance — OSS Tables provides built-in file merge, snapshot cleanup, and unreferenced file cleanup. No manual maintenance operations are required. For more information, see Data maintenance.