Skip to content

Commit 766d6a3

Browse files
committed
override createTable in redshift
1 parent 636c015 commit 766d6a3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/cubejs-redshift-driver/src/RedshiftDriver.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
QueryTablesResult,
1616
StreamOptions,
1717
StreamTableDataWithTypes,
18+
TableColumn,
1819
UnloadOptions
1920
} from '@cubejs-backend/base-driver';
2021
import crypto from 'crypto';
@@ -240,6 +241,21 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
240241
}
241242
}
242243

244+
public override async createTable(quotedTableName: string, columns: TableColumn[]): Promise<void> {
245+
if (quotedTableName.length > 127) {
246+
throw new Error('Redshift can not work with table names longer than 127 symbols. ' +
247+
`Consider using the 'sqlAlias' attribute in your cube definition for ${quotedTableName}.`);
248+
}
249+
250+
// we can not call super.createTable(quotedTableName, columns)
251+
// because Postgres has 63 length check. So pasting the code from the base driver
252+
const createTableSql = this.createTableSql(quotedTableName, columns);
253+
await this.query(createTableSql, []).catch(e => {
254+
e.message = `Error during create table: ${createTableSql}: ${e.message}`;
255+
throw e;
256+
});
257+
}
258+
243259
/**
244260
* AWS Redshift doesn't have any special connection check.
245261
* And querying even system tables is billed.

0 commit comments

Comments
 (0)