OSS Tables is compatible with the Apache Iceberg REST Catalog protocol. You can connect to OSS Tables using Trino's native S3 file system (fs.native-s3) to query and write data in a table bucket using standard SQL. This method requires minor modifications to the Trino source code to support the oss:// protocol and is suitable for scenarios where you control the build environment.
The Trino community does not natively support the oss:// file system protocol. To use Trino to access OSS Tables, you must modify the Trino source code and recompile two modules. You must then replace the original JAR packages in your Trino environment with the newly compiled ones and restart the service.
Step 1: Modify the Trino source code
OSS Tables returns data paths prefixed with oss://, but Trino's native S3 file system only recognizes the s3://, s3a://, and s3n:// schemes. You must register the oss scheme in the following two modules.
Modify trino-filesystem-s3
Locate the S3 location validation logic and add oss to the set of allowed schemes:
// Before modification
checkArgument(Set.of("s3", "s3a", "s3n").contains(location.scheme().get()), "Wrong scheme for S3 location: %s", location);
// After modification
checkArgument(Set.of("s3", "s3a", "s3n", "oss").contains(location.scheme().get()), "Wrong scheme for S3 location: %s", location);Modify trino-filesystem-manager
Add a binding for the oss scheme in the file system factory bindings:
factories.addBinding("s3").to(Key.get(TrinoFileSystemFactory.class, FileSystemS3.class));
factories.addBinding("s3a").to(Key.get(TrinoFileSystemFactory.class, FileSystemS3.class));
factories.addBinding("s3n").to(Key.get(TrinoFileSystemFactory.class, FileSystemS3.class));
// Add this line after the existing s3/s3a/s3n bindings:
factories.addBinding("oss").to(Key.get(TrinoFileSystemFactory.class, FileSystemS3.class));Build and replace the JAR packages
After building the two modules, replace the original JAR packages in your Trino deployment directory with the new ones and restart the Trino service.
# Build trino-filesystem-s3
mvn -pl lib/trino-filesystem-s3 -am package -DskipTests
# Build trino-filesystem-manager
mvn -pl lib/trino-filesystem-manager -am package -DskipTests
# Replace the JAR packages (assuming Trino is installed in /opt/trino)
cp lib/trino-filesystem-s3/target/trino-filesystem-s3-*.jar /opt/trino/lib/
cp lib/trino-filesystem-manager/target/trino-filesystem-manager-*.jar /opt/trino/lib/Step 2: Create a table bucket
Before you can write data, you must create a table bucket and a namespace. You can use either ossutil or the AWS CLI.
Method 1: Use ossutil
1. Install or upgrade ossutil
Install ossutil 2.3.0 or later. If you have an older version of ossutil installed, run the following command to upgrade to the latest version:
ossutil update -f2. Configure credentials
Run the ossutil config command and follow the prompts to enter your AccessKey ID, AccessKey Secret, and region.
3. Create a table bucket
ossutil tables-api create-table-bucket --name <table_bucket_name> --endpoint http://<endpoint> --region <region>After the command succeeds, the output includes the Table Bucket ARN. Record this ARN for later use.
4. Create a namespace
ossutil tables-api create-namespace --table-bucket-arn <table_bucket_arn> --namespace <namespace_name> --endpoint http://<endpoint>Namespace and table names cannot contain hyphens (-). Use underscores (_) instead, as these names are used as identifiers in SQL statements.
5. Create a table
You can create an Iceberg table in one of the following ways:
Create it using another compute engine, such as Spark.
Create it using ossutil: save the table schema to a JSON file, and then call
create-table.The following example schema file, named
schema.json, defines three fields:{ "iceberg": { "schema": { "fields": [ {"name": "event_id", "type": "string", "required": true}, {"name": "event_time", "type": "string"}, {"name": "event_type", "type": "string"} ] } } }Create a table based on the schema file:
ossutil tables-api create-table --table-bucket-arn <bucket_arn> --namespace <namespace_name> --name <table_name> --format ICEBERG --metadata file://<file_path> --endpoint http://<endpoint>
Method 2: Use the AWS CLI
OSS Tables is compatible with the S3 Tables API, so you can also use the AWS CLI to manage a table bucket.
1. Install the AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install2. Configure credentials
Run the aws configure command and follow the prompts to enter your AccessKey ID, AccessKey Secret, and region.
3. Create a table bucket
aws s3tables --endpoint http://<endpoint> create-table-bucket --region <region> --name <table_bucket_name>After the command succeeds, the output includes the Table Bucket ARN.
4. Create a namespace
aws s3tables --endpoint http://<endpoint> create-namespace --table-bucket-arn <table_bucket_arn> --namespace <namespace_name>5. Create a table
Create a table using another compute engine, such as Spark.
Use the AWS CLI. Save the complete parameters to a JSON file, such as
create-table.json, and then callcreate-table.{ "tableBucketARN": "<bucket_arn>", "namespace": "<namespace_name>", "name": "<table_name>", "format": "ICEBERG", "metadata": { "iceberg": { "schema": { "fields": [ {"name": "event_id", "type": "string","required": true}, {"name": "event_time", "type": "string"}, {"name": "event_type", "type": "string"} ] } } } }aws s3tables --endpoint http://<endpoint> create-table --cli-input-json file://<file_path>
6. Manage background maintenance tasks
OSS Tables supports automatic background maintenance for Iceberg tables, such as file cleanup and file compaction. You can use the AWS CLI to query and configure these maintenance tasks.
Query the status of a table maintenance job:
aws s3tables get-table-maintenance-job-status \
--table-bucket-arn="<bucket_arn>" \
--namespace="<namespace_name>" \
--name="<table_name>" Configure a bucket-level maintenance policy (file cleanup):
aws s3tables put-table-bucket-maintenance-configuration \
--table-bucket-arn <table_bucket_arn> \
--type icebergUnreferencedFileRemoval \
--value '{"status":"enabled","settings":{"icebergUnreferencedFileRemoval":{"unreferencedDays":4,"nonCurrentDays":10}}}' Configure a table-level maintenance policy (small file compaction):
aws s3tables put-table-maintenance-configuration \
--table-bucket-arn <bucket_arn> \
--type icebergCompaction \
--namespace <namespace_name> \
--name <table_name> \
Step 3: Configure the Trino catalog
OSS Tables provides an Iceberg REST Catalog endpoint. Trino connects using the Iceberg connector in REST Catalog mode. The endpoint formats are as follows:
Internal network:
https://{region}-internal.oss-tables.aliyuncs.com/icebergPublic network:
https://{region}.oss-tables.aliyuncs.com/iceberg
OSS Tables provides an S3-compatible endpoint for data plane access. Trino uses this endpoint to read and write table data. The endpoint formats are as follows:
Internal network:
https://oss-{region}-internal.aliyuncs.comPublic network:
https://oss-{region}.aliyuncs.com
Create a catalog properties file
In Trino's etc/catalog/ directory, create a properties file (for example, oss_tables.properties):
connector.name=iceberg
iceberg.catalog.type=rest
iceberg.rest-catalog.uri=https://<region>-internal.oss-tables.aliyuncs.com/iceberg
iceberg.rest-catalog.warehouse=<Table Bucket ARN>
iceberg.rest-catalog.security=SIGV4
iceberg.rest-catalog.signing-name=osstables
iceberg.rest-catalog.view-endpoints-enabled=false
fs.hadoop.enabled=false
fs.native-s3.enabled=true
s3.endpoint=https://oss-<region>-internal.aliyuncs.com
s3.region=<region>
s3.aws-access-key=<AccessKey ID>
s3.aws-secret-key=<AccessKey Secret>
s3.path-style-access=trueParameters
Parameter | Required | Description |
| Yes | Set to |
| Yes | Set to |
| Yes | The REST catalog endpoint URL. The formats are:
|
| Yes | The Table Bucket ARN. Format: |
| Yes | Set to |
| Yes | Set to |
| Yes | Set to |
| Yes | Set to |
| Yes | The OSS data plane endpoint. The formats are:
|
| Yes | Set to |
Step 4: Use SQL to manage data
After configuring and restarting Trino, you can connect using the Trino CLI or a JDBC client to manage data in OSS Tables using standard SQL.
Example: Create a table
CREATE TABLE ${catalog}.${namespace}.orders (
order_id BIGINT,
customer VARCHAR,
amount DECIMAL(10,2),
order_date DATE,
created_at TIMESTAMP(6)
)
WITH (
format = 'PARQUET',
partitioning = ARRAY['day(order_date)'],
);Example: Query data
SELECT * FROM ${catalog}.${namespace}.orders limit 10;Permissions
When using a RAM user or STS temporary credentials to access OSS Tables, you must ensure that the identity has the required permissions.
Resources
Table Bucket ARN:
acs:osstables:<region>:<alibaba_cloud_account_id>:bucket/<bucket_name>Table ARN:
acs:osstables:<region>:<alibaba_cloud_account_id>:bucket/<bucket_name>/table/<table_id>
Actions
The following table lists the actions supported by OSS Tables and indicates whether they allow cross-account access.
Category | Action | Cross-account access |
Table bucket level |
| Not Allowed |
| Allowed | |
| Not Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Not Allowed | |
| Not Allowed | |
| Not Allowed | |
| Allowed | |
| Allowed | |
| Not Allowed | |
| Not Allowed | |
| Not Allowed | |
Table level |
| Allowed |
| Allowed | |
| Not Allowed | |
| Not Allowed | |
| Not Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Allowed | |
| Not Allowed | |
| Not Allowed | |
| Allowed |
Iceberg REST operation permissions
The following table lists the OSS actions required for each Iceberg REST Catalog operation.
Iceberg REST operation | Required OSS action |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|