Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/cubejs-redshift-driver/src/RedshiftDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
super(options);
}

/**
* @param {string} schemaName
* @return {Promise<Array<unknown>>}
*/
async createSchemaIfNotExists(schemaName: string) {
const schemaExistsQuery = `SELECT nspname FROM pg_namespace where nspname = ${this.param(0)}`;
const schemas = await this.query(schemaExistsQuery, [schemaName])
if (schemas.length === 0) {
return this.query(`CREATE SCHEMA IF NOT EXISTS ${schemaName}`);
}
return null;
}

protected getInitialConfiguration(): Partial<RedshiftDriverConfiguration> {
return {
// @todo It's not possible to support UNLOAD in readOnly mode, because we need column types (CREATE TABLE?)
Expand Down