Quickstart
Start Pivot, load some data, and run your first queries.
1. Start Pivot
Section titled “1. Start Pivot”Pivot runs either as a local SQL shell, or as a server that Postgres clients connect to. Choose the option that fits, then where your data lives: an existing Iceberg catalog, or a Pivot datastore in Amazon S3 or Google Cloud Storage.
Best for: trying Pivot on your own machine, with no server to run and no client to install.
Install the Pivot CLI on Linux:
curl https://pivotlake.io | shThen open your data:
Give Pivot the catalog’s credential, then open the Iceberg REST catalog:
export PIVOT_ICEBERG_CREDENTIAL=client-id:client-secret# Or, for a catalog that issues bearer tokens:# export PIVOT_ICEBERG_TOKEN=your-token
pivot open --kind iceberg https://catalog.example.com/api --warehouse mywarehouseEach catalog namespace appears as a schema. Table files are read with the credentials the catalog vends; if it vends none, also export your object-store credentials.
Export your AWS credentials and region, then open a datastore from its location in S3:
export AWS_ACCESS_KEY_ID=your-access-key-idexport AWS_SECRET_ACCESS_KEY=your-secret-access-keyexport AWS_REGION=us-east-1
pivot open s3://my-bucket/pivot-dataLog in with Application Default Credentials, then open a datastore from its location in Google Cloud Storage:
gcloud auth application-default login
pivot open gs://my-bucket/pivot-dataPivot opens an interactive SQL prompt, and your data stays where it is
after you exit with \q. See the CLI reference
for options, credentials,
and shell commands.
Best for: running a server with minimal setup.
Write pivot-data/metastore.yaml with an
Iceberg datastore
named lake:
datastores: lake: kind: iceberg uri: https://catalog.example.com/api warehouse: mywarehouse secret: lake-catalog default: truesecrets: lake-catalog: type: iceberg credential: client-id:client-secretThen mount its directory over /var/lib/pivot and start the server:
# seccomp=unconfined allows io_uring, which Docker's default profile blocksdocker run --rm --name pivot \ -p 5432:5432 \ --security-opt seccomp=unconfined \ -v "$PWD/pivot-data:/var/lib/pivot" \ pivotlake/pivot:latestStart the server with the datastore’s location in S3, and pass your AWS credentials and region:
# seccomp=unconfined allows io_uring, which Docker's default profile blocksdocker run --rm --name pivot \ -p 5432:5432 \ --security-opt seccomp=unconfined \ -e PIVOT_DATASTORE=s3://my-bucket/pivot-data \ -e AWS_ACCESS_KEY_ID=your-access-key-id \ -e AWS_SECRET_ACCESS_KEY=your-secret-access-key \ -e AWS_REGION=us-east-1 \ pivotlake/pivot:latestFor MinIO or another S3-compatible service, also add
-e AWS_ENDPOINT_URL=http://minio:9000. The image generates a
metastore for the location on startup, and the datastore remains in
your bucket after the container exits.
Start the server with the datastore’s location in Google Cloud
Storage, mounting a service-account key file and pointing
GOOGLE_APPLICATION_CREDENTIALS at it:
# seccomp=unconfined allows io_uring, which Docker's default profile blocksdocker run --rm --name pivot \ -p 5432:5432 \ --security-opt seccomp=unconfined \ -e PIVOT_DATASTORE=gs://my-bucket/pivot-data \ -e GOOGLE_APPLICATION_CREDENTIALS=/etc/pivot/gcs-key.json \ -v "$PWD/gcs-key.json:/etc/pivot/gcs-key.json:ro" \ pivotlake/pivot:latestThe image generates a metastore for the location on startup, and the datastore remains in your bucket after the container exits.
In a second terminal, connect with any Postgres client:
psql -h 127.0.0.1 -p 5432 -U pivotBest for: a persistent production database endpoint for applications, BI tools, and other Postgres clients.
Install Pivot from the Debian or Ubuntu package repository:
sudo apt-get updatesudo apt-get install -y ca-certificates curl gnupgcurl -fsSL https://packages.pivotlake.io/keys/pivotlake-archive-key.asc | sudo gpg --dearmor --yes -o /usr/share/keyrings/pivotlake-archive-keyring.gpg
ARCH=$(dpkg --print-architecture)echo "deb [signed-by=/usr/share/keyrings/pivotlake-archive-keyring.gpg arch=${ARCH}] https://packages.pivotlake.io/deb stable main" | sudo tee /etc/apt/sources.list.d/pivotlake.listsudo apt-get updatesudo apt-get install -y pivotUse testing instead of stable in the repository line to receive release
candidates. The package starts Pivot immediately and enables it at boot,
serving a local datastore. Check the service:
sudo systemctl status pivotTo serve your own data, edit /etc/pivot/config.yaml (see
Datastores & storage credentials):
Add an Iceberg datastore
named lake next to the default one, and its catalog credential:
datastores: lake: kind: iceberg uri: https://catalog.example.com/api warehouse: mywarehouse secret: lake-catalogsecrets: lake-catalog: type: iceberg credential: client-id:client-secretPoint the default datastore at your bucket, and add a secret for it:
datastores: default: kind: pivot location: s3://my-bucket/pivot-data default: truesecrets: my-bucket: type: s3 scope: s3://my-bucket/ region: us-east-1 access_key_id: your-access-key-id secret_access_key: your-secret-access-keyPoint the default datastore at your bucket, and add a secret with a
service-account key file:
datastores: default: kind: pivot location: gs://my-bucket/pivot-data default: truesecrets: my-bucket: type: gcs scope: gs://my-bucket/ credentials_file: /etc/pivot/gcs-key.jsonRestart the server to apply it, then connect with any Postgres client:
sudo systemctl restart pivotpsql -h 127.0.0.1 -p 5432 -U pivot2. Load data
Section titled “2. Load data”As an example, create a table of NYC taxi trips, then fill it three ways: with
SQL, from Parquet in object storage, and from raw Arrow IPC data with \copy.
CREATE TABLE trips ( vendor_id INTEGER, pickup_at TIMESTAMP, dropoff_at TIMESTAMP, passenger_count BIGINT, trip_distance DOUBLE, pickup_location_id INTEGER, dropoff_location_id INTEGER, fare_amount DOUBLE, tip_amount DOUBLE, total_amount DOUBLE) WITH (sort_by = 'pickup_at');-- Insert rows with SQLINSERT INTO trips VALUES (2, '2024-01-01 00:57:55', '2024-01-01 01:17:43', 1, 1.72, 186, 79, 17.7, 0.0, 22.7), (1, '2024-01-01 00:03:00', '2024-01-01 00:09:36', 1, 1.8, 140, 236, 10.0, 3.75, 18.75);
-- Load January 2024 (about 3 million trips) from Parquet in a public bucketINSERT INTO tripsSELECT VendorID, tpep_pickup_datetime, tpep_dropoff_datetime, passenger_count, trip_distance, PULocationID, DOLocationID, fare_amount, tip_amount, total_amountFROM read_parquet('s3://pivotlake-examples/nyc-taxi/yellow_tripdata_2024-01.parquet');
-- Ingest raw Arrow IPC data from a local file (works in psql too). Download it first:-- curl -O https://pivotlake-examples.s3.amazonaws.com/nyc-taxi/yellow_tripdata_2024-02_sample.arrow\copy trips FROM 'yellow_tripdata_2024-02_sample.arrow' WITH (FORMAT arrow)3. Query
Section titled “3. Query”Find January’s busiest days and their average tip:
SELECT date_trunc('day', pickup_at) AS day, count(*) AS trips, CAST(avg(tip_amount) AS DECIMAL(10, 2)) AS avg_tipFROM tripsWHERE pickup_at >= '2024-01-01' AND pickup_at < '2024-02-01'GROUP BY dayORDER BY trips DESCLIMIT 5; day | trips | avg_tip---------------------+--------+--------- 2024-01-27 00:00:00 | 110515 | 3.10 2024-01-17 00:00:00 | 110365 | 3.35 2024-01-18 00:00:00 | 110358 | 3.36 2024-01-25 00:00:00 | 110318 | 3.48 2024-01-20 00:00:00 | 108768 | 2.92(5 rows)Or see how tipping changes with the number of passengers:
SELECT passenger_count, count(*) AS trips, CAST(avg(tip_amount / NULLIF(fare_amount, 0)) * 100 AS DECIMAL(10, 1)) AS tip_percentFROM tripsWHERE passenger_count BETWEEN 1 AND 6GROUP BY passenger_countORDER BY passenger_count; passenger_count | trips | tip_percent-----------------+---------+------------- 1 | 2271171 | 23.7 2 | 416662 | 20.7 3 | 93344 | 21.0 4 | 53029 | 18.0 5 | 34516 | 21.4 6 | 23040 | 21.5(6 rows)Next steps
Section titled “Next steps”- SQL reference: the statements and functions Pivot supports.
- CLI reference: every
pivot openoption and shell command. - Configuration file and Datastores & storage credentials: set up a server for your own data.
Build from source
Section titled “Build from source”To build the same executable from the repository:
cargo build --release -p bin --bin pivotRun the local shell directly from the build output:
./target/release/pivot open ./pivot-dataTo run a server from the build output, copy
bin/config.example.yaml,
adjust its datastore locations, and start Pivot with:
./target/release/pivot server --config pivot.yaml