Skip to content

Commit a8b8ad0

Browse files
authored
fix(cubestore-driver): Check introspection results on import (#7382)
1 parent 3e1389b commit a8b8ad0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/cubejs-cubestore-driver/src/CubeStoreDriver.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ export class CubeStoreDriver extends BaseDriver implements DriverInterface {
240240
}
241241

242242
private async importRows(table: string, columns: Column[], indexesSql: any, aggregations: any, tableData: DownloadTableMemoryData, queryTracingObj?: any) {
243+
if (!columns || columns.length === 0) {
244+
throw new Error('Unable to import (as rows) in Cube Store: empty columns. Most probably, introspection has failed.');
245+
}
246+
243247
await this.createTableWithOptions(table, columns, { indexes: indexesSql, aggregations, buildRangeEnd: queryTracingObj?.buildRangeEnd }, queryTracingObj);
244248
try {
245249
const batchSize = 2000; // TODO make dynamic?
@@ -267,6 +271,10 @@ export class CubeStoreDriver extends BaseDriver implements DriverInterface {
267271
}
268272

269273
private async importCsvFile(tableData: DownloadTableCSVData, table: string, columns: Column[], indexes: any, aggregations: any, queryTracingObj?: any) {
274+
if (!columns || columns.length === 0) {
275+
throw new Error('Unable to import (as csv) in Cube Store: empty columns. Most probably, introspection has failed.');
276+
}
277+
270278
const files = Array.isArray(tableData.csvFile) ? tableData.csvFile : [tableData.csvFile];
271279
const options: CreateTableOptions = {
272280
buildRangeEnd: queryTracingObj?.buildRangeEnd,
@@ -285,6 +293,10 @@ export class CubeStoreDriver extends BaseDriver implements DriverInterface {
285293
}
286294

287295
private async importStream(columns: Column[], tableData: StreamTableData, table: string, indexes: string, aggregations: string, queryTracingObj?: any) {
296+
if (!columns || columns.length === 0) {
297+
throw new Error('Unable to import (as stream) in Cube Store: empty columns. Most probably, introspection has failed.');
298+
}
299+
288300
const tempFiles: string[] = [];
289301
try {
290302
const pipelinePromises: Promise<any>[] = [];

0 commit comments

Comments
 (0)