> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# Apache Iceberg Lakehouse

> Quick start guide for querying Apache Iceberg data lakes with the database.

**Upstream deployment example.** This page uses community images, charts, or an upstream lab. [Get Enterprise Edition installation files](/documents/4.2/deployment/preparation/prepare_deployment_files.md) and confirm the supported image, chart, and operator versions for your release.

This guide will get you up and running with Apache Iceberg™ using the database™, including sample code to highlight some
powerful features.

### Docker-Compose

The fastest way to get started is to use a docker-compose file that uses the `starrocks/fe-ubuntu` and `starrocks/be-ubuntu`
images which contain a local cluster with a configured Iceberg catalog. To use this, you'll need to install
the Docker CLI.

Once you have Docker installed, save the yaml below into a file named docker-compose.yml:

```yml theme={null}
services:

  starrocks-fe:
    image: starrocks/fe-ubuntu:4.0-latest
    hostname: starrocks-fe
    container_name: starrocks-fe
    user: root
    command: |
      bash /opt/starrocks/fe/bin/start_fe.sh --host_type FQDN
    ports:
      - 8030:8030
      - 9020:9020
      - 9030:9030
    networks:
      iceberg_net:
    environment:
      - AWS_ACCESS_KEY_ID=admin
      - AWS_SECRET_ACCESS_KEY=password
      - AWS_REGION=us-east-1
    healthcheck:
      test: 'mysql -u root -h starrocks-fe -P 9030 -e "SHOW FRONTENDS\G" |grep "Alive: true"'
      interval: 10s
      timeout: 5s
      retries: 3

  starrocks-be:
    image: starrocks/be-ubuntu:4.0-latest
    command:
      - /bin/bash
      - -c
      - |
        ulimit -n 65535;
        echo "# Enable data cache"  >> /opt/starrocks/be/conf/be.conf
        echo "block_cache_enable = true"  >> /opt/starrocks/be/conf/be.conf
        echo "block_cache_mem_size = 536870912" >> /opt/starrocks/be/conf/be.conf
        echo "block_cache_disk_size = 1073741824" >> /opt/starrocks/be/conf/be.conf
        sleep 15s
        mysql --connect-timeout 2 -h starrocks-fe -P 9030 -u root -e "ALTER SYSTEM ADD BACKEND \"starrocks-be:9050\";"
        bash /opt/starrocks/be/bin/start_be.sh
    ports:
      - 8040:8040
    hostname: starrocks-be
    container_name: starrocks-be
    user: root
    depends_on:
      starrocks-fe:
        condition: service_healthy
    healthcheck:
      test: 'mysql -u root -h starrocks-fe -P 9030 -e "SHOW BACKENDS\G" |grep "Alive: true"'
      interval: 10s
      timeout: 5s
      retries: 3
    networks:
      iceberg_net:
    environment:
      - HOST_TYPE=FQDN
      - AWS_EC2_METADATA_DISABLED=true

  rest:
    image: apache/iceberg-rest-fixture
    container_name: iceberg-rest
    networks:
      iceberg_net:
        aliases:
          - iceberg-rest.minio
    ports:
      - 8181:8181
    environment:
      - AWS_ACCESS_KEY_ID=admin
      - AWS_SECRET_ACCESS_KEY=password
      - AWS_REGION=us-east-1
      - CATALOG_WAREHOUSE=s3://warehouse/
      - CATALOG_IO__IMPL=org.apache.iceberg.aws.s3.S3FileIO
      - CATALOG_S3_ENDPOINT=http://minio:9000

  minio:
    image: quay.io/minio/aistor/minio:latest
    container_name: minio
    volumes:
      - ./minio.license:/minio.license:ro
    environment:
      - MINIO_ROOT_USER=admin
      - MINIO_ROOT_PASSWORD=password
      - MINIO_DOMAIN=minio
    networks:
      iceberg_net:
        aliases:
          - warehouse.minio
    ports:
      - 9001:9001
      - 9000:9000
    command: ["server", "/data", "--console-address", ":9001"]
  mc:
    depends_on:
      - minio
    image: quay.io/minio/aistor/mc:latest
    container_name: mc
    networks:
      iceberg_net:
    environment:
      - AWS_ACCESS_KEY_ID=admin
      - AWS_SECRET_ACCESS_KEY=password
      - AWS_REGION=us-east-1
    entrypoint: >
      /bin/sh -c "
      until (/usr/bin/mc alias set minio http://minio:9000 admin password) do echo '...waiting...' && sleep 1; done;
      /usr/bin/mc rm -r --force minio/warehouse;
      /usr/bin/mc mb minio/warehouse;
      /usr/bin/mc anonymous set public minio/warehouse;
      tail -f /dev/null
      "
networks:
  iceberg_net:
```

MinIO AIStor requires a license. Before you start the containers, acquire a license:

MinIO AIStor requires a license to run. You can use an existing license, or you can request a new MinIO AIStor Free Tier license.

To request a new MinIO AIStor Free Tier license, go to the [MinIO AIStor pricing](https://min.io/pricing) page and select **Get Started** under the Free tier to obtain a free license. The free tier license allows you to run MinIO AIStor on a single compute resource with one or more drives.

Save the license file as `minio.license` in the same directory as the `docker-compose.yml` file. The Docker Compose file mounts `minio.license` into the MinIO AIStor container. Without a valid license, MinIO AIStor starts but denies all S3 operations.

Next, start up the docker containers with this command:

```Plain theme={null}
docker compose up --detach --wait --wait-timeout 400
```

You can then run any of the following commands to start a database session.

```bash theme={null}
docker exec -it starrocks-fe \
mysql -P 9030 -h 127.0.0.1 -u root --prompt="StarRocks > "
```

### Adding and Using a Catalog

```SQL theme={null}
CREATE EXTERNAL CATALOG 'demo'
COMMENT "External catalog to Apache Iceberg on MinIO"
PROPERTIES
(
  "type"="iceberg",
  "iceberg.catalog.type"="rest",
  "iceberg.catalog.uri"="http://iceberg-rest:8181",
  "iceberg.catalog.warehouse"="warehouse",
  "aws.s3.access_key"="admin",
  "aws.s3.secret_key"="password",
  "aws.s3.endpoint"="http://minio:9000",
  "aws.s3.enable_path_style_access"="true"
);
```

```SQL theme={null}
SHOW CATALOGS\G
```

```SQL theme={null}
*************************** 1. row ***************************
Catalog: default_catalog
   Type: Internal
Comment: An internal catalog contains this cluster's self-managed tables.
*************************** 2. row ***************************
Catalog: demo
   Type: Iceberg
Comment: External catalog to Apache Iceberg on MinIO
2 rows in set (0.00 sec)
```

```SQL theme={null}
SET CATALOG demo;
```

### Creating and using a database

```SQL theme={null}
CREATE DATABASE nyc;
```

```SQL theme={null}
USE nyc;
```

### Creating a table

```SQL theme={null}
CREATE TABLE demo.nyc.taxis
(
    trip_id            bigint,
    trip_distance      float,
    fare_amount double,
    store_and_fwd_flag string,
    vendor_id          bigint
) PARTITION BY (vendor_id);
```

### Writing Data to a Table

```SQL theme={null}
INSERT INTO demo.nyc.taxis
VALUES (1000371, 1.8, 15.32, 'N', 1),
       (1000372, 2.5, 22.15, 'N', 2),
       (1000373, 0.9, 9.01, 'N', 2),
       (1000374, 8.4, 42.13, 'Y', 1);
```

### Reading Data from a Table

```SQL theme={null}
SELECT *
FROM demo.nyc.taxis;
```

### Verify that the data is stored in object storage

When you added and used the external catalog, the database started using MinIO as the object store for the `demo.nyc.taxis`
table. If you navigate to [http://localhost:9001](http://localhost:9001) and then navigate through the Object Browser menu to
`warehouse/nyc/taxis/` you can confirm that the database is using MinIO for the storage.

**Tip**

The username and password for MinIO are in the docker-compose.yml file. You will be prompted to change the password to something better, just ignore this advice for the tutorial.

![img](https://mintcdn.com/mirrorship-docs/8FakUMFrFjmoxRt5/documents/images/d6f078d44705f38fe40f105e.png?fit=max\&auto=format\&n=8FakUMFrFjmoxRt5\&q=85\&s=4a05fed4e82008f3adc182e9e3b2b8d2)

### Next Steps

#### Adding Iceberg to the database

If you already have a StarRocks 3.2.0, or later, environment, it comes with the Iceberg 1.6.0 included. No additional
downloads or jars are needed.

#### Learn More

Now that you're up and running with Iceberg and the database, check out
the [StarRocks-Iceberg docs](/documents/4.2/data_source/catalog/iceberg/iceberg.md) to learn more!


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.