Skip to content

Commit 2e97019

Browse files
authored
fix(redshift-driver): Use proper query for table column types that respects fetchColumnsByOrdinalPosition (#9915)
1 parent 1d0e1b8 commit 2e97019

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/cubejs-redshift-driver/src/RedshiftDriver.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,24 +360,24 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
360360
}
361361

362362
public override async tableColumnTypes(table: string): Promise<TableStructure> {
363+
const columns: TableStructure = await super.tableColumnTypes(table);
364+
365+
if (columns.length) {
366+
return columns;
367+
}
368+
369+
// It's possible that table is external Spectrum table, so we need to query it separately
363370
const [schema, name] = table.split('.');
364371

365372
// We might get table from Spectrum schema, so common request via `information_schema.columns`
366373
// won't return anything. `getColumnsForSpecificTables` is aware of Spectrum tables.
367-
const columns = await this.getColumnsForSpecificTables([{
368-
schema_name: schema,
369-
table_name: name,
370-
}]);
374+
const columnRes = await this.columnsForExternalTable(schema, name);
371375

372-
return columns.map(c => ({ name: c.column_name, type: this.toGenericType(c.data_type) }));
376+
return columnRes.map(c => ({ name: c.column_name, type: this.toGenericType(c.data_type) }));
373377
}
374378

375379
public async isUnloadSupported() {
376-
if (this.config.exportBucket) {
377-
return true;
378-
}
379-
380-
return false;
380+
return !!this.config.exportBucket;
381381
}
382382

383383
public async unload(tableName: string, options: UnloadOptions): Promise<DownloadTableCSVData> {

0 commit comments

Comments
 (0)