File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
packages/cubejs-redshift-driver/src Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,20 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
116116 ` ;
117117 }
118118
119+ /**
120+ * In Redshift schemas not owned by the current user are not shown in regular information_schema,
121+ * so it needs to be queried through the pg_namespace table. Because user might be granted specific
122+ * permissions on the concrete schema (like CREATE tables in already existing but not owned pre-aggregation schema).
123+ * @override
124+ */
125+ public override async createSchemaIfNotExists ( schemaName : string ) : Promise < void > {
126+ const schemaExistsQuery = `SELECT nspname FROM pg_namespace where nspname = ${ this . param ( 0 ) } ` ;
127+ const schemas = await this . query ( schemaExistsQuery , [ schemaName ] ) ;
128+ if ( schemas . length === 0 ) {
129+ await this . query ( `CREATE SCHEMA IF NOT EXISTS ${ schemaName } ` , [ ] ) ;
130+ }
131+ }
132+
119133 /**
120134 * In Redshift external tables are not shown in regular Postgres information_schema,
121135 * so it needs to be queried separately.
You can’t perform that action at this time.
0 commit comments