{"record":{"id":"a8eba02a1703b339","repo":"cube-js/cube","slug":"unable-to-detect-a-source-table-for-ksql-download","errorCode":null,"errorMessage":"Unable to detect a source table for ksql download query. In order to query ksql use \"SELECT * FROM <TABLE>\"","messagePattern":"Unable to detect a source table for ksql download query\\. In order to query ksql use \"SELECT \\* FROM <TABLE>\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-ksql-driver/src/KsqlDriver.ts","lineNumber":288,"sourceCode":"  }\n\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  public loadPreAggregationIntoTable(preAggregationTableName: string, loadSql: string, params: any[], options: KsqlQueryOptions): Promise<any> {\n    const { streamOffset } = options || {};\n    return this.query(loadSql.replace(preAggregationTableName, this.tableDashName(preAggregationTableName)), params, { streamOffset });\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  public async downloadTable(table: string, options: any): Promise<any> {\n    const { streamOffset } = options || {};\n    return this.getStreamingTableData(this.tableDashName(table), { streamOffset });\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  public async downloadQueryResults(query: string, params: any, options: any) {\n    const table = KsqlQuery.extractTableFromSimpleSelectAsteriskQuery(query);\n    if (!table) {\n      throw new Error('Unable to detect a source table for ksql download query. In order to query ksql use \"SELECT * FROM <TABLE>\"');\n    }\n\n    const selectStatement = this.prepareQueryWithParams(query, params);\n    const { streamOffset, outputColumnTypes } = options || {};\n    return this.getStreamingTableData(table, { selectStatement, streamOffset, outputColumnTypes });\n  }\n\n  private async getStreamingTableData(streamingTable: string, options: KsqlQueryOptions = {}) {\n    const { selectStatement, streamOffset, outputColumnTypes } = options;\n    const describe = await this.describeTable(streamingTable);\n    const name = this.config.streamingSourceName || 'default';\n    const kafkaDirectDownload = !!this.config.kafkaHost;\n    const streamingSource = kafkaDirectDownload ? {\n      name: `${name}-kafka`,\n      type: 'kafka',\n      credentials: {\n        user: this.config.kafkaUser,\n        password: this.config.kafkaPassword,","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-ksql-driver/src/KsqlDriver.ts#L270-L306","documentation":"A guard in KsqlDriver.downloadQueryResults: downloading a table's results requires a simple `SELECT * FROM <TABLE>` form so the driver can identify the source stream/table from the SQL; any other query shape leaves the source table undetectable and is rejected. The input at fault is a download/downloadQueryResults call whose SQL is filtered, joined, or otherwise not a plain SELECT *.","triggerScenarios":"Thrown at packages/cubejs-ksql-driver/src/KsqlDriver.ts:288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the download query passed to downloadQueryResults matches the expected 'SELECT * FROM <TABLE>' shape so the source table can be extracted","Set options.table (or the table name parameter) explicitly when constructing the download query","Fix query generation upstream in the orchestrator so the pre-aggregation source table name is embedded in the SELECT"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}