Skip to content
Merged
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
14 changes: 14 additions & 0 deletions packages/cubejs-redshift-driver/src/RedshiftDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
`;
}

/**
* In Redshift schemas not owned by the current user are not shown in regular information_schema,
* so it needs to be queried through the pg_namespace table. Because user might be granted specific
* permissions on the concrete schema (like CREATE tables in already existing but not owned pre-aggregation schema).
* @override
*/
public override async createSchemaIfNotExists(schemaName: string): Promise<void> {
const schemaExistsQuery = `SELECT nspname FROM pg_namespace where nspname = ${this.param(0)}`;
const schemas = await this.query(schemaExistsQuery, [schemaName]);
if (schemas.length === 0) {
await this.query(`CREATE SCHEMA IF NOT EXISTS ${schemaName}`, []);
}
}

/**
* In Redshift external tables are not shown in regular Postgres information_schema,
* so it needs to be queried separately.
Expand Down
Loading