{"record":{"id":"9fbf714503b8bb4d","repo":"cube-js/cube","slug":"unable-to-unload-table-there-are-no-files-in-s3-s","errorCode":null,"errorMessage":"Unable to UNLOAD table, there are no files in S3 storage","messagePattern":"Unable to UNLOAD table, there are no files in S3 storage","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-redshift-driver/src/RedshiftDriver.ts","lineNumber":507,"sourceCode":"          csvFile: [],\n          types\n        };\n      }\n\n      const csvFile = await this.extractUnloadedFilesFromS3(\n        {\n          credentials: (keyId && secretKey) ? {\n            accessKeyId: keyId,\n            secretAccessKey: secretKey,\n          } : undefined,\n          region,\n        },\n        bucketName,\n        exportPathName,\n      );\n\n      if (csvFile.length === 0) {\n        throw new Error('Unable to UNLOAD table, there are no files in S3 storage');\n      }\n\n      return {\n        exportBucketCsvEscapeSymbol: this.config.exportBucketCsvEscapeSymbol,\n        csvFile,\n        types\n      };\n    } finally {\n      conn.removeAllListeners('notice');\n      await this.pool.release(conn);\n    }\n  }\n\n  public capabilities(): DriverCapabilities {\n    return {\n      incrementalSchemaLoading: true,\n    };\n  }","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-redshift-driver/src/RedshiftDriver.ts#L489-L525","documentation":"A sentinel guard in RedshiftDriver.unload: after Redshift UNLOADs the table to S3, extractUnloadedFilesFromS3 lists the exported objects and the list came back empty — no manifest/CSV files exist at the export path. This usually means the UNLOAD wrote nothing (empty result with no files emitted), the S3 path/prefix is wrong, or the credentials used for listing lack access to the bucket prefix. It detects a broken unload-export round trip rather than a query error.","triggerScenarios":"unload() runs the UNLOAD statement and the subsequent S3 listObjectsV2 for bucketName/exportPathName returns zero csvFile entries — e.g. the query produced zero rows (Redshift writes no files), or the object listing targets the wrong bucket/prefix/region.","commonSituations":"Pre-aggregation/table with no data; mismatch between the S3 prefix used in UNLOAD and the one being listed; IAM permissions hiding objects; eventual-consistency lag right after UNLOAD.","solutions":["Verify the source table actually contains rows (SELECT COUNT(*))","Confirm bucketName/region/prefix configuration matches what UNLOAD was authorized to write to","Check IAM policy allows s3:ListBucket/s3:GetObject on the export prefix","Retry — transient S3 listing lag right after unload can briefly return an empty listing"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check data exists before exporting\nconst [{ count }] = await driver.query('SELECT COUNT(*) AS count FROM ' + tableName);","typeGuard":null,"tryCatchPattern":"try {\n  return await driver.unload(tableName, options);\n} catch (e) {\n  if (/no files in S3 storage/.test(e.message)) {\n    // check table row count and S3 prefix/IAM config, then retry once\n  }\n  throw e;\n}","preventionTips":["Verify the exported table contains rows before unloading","Confirm S3 bucket, prefix and region alignment between UNLOAD and listing config","Grant s3:ListBucket and s3:GetObject on the export prefix to the configured keys"],"tags":["redshift","s3","unload","empty-result"],"backgroundTag":"s3-export-empty","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}