Skip to content
Pivot is in early development and is not production ready. See Project status.

CREATE TABLE

CREATE TABLE creates an empty table or registers existing Parquet files as a new table’s initial data.

CREATE TABLE events (
id BIGINT,
region VARCHAR,
ts TIMESTAMP
);
CREATE TABLE [IF NOT EXISTS] [[datastore.]schema.]table (
column_name data_type [, ...]
) [WITH (option = value [, ...])];

Use schema.table or datastore.schema.table to choose a namespace. The schema must exist; create one with CREATE SCHEMA. Unqualified names use the default datastore and schema.

Each column has a name and a data type. IF NOT EXISTS leaves an existing table in place.

WITH (...) accepts the following options. Unknown option names are rejected.

Option Value Purpose
partition_by Comma-separated column names in a string Partition newly written files.
sort_by Comma-separated column names in a string Sort newly written rows.
with_pre_existing_parquets Directory path in a string Adopt existing Parquet files.

partition_by selects partition columns in the declared order. Every named column must exist in the table declaration.

CREATE TABLE regional_events (id BIGINT, region VARCHAR)
WITH (partition_by = 'region');

sort_by selects sort columns in the declared order. It can be combined with partitioning:

CREATE TABLE sorted_events (id BIGINT, region VARCHAR, ts TIMESTAMP)
WITH (partition_by = 'region', sort_by = 'ts');

Sorting controls the layout of newly written rows. Use ORDER BY in a query when its returned rows need a particular order.

with_pre_existing_parquets adopts Parquet files directly under a directory. The declared schema must match those files.

CREATE TABLE imported_events (id BIGINT, region VARCHAR, ts TIMESTAMP)
WITH (with_pre_existing_parquets = 'incoming/events');

The option takes a plain storage path, not a URL. A relative path is resolved within the datastore’s storage. Files remain in their original directory; Pivot records them in the new table without moving or rewriting them during creation.

Temporary tables, constraints, CREATE OR REPLACE TABLE, and CREATE TABLE ... AS SELECT are not supported.