cube-js/cube · error · Error
Redshift server does not support more than 32767 parameters,
Error message
Redshift server does not support more than 32767 parameters, but ${length} passed What it means
Redshift's PostgreSQL-wire implementation breaks with more than 32767 bind parameters ('there is no parameter $-32768'), a server-side bug. RedshiftDriver.checkValuesLimit proactively throws a clear error when a query would send 32768+ parameter values.
Source
Thrown at packages/cubejs-redshift-driver/src/RedshiftDriver.ts:294
protected getInitialConfiguration(
dataSource: string,
preAggregations?: boolean,
): Partial<RedshiftDriverConfiguration> {
return {
// @todo It's not possible to support UNLOAD in readOnly mode, because we need column types (CREATE TABLE?)
readOnly: false,
exportBucket: this.getExportBucket(dataSource, preAggregations),
};
}
protected static checkValuesLimit(values?: unknown[]) {
// Redshift server is not exactly compatible with PostgreSQL protocol
// And breaks after 32767 parameter values with `there is no parameter $-32768`
// This is a bug/misbehaviour on server side, nothing we can do besides generate a more meaningful error
const length = (values?.length ?? 0);
if (length >= 32768) {
throw new Error(`Redshift server does not support more than 32767 parameters, but ${length} passed`);
}
}
public override async createTable(quotedTableName: string, columns: TableColumn[]): Promise<void> {
if (quotedTableName.length > 127) {
throw new Error('Redshift can not work with table names longer than 127 symbols. ' +
`Consider using the 'sqlAlias' attribute in your cube definition for ${quotedTableName}.`);
}
// we can not call super.createTable(quotedTableName, columns)
// because Postgres has 63 length check. So pasting the code from the base driver
const createTableSql = this.createTableSql(quotedTableName, columns);
await this.query(createTableSql, []).catch(e => {
e.message = `Error during create table: ${createTableSql}: ${e.message}`;
throw e;
});
}
/**View on GitHub (pinned to 7d981676b3)
Solutions
- Chunk the upload/insert into batches under 32767 parameters (rows * columns per batch)
- Upgrade cubejs-redshift-driver — newer versions chunk large uploads automatically
- Use a COPY-based load path (S3 + COPY) for large data loads instead of parameterized INSERTs
- Reduce the number of filtered values in generated queries
Example fix
// before
await driver.uploadTable(table, columns, { rows: allRows }); // 100k rows
// after
for (const chunk of chunk(allRows, 5000)) {
await driver.uploadTable(table, columns, { rows: chunk });
} Defensive patterns
Strategy: validation
Validate before calling
if ((values?.length ?? 0) >= 32768) throw new Error('Chunk query values below 32767 for Redshift'); Type guard
function withinParamLimit(values) { return Array.isArray(values) && values.length < 32768; } Try / catch
try { await driver.uploadTable(table, columns, { rows }); } catch (e) { if (e.message.includes('more than 32767 parameters')) { return uploadInChunks(table, columns, rows); } throw e; } Prevention
- Chunk bulk inserts so rows * columns stays under 32767
- Use S3 COPY for large loads instead of parameterized inserts
- Limit IN-clause sizes in generated queries
- Keep the redshift driver updated for automatic chunking
When it happens
Trigger: Executing a query (query/checkValuesLimit called from executeMethods like uploadTable bulk inserts or large IN filters) with a values array of length >= 32768.
Common situations: Uploading a pre-aggregation table with tens of thousands of rows in a single multi-row INSERT; filtering on a dimension with a very large member list (huge IN clause); bulk load of large dimension tables.
Related errors
- GetClusterCredentialsWithIAM returned incomplete response
- Driver's .streamQuery() method is not implemented yet.
- ${this.constructor} driver supports only rows upload
- CUBEJS_DB_NAME can`t be empty.
- Please specify CUBEJS_DB_URL
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/4e40fc76fb954fb7.
Report an issue: GitHub.