Getting Started with Apache Polaris and Trino
This getting started guide provides a docker-compose file to set up Trino with Apache Polaris.
Apache Polaris is configured as an Iceberg REST Catalog, and RustFS provides S3-compatible object storage.
The docker-compose file starts the following services:
rustfsβ S3-compatible object storage for Iceberg data filespolarisβ Apache Polaris running with an in-memory metastorepolaris-setupβ bootstraps a catalog, grants, and a namespace in Polaristrinoβ Trino configured with an Iceberg connector pointing at Polaris
Build the Polaris imageπ
If a Polaris image is not already present locally, build one with the following command:
./gradlew \
:polaris-server:assemble \
:polaris-server:quarkusAppPartsBuild --rerun \
-Dquarkus.container-image.build=true
Run the docker-compose fileπ
Start all services from the repo’s root directory:
docker compose -f site/content/guides/trino/docker-compose.yml up
Wait until the trino service is healthy before proceeding. You can check by watching for the log line HTTP server started in the Trino container output.
Connect to the Trino CLIπ
Open a Trino CLI session inside the running Trino container:
docker compose -f site/content/guides/trino/docker-compose.yml exec trino trino
Run SQL queriesπ
The polaris-setup service already created a quickstart_catalog backed by RustFS. Create a schema, table, and run some queries:
CREATE SCHEMA polaris.demo;
USE polaris.demo;
CREATE TABLE events (
event_id BIGINT,
event_type VARCHAR,
user_id BIGINT,
created_at TIMESTAMP(6) WITH TIME ZONE
)
WITH (format = 'PARQUET');
INSERT INTO events VALUES
(1, 'page_view', 101, TIMESTAMP '2024-10-01 10:00:00 UTC'),
(2, 'click', 102, TIMESTAMP '2024-10-01 11:30:00 UTC'),
(3, 'purchase', 101, TIMESTAMP '2024-10-02 09:15:00 UTC');
SELECT event_type, count(*) AS cnt
FROM events
GROUP BY event_type
ORDER BY cnt DESC;
Catalog configurationπ
The Trino Iceberg catalog is defined in catalog/polaris.properties and mounted into the Trino container at /etc/trino/catalog/. Key properties:
| Property | Value | Description |
|---|---|---|
iceberg.catalog.type | rest | Use the Iceberg REST catalog protocol |
iceberg.rest-catalog.uri | http://polaris:8181/api/catalog | Polaris REST catalog endpoint |
iceberg.rest-catalog.warehouse | quickstart_catalog | Polaris catalog name |
iceberg.rest-catalog.security | OAUTH2 | OAuth2 client credentials flow |
iceberg.rest-catalog.http-headers | Polaris-Realm: POLARIS | Routes requests to the correct Polaris realm |
iceberg.rest-catalog.vended-credentials-enabled | true | Use credentials vended by Polaris to access object storage, instead of static S3 credentials |
fs.s3.enabled | true | Enable native S3 file system |
s3.endpoint | http://rustfs:9000 | RustFS S3-compatible endpoint |
s3.path-style-access | true | Required for RustFS |
RustFS endpointsπ
The catalog configuration uses different endpoints for Polaris and Trino versus external clients.
endpointInternal (http://rustfs:9000) is used by Polaris when writing Iceberg metadata files.
endpoint (http://localhost:9000) is the externally reachable address for clients running outside Docker.
Trino configures its S3 endpoint directly in catalog/polaris.properties using the internal Docker hostname rustfs.
Useful URLsπ
- Trino Web UI: http://localhost:8080
- Polaris REST API: http://localhost:8181
- RustFS Console: http://localhost:9001