{"record":{"id":"4e40fc76fb954fb7","repo":"cube-js/cube","slug":"redshift-server-does-not-support-more-than-32767-p","errorCode":null,"errorMessage":"Redshift server does not support more than 32767 parameters, but ${length} passed","messagePattern":"Redshift server does not support more than 32767 parameters, but (.+?) passed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-redshift-driver/src/RedshiftDriver.ts","lineNumber":294,"sourceCode":"  protected getInitialConfiguration(\n    dataSource: string,\n    preAggregations?: boolean,\n  ): Partial<RedshiftDriverConfiguration> {\n    return {\n      // @todo It's not possible to support UNLOAD in readOnly mode, because we need column types (CREATE TABLE?)\n      readOnly: false,\n      exportBucket: this.getExportBucket(dataSource, preAggregations),\n    };\n  }\n\n  protected static checkValuesLimit(values?: unknown[]) {\n    // Redshift server is not exactly compatible with PostgreSQL protocol\n    // And breaks after 32767 parameter values with `there is no parameter $-32768`\n    // This is a bug/misbehaviour on server side, nothing we can do besides generate a more meaningful error\n    const length = (values?.length ?? 0);\n    if (length >= 32768) {\n      throw new Error(`Redshift server does not support more than 32767 parameters, but ${length} passed`);\n    }\n  }\n\n  public override async createTable(quotedTableName: string, columns: TableColumn[]): Promise<void> {\n    if (quotedTableName.length > 127) {\n      throw new Error('Redshift can not work with table names longer than 127 symbols. ' +\n        `Consider using the 'sqlAlias' attribute in your cube definition for ${quotedTableName}.`);\n    }\n\n    // we can not call super.createTable(quotedTableName, columns)\n    // because Postgres has 63 length check. So pasting the code from the base driver\n    const createTableSql = this.createTableSql(quotedTableName, columns);\n    await this.query(createTableSql, []).catch(e => {\n      e.message = `Error during create table: ${createTableSql}: ${e.message}`;\n      throw e;\n    });\n  }\n\n  /**","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-redshift-driver/src/RedshiftDriver.ts#L276-L312","documentation":"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.","triggerScenarios":"Executing a query (query/checkValuesLimit called from executeMethods like uploadTable bulk inserts or large IN filters) with a values array of length >= 32768.","commonSituations":"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.","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"],"exampleFix":"// before\nawait driver.uploadTable(table, columns, { rows: allRows }); // 100k rows\n// after\nfor (const chunk of chunk(allRows, 5000)) {\n  await driver.uploadTable(table, columns, { rows: chunk });\n}","handlingStrategy":"validation","validationCode":"if ((values?.length ?? 0) >= 32768) throw new Error('Chunk query values below 32767 for Redshift');","typeGuard":"function withinParamLimit(values) { return Array.isArray(values) && values.length < 32768; }","tryCatchPattern":"try { await driver.uploadTable(table, columns, { rows }); } catch (e) { if (e.message.includes('more than 32767 parameters')) { return uploadInChunks(table, columns, rows); } throw e; }","preventionTips":["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"],"tags":["redshift","parameter-limit","driver"],"backgroundTag":"parameter-limit-exceeded","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}