{"record":{"id":"9412216b8fe94235","repo":"cube-js/cube","slug":"default-database-should-be-defined-to-be-used-for","errorCode":null,"errorMessage":"Default database should be defined to be used for temporary tables during query results downloads","messagePattern":"Default database should be defined to be used for temporary tables during query results downloads","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-mysql-aurora-serverless-driver/driver/AuroraServerlessMySqlDriver.js","lineNumber":128,"sourceCode":"  }\n\n  fromGenericType(columnType) {\n    return GenericTypeToMySql[columnType] || super.fromGenericType(columnType);\n  }\n\n  loadPreAggregationIntoTable(preAggregationTableName, loadSql, params, tx) {\n    if (this.config.loadPreAggregationWithoutMetaLock) {\n      return this.cancelCombinator(async saveCancelFn => {\n        await saveCancelFn(this.query(`${loadSql} LIMIT 0`, params));\n        await saveCancelFn(this.query(loadSql.replace(/^CREATE TABLE (\\S+) AS/i, 'INSERT INTO $1'), params));\n      });\n    }\n    return super.loadPreAggregationIntoTable(preAggregationTableName, loadSql, params, tx);\n  }\n\n  async downloadQueryResults(query, values) {\n    if (!this.config.database) {\n      throw new Error('Default database should be defined to be used for temporary tables during query results downloads');\n    }\n    const tableName = crypto.randomBytes(10).toString('hex');\n\n    const transaction = this.dataApi.transaction()\n      .query(`CREATE TEMPORARY TABLE \\`${this.config.database}\\`.t_${tableName} AS ${query} LIMIT 0`, values)\n      .query(`DESCRIBE \\`${this.config.database}\\`.t_${tableName}`)\n      .query(`DROP TEMPORARY TABLE \\`${this.config.database}\\`.t_${tableName}`)\n      .rollback((error) => { if (error) throw new Error(error); });\n\n    const results = await transaction.commit();\n    const columns = results[1].records;\n\n    const types = columns.map(c => ({ name: c.Field, type: this.toGenericType(c.Type) }));\n\n    return {\n      rows: await this.query(query, values),\n      types,\n    };","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-mysql-aurora-serverless-driver/driver/AuroraServerlessMySqlDriver.js#L110-L146","documentation":"A configuration guard in AuroraServerlessMySqlDriver.downloadQueryResults: the download flow materializes results into a temporary table in the current database, and with the Data API there is no explicit session database, so config.database (default DB) must be set to know where to create the temp table. It fires when the driver is used for query-results download without a configured default database.","triggerScenarios":"Thrown at packages/cubejs-mysql-aurora-serverless-driver/driver/AuroraServerlessMySqlDriver.js:128 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the database option in the driver configuration (e.g. CUBEJS_DB_NAME) since downloadQueryResults creates a temporary table in the default database","Pass the database name in the Aurora Serverless data store configuration so temp tables for downloads have a schema to live in"],"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"}