{"record":{"id":"0afe3a462dc10eb3","repo":"cube-js/cube","slug":"unable-to-import-as-csv-in-cube-store-empty-col","errorCode":null,"errorMessage":"Unable to import (as csv) in Cube Store: empty columns. Most probably, introspection has failed.","messagePattern":"Unable to import \\(as csv\\) in Cube Store: empty columns\\. Most probably, introspection has failed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-cubestore-driver/src/CubeStoreDriver.ts","lineNumber":326,"sourceCode":"          .reduce((a, b) => a.concat(b), []);\n\n        await this.query(\n          `INSERT INTO ${table}\n        (${columns.map(c => this.quoteIdentifier(c.name)).join(', ')})\n        VALUES ${valueParamPlaceholders}`,\n          params,\n          queryTracingObj\n        );\n      }\n    } catch (e) {\n      await this.dropTable(table);\n      throw e;\n    }\n  }\n\n  private async importCsvFile(tableData: DownloadTableCSVData, table: string, columns: Column[], indexes: any, aggregations: any, queryTracingObj?: any) {\n    if (!columns || columns.length === 0) {\n      throw new Error('Unable to import (as csv) in Cube Store: empty columns. Most probably, introspection has failed.');\n    }\n\n    const files = Array.isArray(tableData.csvFile) ? tableData.csvFile : [tableData.csvFile];\n    const options: CreateTableOptions = {\n      buildRangeEnd: queryTracingObj?.buildRangeEnd,\n      indexes,\n      aggregations\n    };\n    if (files.length > 0) {\n      options.inputFormat = tableData.csvNoHeader ? 'csv_no_header' : 'csv';\n      if (tableData.csvDelimiter) {\n        options.delimiter = tableData.csvDelimiter;\n      }\n      if (tableData.csvDisableQuoting) {\n        options.disableQuoting = tableData.csvDisableQuoting;\n      }\n      options.files = files;\n    }","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-cubestore-driver/src/CubeStoreDriver.ts#L308-L344","documentation":"Same root cause as the rows variant, but for CSV-file based imports: importCsvFile needs column definitions to emit the CREATE TABLE SQL before loading the CSV. An empty columns array indicates failed introspection.","triggerScenarios":"uploadTable with tableData.csvFile but columns empty/null — introspection for the CSV source returned no columns.","commonSituations":"CSV data source with headers the introspection stage can't parse; driver bug returning empty metadata; schema whose pre-aggregation columns resolve to zero.","solutions":["Fix or re-run introspection so columns are derived from the CSV schema.","Supply columns explicitly when calling uploadTable if introspection is unreliable.","Verify the CSV source driver is supported and returns metadata.","Update cubejs-schema-compiler and driver packages to compatible versions."],"exampleFix":"// before\nawait driver.uploadTable(table, [], { csvFile: 'data.csv' });\n// after\nconst columns = [{ name: 'id', type: 'text' }, { name: 'ts', type: 'timestamp' }];\nawait driver.uploadTable(table, columns, { csvFile: 'data.csv' });","handlingStrategy":"validation","validationCode":"if (!Array.isArray(columns) || columns.length === 0) {\n  throw new Error('Refusing CSV import: no columns from introspection');\n}\nawait driver.uploadTable(table, columns, { csvFile });","typeGuard":"function hasColumns(c: unknown): c is Array<{ name: string; type: string }> {\n  return Array.isArray(c) && c.length > 0 && c.every(col => typeof (col as any).name === 'string');\n}","tryCatchPattern":"try {\n  await driver.uploadTable(table, columns, { csvFile });\n} catch (e) {\n  if (e.message.includes('as csv') && e.message.includes('empty columns')) {\n    console.error('CSV introspection failed: provide explicit columns or fix the CSV source driver');\n  }\n  throw e;\n}","preventionTips":["Supply explicit columns for CSV sources when introspection is unreliable.","Confirm the CSV file has a parseable header row.","Test the CSV source driver metadata path in CI.","Keep backend packages version-aligned."],"tags":["cubestore","introspection","csv"],"backgroundTag":"empty-columns-introspection-failed","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}