tree: 07418de1922ff41837755fc6d0019ee5a23e78ca [path history] [tgz]
  1. docker-compose-bootstrap-db.yml
  2. docker-compose.yml
  3. README.md
getting-started/eclipselink/README.md

Getting Started with Apache Polaris, EclipseLink, Postgres and Spark SQL

This example requires jq to be installed on your machine.

  1. If such an image is not already present, build the Polaris image with support for EclipseLink and the Postgres JDBC driver:

    ./gradlew \
       :polaris-server:assemble \
       :polaris-server:quarkusAppPartsBuild --rerun \
       :polaris-admin:assemble \
       :polaris-admin:quarkusAppPartsBuild --rerun \
       -Dquarkus.container-image.build=true
    
  2. Start the docker compose group by running the following command from the root of the repository:

    export ASSETS_PATH=$(pwd)/getting-started/assets/
    export CLIENT_ID=root
    export CLIENT_SECRET=s3cr3t
    docker compose -p polaris -f getting-started/assets/postgres/docker-compose-postgres.yml \
       -f getting-started/eclipselink/docker-compose-bootstrap-db.yml \
       -f getting-started/eclipselink/docker-compose.yml up
    
  3. Using spark-sql: attach to the running spark-sql container:

    docker attach $(docker ps -q --filter name=spark-sql)
    

    You may not see Spark's prompt immediately, type ENTER to see it. A few commands that you can try:

    CREATE NAMESPACE quickstart_catalog.ns1;
    USE quickstart_catalog.ns1;
    CREATE TABLE table1 (id int, name string);
    INSERT INTO table1 VALUES (1, 'a');
    SELECT * FROM table1;
    
  4. To access Polaris from the host machine, first request an access token:

    export POLARIS_TOKEN=$(curl -s http://localhost:8181/api/catalog/v1/oauth/tokens \
       --user root:s3cr3t \
       -d 'grant_type=client_credentials' \
       -d 'scope=PRINCIPAL_ROLE:ALL' | jq -r .access_token)
    
  5. Then, use the access token in the Authorization header when accessing Polaris:

    curl -v http://localhost:8181/api/management/v1/principal-roles -H "Authorization: Bearer $POLARIS_TOKEN"
    curl -v http://localhost:8181/api/management/v1/catalogs/quickstart_catalog -H "Authorization: Bearer $POLARIS_TOKEN"
    
  6. Using Trino CLI: To access the Trino CLI, run this command:

docker exec -it polaris-trino-1 trino

Note, polaris-trino-1 is the name of the Docker container. The actual name on your system may vary.

Example Trino queries:

SHOW CATALOGS;
SHOW SCHEMAS FROM iceberg;
SHOW TABLES FROM iceberg.information_schema;
DESCRIBE iceberg.information_schema.tables;

CREATE SCHEMA iceberg.tpch;
CREATE TABLE iceberg.tpch.test_polaris AS SELECT 1 x;
SELECT * FROM iceberg.tpch.test_polaris;