File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
packages/cubejs-redshift-driver/src Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,19 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
2222 super ( options ) ;
2323 }
2424
25+ /**
26+ * @param {string } schemaName
27+ * @return {Promise<Array<unknown>> }
28+ */
29+ async createSchemaIfNotExists ( schemaName : string ) {
30+ const schemaExistsQuery = `SELECT nspname FROM pg_namespace where nspname = ${ this . param ( 0 ) } ` ;
31+ const schemas = await this . query ( schemaExistsQuery , [ schemaName ] )
32+ if ( schemas . length === 0 ) {
33+ return this . query ( `CREATE SCHEMA IF NOT EXISTS ${ schemaName } ` ) ;
34+ }
35+ return null ;
36+ }
37+
2538 protected getInitialConfiguration ( ) : Partial < RedshiftDriverConfiguration > {
2639 return {
2740 // @todo It's not possible to support UNLOAD in readOnly mode, because we need column types (CREATE TABLE?)
You can’t perform that action at this time.
0 commit comments