Redshift
Amazon Redshift support with PostgreSQL-compatible dialect, columnar storage types, and SUPER semi-structured data type.
Overview
Section titled “Overview”Amazon Redshift is a cloud data warehouse based on PostgreSQL. It uses the PostgreSQL wire protocol and a compatible SQL dialect, with additions like the SUPER type for semi-structured data, IDENTITY columns, and columnar storage optimizations. Scythe reuses PostgreSQL backends with Redshift-specific manifests.
Engine alias
Section titled “Engine alias”[[sql]]engine = "redshift"Supported backends
Section titled “Supported backends”Redshift uses PostgreSQL backends:
| Backend | Language | Driver |
|---|---|---|
rust-sqlx |
Rust | sqlx (PostgreSQL driver) |
rust-tokio-postgres |
Rust | tokio-postgres |
python-psycopg3 |
Python | psycopg3 |
python-asyncpg |
Python | asyncpg |
typescript-pg |
TypeScript | pg (node-postgres) |
typescript-postgres |
TypeScript | postgres.js |
go-pgx |
Go | pgx v5 |
java-jdbc |
Java | JDBC (Redshift JDBC driver) |
kotlin-jdbc |
Kotlin | JDBC (Redshift JDBC driver) |
csharp-npgsql |
C# | Npgsql |
elixir-postgrex |
Elixir | Postgrex |
ruby-pg |
Ruby | pg gem |
php-pdo |
PHP | PDO (pgsql driver) |
typescript-kysely |
TypeScript | Kysely |
Configuration
Section titled “Configuration”[[sql]]name = "main"engine = "redshift"schema = ["schema.sql"]queries = ["queries/"]
[[sql.gen]]backend = "python-psycopg3"output = "src/generated"Differences from PostgreSQL
Section titled “Differences from PostgreSQL”| Feature | PostgreSQL | Redshift |
|---|---|---|
SERIAL |
Sequence-backed auto-increment | Not supported (use IDENTITY) |
ENUM types |
CREATE TYPE ... AS ENUM |
Not supported |
ARRAY types |
Native TEXT[], INT[] |
Not supported |
| Range types | int4range, tstzrange |
Not supported |
SUPER |
Not available | Semi-structured data type |
IDENTITY |
Standard identity columns | IDENTITY(seed, step) |
HLLSKETCH |
Not available | HyperLogLog sketch type |
GEOMETRY / GEOGRAPHY |
PostGIS extension | Native spatial types |
Type mapping table
Section titled “Type mapping table”| Redshift Type | Neutral Type | Notes |
|---|---|---|
INTEGER / INT / INT4 |
int32 |
|
BIGINT / INT8 |
int64 |
|
SMALLINT / INT2 |
int16 |
|
REAL / FLOAT4 |
float32 |
|
DOUBLE PRECISION / FLOAT8 |
float64 |
|
DECIMAL / NUMERIC |
decimal |
|
VARCHAR / CHAR / TEXT |
string |
|
BOOLEAN / BOOL |
bool |
|
DATE |
date |
|
TIME |
time |
|
TIMETZ |
time_tz |
|
TIMESTAMP |
datetime |
|
TIMESTAMPTZ |
datetime_tz |
|
SUPER |
json |
Semi-structured data |
GEOMETRY |
string |
Spatial type |
GEOGRAPHY |
string |
Spatial type |
BPCHAR, VARBYTE/BINARY VARYING, and HLLSKETCH have no type mapping. A column declared with
any of these fails code generation.
Placeholder syntax
Section titled “Placeholder syntax”Redshift uses PostgreSQL positional $N placeholders:
SELECT id, name FROM users WHERE id = $1;- No ENUM or ARRAY – Redshift does not support PostgreSQL
ENUMorARRAYtypes. UseVARCHARwith check constraints for enum-like behavior, and normalize arrays into separate tables. - IDENTITY columns – Use
IDENTITY(1,1)instead ofSERIAL. Scythe strips theIDENTITY(seed, step)clause when parsing; the column is nullable unless it also declaresNOT NULLorPRIMARY KEY, same as any other column. Unlike PostgreSQL’sSERIAL,IDENTITYalone does not imply NOT NULL. - SUPER type – Redshift’s
SUPERtype stores semi-structured data (JSON-like). Scythe maps it to thejsonneutral type. - Cloud-only with local testing – Redshift is a cloud service, but you can use PostgreSQL locally for
development since they share the same wire protocol.
engine = "redshift"selects Redshift-specific backend manifests (driver imports, connection setup); analyzer type inference is identical toengine = "postgresql". - QUALIFY clause – Redshift does not support
QUALIFY. Use subqueries with window functions instead.