Skip to content

Commit

Permalink
#68 rename + consolidate crates (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
twuebi committed Jun 11, 2024
1 parent d042518 commit 01414ee
Show file tree
Hide file tree
Showing 67 changed files with 439 additions and 425 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
target
Dockerfile
**/Dockerfile
!target/release/iceberg-rest
!target/release/iceberg-catalog
38 changes: 19 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,25 @@ jobs:

- name: Docker info
run: docker info

- name: Build Docker image (amd64)
run: |
DOCKER_BUILDKIT=1 docker build -t localhost/iceberg-rest-local:amd64 \
DOCKER_BUILDKIT=1 docker build -t localhost/iceberg-catalog-local:amd64 \
-f docker/full.Dockerfile \
--add-host=host.docker.internal:host-gateway \
--build-arg DATABASE_URL=postgres://postgres:postgres@host.docker.internal:5432/postgres .
docker save -o /tmp/iceberg-rest-server-amd64.tar localhost/iceberg-rest-local:amd64
docker save -o /tmp/iceberg-catalog-amd64.tar localhost/iceberg-catalog-local:amd64
# This is currently very slow. Switch to ARM workers once they are finally available
# in gh actions!
# - name: Build Docker image (arm64)
# run: |
# DOCKER_BUILDKIT=1 docker build \
# --platform linux/arm64 -t iceberg-rest-local:arm64 \
# --platform linux/arm64 -t iceberg-catalog-local:arm64 \
# --add-host=host.docker.internal:host-gateway \
# -f docker/full.Dockerfile \
# --build-arg DATABASE_URL=postgres://postgres:postgres@host.docker.internal:5432/postgres .
# docker save -o /tmp/iceberg-rest-server-arm64.tar iceberg-rest-local:arm64
# docker save -o /tmp/iceberg-catalog-arm64.tar iceberg-catalog-local:arm64

# ToDo: Use action instead of manual build.
# The snippet below couldn't resolve the host.docker.internal / host-gateway.
Expand All @@ -101,18 +101,18 @@ jobs:
# load: true
# platforms: linux/amd64
# file: docker/full.Dockerfile
# outputs: type=docker,dest=/tmp/iceberg-rest-server-amd64.tar
# outputs: type=docker,dest=/tmp/iceberg-catalog-amd64.tar
# # cache-from: type=gha
# # cache-to: type=gha,mode=max
# add-hosts: "host.docker.internal:host-gateway"
# build-args: |
# "DATABASE_URL=postgres://postgres:postgres@host.docker.internal:5432/postgres"
# tags: iceberg-rest-local:amd64
# tags: iceberg-catalog-local:amd64

- name: Save Docker
uses: actions/upload-artifact@v4
with:
name: iceberg-rest-server-image
name: iceberg-catalog-image
path: /tmp/*.tar

clippy:
Expand All @@ -139,7 +139,7 @@ jobs:
run: |
sudo apt-get install libpq-dev -y
cargo install --version=0.7.4 sqlx-cli --no-default-features --features postgres
cd crates/iceberg-rest-server
cd crates/iceberg-catalog
sqlx database create
sqlx migrate run
env:
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
run: |
sudo apt-get install libpq-dev -y
cargo install --version=0.7.4 sqlx-cli --no-default-features --features postgres
cd crates/iceberg-rest-server
cd crates/iceberg-catalog
sqlx database create
sqlx migrate run
env:
Expand All @@ -183,7 +183,7 @@ jobs:
run: cargo test --no-fail-fast --all-targets --all-features --workspace
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres

- name: Doc Test
run: cargo test --no-fail-fast --doc --all-features --workspace
env:
Expand All @@ -198,15 +198,15 @@ jobs:
- name: Restore binary
uses: actions/download-artifact@v4
with:
name: iceberg-rest-server-image
name: iceberg-catalog-image
path: artifacts

- name: Display structure of downloaded files
run: ls -Rlh artifacts

- name: Restore Docker image
run: |
docker load -i artifacts/iceberg-rest-server-amd64.tar
docker load -i artifacts/iceberg-catalog-amd64.tar
- name: Test Pyiceberg
run: |
Expand All @@ -215,7 +215,7 @@ jobs:
env:
ICEBERG_REST_TEST_SPARK_IMAGE: apache/spark:3.5.1-java17-python3
ICEBERG_REST_TEST_SERVER_IMAGE: localhost/iceberg-rest-local:amd64
ICEBERG_REST_TEST_SERVER_IMAGE: localhost/iceberg-catalog-local:amd64


test-pyspark:
Expand All @@ -227,15 +227,15 @@ jobs:
- name: Restore binary
uses: actions/download-artifact@v4
with:
name: iceberg-rest-server-image
name: iceberg-catalog-image
path: artifacts

- name: Display structure of downloaded files
run: ls -Rlh artifacts

- name: Restore Docker image
run: |
docker load -i artifacts/iceberg-rest-server-amd64.tar
docker load -i artifacts/iceberg-catalog-amd64.tar
- name: Test Pyspark
run: |
Expand All @@ -244,4 +244,4 @@ jobs:
env:
ICEBERG_REST_TEST_SPARK_IMAGE: apache/spark:3.5.1-java17-python3
ICEBERG_REST_TEST_SERVER_IMAGE: localhost/iceberg-rest-local:amd64
ICEBERG_REST_TEST_SERVER_IMAGE: localhost/iceberg-catalog-local:amd64
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[workspace]
members = [
"crates/iceberg-ext",
"crates/iceberg-rest-bin",
"crates/iceberg-rest-server",
"crates/iceberg-rest-service",
"crates/iceberg-catalog-bin",
"crates/iceberg-catalog",
]
resolver = "2"

Expand Down
47 changes: 28 additions & 19 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
## Working with SQLx
This crate uses sqlx. For development and compilation a Postgres Database is required. You can use Docker to launch one.:

This crate uses sqlx. For development and compilation a Postgres Database is required. You can use Docker to launch
one.:

```sh
docker run -d --name postgres-15 -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:15
```

The server crate folder that uses SQLx contains a `.env.sample` File.
Copy this file to `.env` and add your database credentials if they differ.

Run:

```sh
sqlx database create
sqlx migrate run
```

## Running integration test

Please check the [Integration Test Docs](tests/README.md).

## Running the binary
Expand All @@ -25,7 +31,7 @@ export ICEBERG_REST__PG_ENCRYPTION_KEY="abc"
export ICEBERG_REST__PG_DATABASE_URL_READ="postgresql://postgres:postgres@localhost/demo"
export ICEBERG_REST__PG_DATABASE_URL_WRITE="postgresql://postgres:postgres@localhost/demo"

cd src/crates/iceberg-rest-bin
cd src/crates/iceberg-catalog-bin

cargo run migrate
# Optional - get some logs:
Expand All @@ -35,34 +41,37 @@ cargo run serve

Now that the server is running, we need to create a new warehouse including its storage.
Lets assume we have an AWS S3-bucket, create a file called `create-warehouse-request.json`:

```json
{
"warehouse-name": "test",
"project-id": "00000000-0000-0000-0000-000000000000",
"storage-profile": {
"type": "s3",
"bucket": "demo-catalog-iceberg",
"key-prefix": "test_warehouse",
"assume-role-arn": null,
"endpoint": null,
"region": "eu-central-1",
"path-style-access": null
},
"storage-credential": {
"type": "s3",
"credential-type": "access-key",
"aws-access-key-id": "<my-access-key>",
"aws-secret-access-key": "<my-secret-access-key>"
}
"warehouse-name": "test",
"project-id": "00000000-0000-0000-0000-000000000000",
"storage-profile": {
"type": "s3",
"bucket": "demo-catalog-iceberg",
"key-prefix": "test_warehouse",
"assume-role-arn": null,
"endpoint": null,
"region": "eu-central-1",
"path-style-access": null
},
"storage-credential": {
"type": "s3",
"credential-type": "access-key",
"aws-access-key-id": "<my-access-key>",
"aws-secret-access-key": "<my-secret-access-key>"
}
}
```

We now create a new Warehouse by POSTing the request to the management API:

```sh
curl -X POST http://localhost:8080/management/v1/warehouse -H "Content-Type: application/json" -d @create-warehouse-request.json
```

That's it - we can now use the catalog:

```python
import pandas as pd
import pyspark
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Iceberg Rest Server
Iceberg Catalog
Copyright 2024 HANSETAG GmbH
Loading

0 comments on commit 01414ee

Please sign in to comment.