cube-js/cube · error · Error

Redshift can not work with table names longer than 127 symbo

Error message

Redshift can not work with table names longer than 127 symbols. Consider using the 'sqlAlias' attribute in your cube definition for ${quotedTableName}.

What it means

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.

Source

Thrown at packages/cubejs-redshift-driver/src/RedshiftDriver.ts:299

      // @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;
    });
  }

  /**
   * AWS Redshift doesn't have any special connection check.
   * And querying even system tables is billed.
   * @override
   */
  public override async testConnection() {

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Add sqlAlias: '<short-name>' to the cube (or pre-aggregation) definition to shorten generated table names
  2. Shorten the cube and/or member names in the data model
  3. Reduce the pre-aggregation name / member list so the derived table identifier fits within 127 chars

Example fix

// before
cube('VeryLongSalesAnalyticsFactTableWithRegionalPartitioning', {
  sql: () => 'SELECT * FROM sales'
});
// after
cube('VeryLongSalesAnalyticsFactTableWithRegionalPartitioning', {
  sql: () => 'SELECT * FROM sales',
  sqlAlias: 'sales_fact'
});
Defensive patterns

Strategy: validation

Validate before calling

const quoted = driver.quoteIdentifier ? '' : '"';
if (quotedTableName.length > 127) {
  throw new Error(`Table identifier exceeds Redshift 127-char limit: ${quotedTableName.length} chars`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/96dbc6b88f4f3e62. Report an issue: GitHub.