{"record":{"id":"96dbc6b88f4f3e62","repo":"cube-js/cube","slug":"redshift-can-not-work-with-table-names-longer-than","errorCode":null,"errorMessage":"Redshift can not work with table names longer than 127 symbols. Consider using the 'sqlAlias' attribute in your cube definition for ${quotedTableName}.","messagePattern":"Redshift can not work with table names longer than 127 symbols\\. Consider using the 'sqlAlias' attribute in your cube definition for (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-redshift-driver/src/RedshiftDriver.ts","lineNumber":299,"sourceCode":"      // @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  /**\n   * AWS Redshift doesn't have any special connection check.\n   * And querying even system tables is billed.\n   * @override\n   */\n  public override async testConnection() {","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-redshift-driver/src/RedshiftDriver.ts#L281-L317","documentation":"Redshift limits identifiers (table names) to 127 characters. Cube generates pre-aggregation table names from cube/members names, which can exceed that limit. The driver refuses to create the table and suggests using the 'sqlAlias' attribute to shorten the generated name.","triggerScenarios":"Calling createTable(quotedTableName, columns) where the fully quoted table name string is longer than 127 characters — typically during pre-aggregation creation with deeply nested or very long cube/member names.","commonSituations":"Long cube names, long member names, or multi-hop joins that inflate the auto-generated pre-aggregation table identifier; happens after upgrading Cube or adding pre-aggregations to cubes with verbose naming.","solutions":["Add sqlAlias: '<short-name>' to the cube (or pre-aggregation) definition to shorten generated table names","Shorten the cube and/or member names in the data model","Reduce the pre-aggregation name / member list so the derived table identifier fits within 127 chars"],"exampleFix":"// before\ncube('VeryLongSalesAnalyticsFactTableWithRegionalPartitioning', {\n  sql: () => 'SELECT * FROM sales'\n});\n// after\ncube('VeryLongSalesAnalyticsFactTableWithRegionalPartitioning', {\n  sql: () => 'SELECT * FROM sales',\n  sqlAlias: 'sales_fact'\n});","handlingStrategy":"validation","validationCode":"const quoted = driver.quoteIdentifier ? '' : '\"';\nif (quotedTableName.length > 127) {\n  throw new Error(`Table identifier exceeds Redshift 127-char limit: ${quotedTableName.length} chars`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set sqlAlias on cubes with long names or many joined members","Keep cube and member names short when targeting Redshift","Estimate generated pre-aggregation table names in CI before deploying"],"tags":["redshift","identifier-length","pre-aggregations"],"backgroundTag":"table-name-too-long","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}