{"record":{"id":"08471953784608d0","repo":"cube-js/cube","slug":"this-constructor-driver-supports-only-rows-uplo-084719","errorCode":null,"errorMessage":"${this.constructor} driver supports only rows upload","messagePattern":"(.+?) driver supports only rows upload","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-mysql-driver/src/MySqlDriver.ts","lineNumber":438,"sourceCode":"      if (value.toLowerCase() === 'false') {\n        return false;\n      }\n    }\n    return super.toColumnValue(value, genericType);\n  }\n\n  protected isDownloadTableDataRow(tableData: DownloadTableData): tableData is DownloadTableMemoryData {\n    return (<DownloadTableMemoryData> tableData).rows !== undefined;\n  }\n\n  public async uploadTableWithIndexes(\n    table: string,\n    columns: TableStructure,\n    tableData: DownloadTableData,\n    indexesSql: IndexesSQL\n  ) {\n    if (!this.isDownloadTableDataRow(tableData)) {\n      throw new Error(`${this.constructor} driver supports only rows upload`);\n    }\n\n    await this.createTable(table, columns);\n\n    try {\n      const batchSize = 1000; // TODO make dynamic?\n      for (let j = 0; j < Math.ceil(tableData.rows.length / batchSize); j++) {\n        const currentBatchSize = Math.min(tableData.rows.length - j * batchSize, batchSize);\n        const indexArray = Array.from({ length: currentBatchSize }, (v, i) => i);\n        const valueParamPlaceholders =\n          indexArray.map(i => `(${columns.map((c, paramIndex) => this.param(paramIndex + i * columns.length)).join(', ')})`).join(', ');\n        const params = indexArray.map(i => columns\n          .map(c => this.toColumnValue(tableData.rows[i + j * batchSize][c.name], c.type)))\n          .reduce((a, b) => a.concat(b), []);\n\n        await this.query(\n          `INSERT INTO ${table}\n        (${columns.map(c => this.quoteIdentifier(c.name)).join(', ')})","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-mysql-driver/src/MySqlDriver.ts#L420-L456","documentation":"MySqlDriver.uploadTableWithIndexes only supports `DownloadTableData` in row form (`rows` array). If the data object is in an unsupported shape (e.g., a stream-like or csv structure), the driver throws this error rather than attempting an incompatible insert path.","triggerScenarios":"Calling `uploadTableWithIndexes` (via the driver's table-upload API) with a `tableData` whose shape fails `isDownloadTableDataRow` — i.e., data not provided as a `rows` array.","commonSituations":"Custom driver wrappers or orchestration code feeding streamed/cursor data from a source database into MySQL; building a custom exporter that passes non-row table data.","solutions":["Materialize the source data into a plain `rows` array before uploading (use source driver's downloadQueryResults rows form).","If the source is streamed, buffer rows in batches and upload as row data.","Check the DownloadTableData type to ensure `rows` is populated and not `stream`/`csv`."],"exampleFix":"// before\nawait mysqlDriver.uploadTableWithIndexes(table, columns, downloaded.stream);\n// after\nconst { rows } = await sourceDriver.downloadQueryResults(query);\nawait mysqlDriver.uploadTableWithIndexes(table, columns, { rows, types });","handlingStrategy":"type-guard","validationCode":"const isRowData = (d) => d && Array.isArray(d.rows);\nif (!isRowData(tableData)) throw new Error('MySQL driver requires rows-based DownloadTableData');","typeGuard":"function isDownloadTableDataRow(d: DownloadTableData): d is { rows: any[] } {\n  return 'rows' in d && Array.isArray((d as any).rows);\n}","tryCatchPattern":"if (!isDownloadTableDataRow(tableData)) {\n  tableData = { rows: await materializeRows(tableData) };\n}\nawait driver.uploadTableWithIndexes(table, columns, tableData);","preventionTips":["Always build DownloadTableData with a `rows` array for MySQL targets.","Convert streams/cursors to arrays before upload.","Reuse driver helpers (downloadQueryResults rows form) rather than custom shapes.","Write a unit test for the upload path with row data."],"tags":["mysql","data-upload","type-guard","api-misuse"],"backgroundTag":"unsupported-upload-format","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}