File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
cubejs-redshift-driver/src
cubejs-testing-drivers/src/tests Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 StreamOptions ,
1717 StreamTableDataWithTypes ,
1818 TableColumn ,
19+ TableStructure ,
1920 UnloadOptions
2021} from '@cubejs-backend/base-driver' ;
2122import crypto from 'crypto' ;
@@ -341,6 +342,19 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
341342 // @todo Implement for Redshift, column \"typcategory\" does not exist in pg_type
342343 }
343344
345+ public override async tableColumnTypes ( table : string ) : Promise < TableStructure > {
346+ const [ schema , name ] = table . split ( '.' ) ;
347+
348+ // We might get table from Spectrum schema, so common request via `information_schema.columns`
349+ // won't return anything. `getColumnsForSpecificTables` is aware of Spectrum tables.
350+ const columns = await this . getColumnsForSpecificTables ( [ {
351+ schema_name : schema ,
352+ table_name : name ,
353+ } ] ) ;
354+
355+ return columns . map ( c => ( { name : c . column_name , type : this . toGenericType ( c . data_type ) } ) ) ;
356+ }
357+
344358 public async isUnloadSupported ( ) {
345359 if ( this . config . exportBucket ) {
346360 return true ;
Original file line number Diff line number Diff line change @@ -46,4 +46,16 @@ export function redshiftExternalSchemasSuite(
4646 expect ( it . data_type ) . toEqual ( expect . any ( String ) ) ;
4747 } ) ;
4848 } ) ;
49+
50+ execute ( 'should load columns types for external table' , async ( ) => {
51+ const columnsForTables = await driver ( ) . tableColumnTypes ( `${ EXTERNAL_SCHEMA } .${ EXTERNAL_TABLE } ` ) ;
52+
53+ expect ( columnsForTables ) . toBeInstanceOf ( Array ) ;
54+ expect ( columnsForTables . length ) . toBeGreaterThan ( 0 ) ;
55+
56+ columnsForTables . forEach ( ( it ) => {
57+ expect ( it . name ) . toEqual ( expect . any ( String ) ) ;
58+ expect ( it . type ) . toEqual ( expect . any ( String ) ) ;
59+ } ) ;
60+ } ) ;
4961}
You can’t perform that action at this time.
0 commit comments