Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions .github/workflows/quickstart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Quickstart (weekly)

# Verifies that ./scripts/quickstart.sh runs end-to-end on clean
# GitHub-hosted runners — the same surface a self-hosting user hits
# on `git clone && ./scripts/quickstart.sh`. If this goes red, the
# README's recommended path is broken regardless of which PM filed it.
#
# Schedule: Mondays 06:00 UTC. Also dispatchable on demand and on
# pushes that touch the script or workflow itself.

on:
schedule:
- cron: '0 6 * * 1'
workflow_dispatch:
push:
paths:
- 'scripts/quickstart.sh'
- '.github/workflows/quickstart.yml'

env:
CARGO_TERM_COLOR: always
CARGO_PROFILE_DEV_DEBUG: 'line-tables-only'
CARGO_INCREMENTAL: '0'
CARGO_NET_RETRY: '5'

jobs:
quickstart:
name: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

# Reclaim disk on Linux — `duckdb-rs` (bundled) compiles a full
# DuckDB tree from cargo and easily overflows the ~14 GB free
# on GH-hosted Ubuntu runners. macOS runners have plenty of room.
- name: Free disk space (Linux)
if: runner.os == 'Linux'
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true

- uses: dtolnay/rust-toolchain@stable

# Warm cargo cache so subsequent runs hit the <15 min target;
# cold first runs may exceed it (this is documented in the
# quickstart script header).
- uses: Swatinem/rust-cache@v2
with:
key: quickstart-${{ matrix.os }}

# ── Linux: docker is pre-installed; quickstart runs the default path. ─
- name: Install prereqs (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
protobuf-compiler postgresql-client libfuse3-dev pkg-config

- name: Run quickstart (Linux)
if: runner.os == 'Linux'
run: ./scripts/quickstart.sh --no-color

# ── macOS: GH runners don't ship Docker. Use Homebrew Postgres + ─────
# `--skip-docker`. Postgres listens on 5432 here, not the 5433
# the dockerised path uses, so we redirect via env.
- name: Install prereqs (macOS)
if: runner.os == 'macOS'
run: |
brew install protobuf libpq postgresql@16
# libpq is keg-only; expose pg_isready / psql on PATH.
echo "$(brew --prefix libpq)/bin" >> "$GITHUB_PATH"
echo "$(brew --prefix postgresql@16)/bin" >> "$GITHUB_PATH"

- name: Start native Postgres (macOS)
if: runner.os == 'macOS'
run: |
brew services start postgresql@16
# Wait for it before we hand off to the script (the script
# will also wait, this just gives a clearer error if the
# service failed to come up).
for i in $(seq 1 30); do
pg_isready -h localhost -p 5432 -q && break
sleep 1
done
# Create the role + database the quickstart expects. Owner
# of the Homebrew install is the runner user, so we connect
# as that user (no password).
psql -h localhost -p 5432 -d postgres -c \
"CREATE ROLE openduck WITH LOGIN PASSWORD 'openduck' SUPERUSER" || true
psql -h localhost -p 5432 -d postgres -c \
"CREATE DATABASE openduck_meta OWNER openduck" || true

- name: Run quickstart (macOS)
if: runner.os == 'macOS'
env:
PG_PORT: '5432'
DATABASE_URL: postgres://openduck:openduck@localhost:5432/openduck_meta
run: ./scripts/quickstart.sh --no-color --skip-docker

- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: quickstart-logs-${{ matrix.os }}
path: .openduck-quickstart-logs/
if-no-files-found: ignore
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@
/docs/internal/
/target/
mydb
.cache/*
.cache/*
*.pyc
*.egg-info/

# scripts/quickstart.sh runtime state
.openduck-data/
.openduck-quickstart-logs/
.openduck-quickstart.pids
94 changes: 94 additions & 0 deletions extensions/openduck/.github/workflows/MainDistributionPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,97 @@ jobs:
deploy_latest: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
deploy_versioned: ${{ startsWith(github.ref, 'refs/tags/v') }}
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_mingw;windows_amd64_rtools;linux_amd64_musl;linux_arm64_musl'

# On v* tag pushes, attach pre-built extension binaries for the four
# quickstart triples (linux x86_64/arm64, mac x86_64/arm64) to the
# GitHub release so the README quickstart becomes "curl + LOAD".
#
# Artifacts come from the same `duckdb-stable-build` matrix CI runs on
# every push, so the published binaries are reproducible from a clean
# runner. Upstream uploads each platform under
# `openduck-${duckdb_version}-extension-${arch}`
# containing a single `openduck.duckdb_extension` file (see
# extension-ci-tools/.github/workflows/_extension_distribution.yml).
github-release:
name: Attach binaries to GitHub release
needs: duckdb-stable-build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
env:
DUCKDB_VERSION: v1.5.1
EXT_NAME: openduck
steps:
- name: Download linux_amd64 extension
uses: actions/download-artifact@v4
with:
name: openduck-v1.5.1-extension-linux_amd64
path: dist/linux_amd64
- name: Download linux_arm64 extension
uses: actions/download-artifact@v4
with:
name: openduck-v1.5.1-extension-linux_arm64
path: dist/linux_arm64
- name: Download osx_amd64 extension
uses: actions/download-artifact@v4
with:
name: openduck-v1.5.1-extension-osx_amd64
path: dist/osx_amd64
- name: Download osx_arm64 extension
uses: actions/download-artifact@v4
with:
name: openduck-v1.5.1-extension-osx_arm64
path: dist/osx_arm64

- name: Stage release assets
run: |
set -euo pipefail
TAG="${GITHUB_REF_NAME}"
mkdir -p release
for arch in linux_amd64 linux_arm64 osx_amd64 osx_arm64; do
src="dist/${arch}/${EXT_NAME}.duckdb_extension"
dst="release/${EXT_NAME}-${TAG}-${arch}.duckdb_extension"
if [ ! -f "$src" ]; then
echo "Missing artifact: $src" >&2
exit 1
fi
cp "$src" "$dst"
done
( cd release && sha256sum *.duckdb_extension > "${EXT_NAME}-${TAG}-SHA256SUMS.txt" )
ls -l release

- name: Create or update GitHub release
uses: softprops/action-gh-release@v2
with:
files: release/*
fail_on_unmatched_files: true
generate_release_notes: true
body: |
## Pre-built `openduck` extension binaries

Loadable DuckDB extension binaries built against DuckDB ${{ env.DUCKDB_VERSION }}.

| Platform | Asset |
| --------------- | ---------------------------------------------------------------------- |
| macOS (Apple Silicon) | `openduck-${{ github.ref_name }}-osx_arm64.duckdb_extension` |
| macOS (Intel) | `openduck-${{ github.ref_name }}-osx_amd64.duckdb_extension` |
| Linux x86_64 | `openduck-${{ github.ref_name }}-linux_amd64.duckdb_extension` |
| Linux arm64 | `openduck-${{ github.ref_name }}-linux_arm64.duckdb_extension` |

SHA-256 checksums are in `openduck-${{ github.ref_name }}-SHA256SUMS.txt`.

**Quickstart:**

```sh
curl -L -o openduck.duckdb_extension \
https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/openduck-${{ github.ref_name }}-osx_arm64.duckdb_extension

duckdb -unsigned -c "
LOAD '$(pwd)/openduck.duckdb_extension';
ATTACH 'openduck:mydb?endpoint=http://localhost:7878&token=...' AS cloud;
SELECT * FROM cloud.users LIMIT 10;
"
```

See the [extension README](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/extensions/openduck/README.md) for full quickstart instructions.
84 changes: 72 additions & 12 deletions extensions/openduck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The gateway includes a plan splitter that assigns `LOCAL` or `REMOTE` placement
```

**3. Open protocol — anyone can implement the backend.**
The data plane is two RPCs in a single `.proto` file (plus two for worker lifecycle). Any service that accepts SQL and streams Arrow IPC batches is a compatible backend. The extension is the universal DuckDB client.
Eight RPCs in a single `.proto` file: three data plane (`ExecuteFragment`, `CancelExecution`, `IngestData`), three transactions (`BeginTransaction`, `CommitTransaction`, `RollbackTransaction`), and two worker lifecycle (`RegisterWorker`, `Heartbeat`). Any service that implements them — accepting SQL and streaming Arrow IPC batches back — is a compatible backend. The extension is the universal DuckDB client.

## Usage

Expand Down Expand Up @@ -101,14 +101,65 @@ od:<database>?endpoint=<url>&token=<token>

## Registered storage schemes

| Scheme | Example |
|--------|---------|
| `openduck:` | `ATTACH 'openduck:mydb?token=xxx' AS cloud;` |
| `od:` | `ATTACH 'od:mydb?token=xxx' AS cloud;` |
| Scheme | Example | What it does |
|--------|---------|--------------|
| `openduck:` | `ATTACH 'openduck:mydb?endpoint=...&token=xxx' AS cloud;` | Gateway/worker remote attach. Stores in plain DuckDB files on the worker; **no differential storage in v0.1** (planned for v0.2 — see [`docs/internal/DIFFERENTIAL_STORAGE_E2E.md`](../../docs/internal/DIFFERENTIAL_STORAGE_E2E.md)). |
| `od:` | `ATTACH 'od:mydb?endpoint=...&token=xxx' AS cloud;` | Alias for `openduck:`. Same gateway/worker semantics. |
| `openduck://` | `ATTACH 'openduck://mydb/database.duckdb?secret=prod_storage' AS db;` | In-process FileSystem. Routes DuckDB I/O through differential storage when the extension is built with `OPENDUCK_BRIDGE_LIB`. Supports `?snapshot=<uuid>` for read-only point-in-time attaches. Falls back to in-memory storage (with a warning) when the bridge is not linked. |

## Building
> **Differential storage paths (v0.1):** the `openduck://` in-process scheme is the only path that touches `StorageBackend`. The gateway/worker `openduck:` path stores in plain DuckDB files; snapshot reads (`?snapshot=`), seal-on-commit, and `openduck_current_snapshot()` over the gateway path are tracked in [`docs/internal/DIFFERENTIAL_STORAGE_E2E.md`](../../docs/internal/DIFFERENTIAL_STORAGE_E2E.md) and ship in v0.2.

### Prerequisites
## Install

### Pre-built binaries (recommended)

Tagged releases ship pre-built `openduck.duckdb_extension` binaries for four
platforms — no toolchain install required. Download the asset for your
platform, verify the checksum, and `LOAD` it.

| Platform | Asset |
| ----------------------- | ---------------------------------------------------- |
| macOS (Apple Silicon) | `openduck-<tag>-osx_arm64.duckdb_extension` |
| macOS (Intel) | `openduck-<tag>-osx_amd64.duckdb_extension` |
| Linux x86_64 | `openduck-<tag>-linux_amd64.duckdb_extension` |
| Linux arm64 | `openduck-<tag>-linux_arm64.duckdb_extension` |

```sh
TAG=v0.1.0 # latest release tag
PLATFORM=osx_arm64 # one of: osx_arm64, osx_amd64, linux_amd64, linux_arm64
BASE="https://github.com/CITGuru/openduck/releases/download/${TAG}"

curl -L -o openduck.duckdb_extension \
"${BASE}/openduck-${TAG}-${PLATFORM}.duckdb_extension"
curl -L -o SHA256SUMS.txt "${BASE}/openduck-${TAG}-SHA256SUMS.txt"

# Verify
grep "openduck-${TAG}-${PLATFORM}.duckdb_extension" SHA256SUMS.txt \
| sed "s|openduck-${TAG}-${PLATFORM}.duckdb_extension|openduck.duckdb_extension|" \
| sha256sum -c -
```

Then load it from any DuckDB client (the extension is unsigned, so the
`-unsigned` flag / `allow_unsigned_extensions` setting is required):

```sh
duckdb -unsigned -c "
LOAD '$(pwd)/openduck.duckdb_extension';
ATTACH 'openduck:mydb?endpoint=http://localhost:7878&token=...' AS cloud;
SELECT * FROM cloud.users LIMIT 10;
"
```

> **Note:** Once the extension is published to DuckDB's community-extensions
> repository, `INSTALL openduck FROM community; LOAD openduck;` will work
> without any download or `-unsigned` flag.

### Build from source (fallback)

Use this path when there is no release for your platform or you need to test
local changes.

#### Prerequisites

- CMake 3.5+, C++17 compiler
- gRPC, Protobuf, and Apache Arrow C++ libraries
Expand All @@ -127,7 +178,7 @@ git clone https://github.com/Microsoft/vcpkg.git
export VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake
```

### Build
#### Build

```sh
make
Expand All @@ -140,22 +191,31 @@ Output:
./build/release/extension/openduck/openduck.duckdb_extension # Loadable binary
```

### Test
#### Test

```sh
make test
```

## Protocol

The extension communicates with backends using the OpenDuck Protocol defined in [`execution.proto`](../../proto/openduck/v1/execution.proto):
The extension communicates with backends using the OpenDuck Protocol defined in [`execution.proto`](../../proto/openduck/v1/execution.proto). One service, eight RPCs:

### Data plane

| RPC | Purpose |
|-----|---------|
| `ExecuteFragment` | Send SQL (or plan IR), stream back Arrow IPC batches |
| `CancelExecution` | Cancel a running execution by ID (requires `access_token`) |
| `IngestData` | Client-streaming: push Arrow IPC batches into a worker-side `TEMP TABLE` for cross-catalog writes |

### Transactions

| RPC | Purpose |
|-----|---------|
| `BeginTransaction` | Open a transaction; returns an opaque `transaction_id` pinned to a worker connection |
| `CommitTransaction` | Commit the pinned transaction |
| `RollbackTransaction` | Roll back the pinned transaction |

### Worker lifecycle (gateway-side)

Expand All @@ -164,6 +224,6 @@ The extension communicates with backends using the OpenDuck Protocol defined in
| `RegisterWorker` | Worker self-registers with database affinity and capabilities |
| `Heartbeat` | Worker sends periodic keepalives to maintain registration |

All RPCs validate `access_token` when `OPENDUCK_TOKEN` is set. The extension sends the token on both `ExecuteFragment` and `CancelExecution` calls.
All RPCs validate `access_token` when `OPENDUCK_TOKEN` is set. The extension sends the token on every call.

Any service implementing the data plane RPCs is a compatible backend. See the [top-level README](../../README.md) for comparisons with Arrow Flight SQL and MotherDuck.
Any service implementing these RPCs is a compatible backend. See the [top-level README](../../README.md) for comparisons with Arrow Flight SQL and MotherDuck.
Loading
Loading