{"record":{"id":"44e3de6b740413a1","repo":"cube-js/cube","slug":"unknown-dbtype-dbtype","errorCode":null,"errorMessage":"Unknown dbType: ${dbType}","messagePattern":"Unknown dbType: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-server-core/src/core/CompilerApi.ts","lineNumber":325,"sourceCode":"    );\n    return new QueryFactory(cubeToQueryClass);\n  }\n\n  public async getDbType(dataSource: string = 'default'): Promise<string> {\n    return this.dbType({ dataSource });\n  }\n\n  public getDialectClass(dataSource: string = 'default', dbType: string): BaseQuery {\n    return this.dialectClass?.({ dataSource, dbType });\n  }\n\n  public async getSqlGenerator(query: NormalizedQuery, dataSource?: string): Promise<{ sqlGenerator: any; compilers: Compiler }> {\n    const dbType = await this.getDbType(dataSource);\n    const compilers = await this.getCompilers({ requestId: query.requestId });\n    let sqlGenerator = await this.createQueryByDataSource(compilers, query, dataSource, dbType);\n\n    if (!sqlGenerator) {\n      throw new Error(`Unknown dbType: ${dbType}`);\n    }\n\n    // sqlGenerator.dataSource can return undefined for query without members\n    // Queries like this are used by api-gateway to initialize SQL API\n    // At the same time, those queries should use concrete dataSource, so we should be good to go with it\n    dataSource = compilers.compiler.withQuery(sqlGenerator, () => sqlGenerator.dataSource);\n    if (dataSource !== undefined) {\n      const _dbType = await this.getDbType(dataSource);\n      if (dataSource !== 'default' && dbType !== _dbType) {\n        // TODO consider more efficient way than instantiating query\n        sqlGenerator = await this.createQueryByDataSource(\n          compilers,\n          query,\n          dataSource,\n          _dbType\n        );\n\n        if (!sqlGenerator) {","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-server-core/src/core/CompilerApi.ts#L307-L343","documentation":"getSqlGenerator resolves a SQL generator (dialect class) based on the dataSource's dbType. If createQueryByDataSource returns nothing for that dbType, Cube does not know how to build queries for it, so this Error is thrown.","triggerScenarios":"driverFactory/dbType configured with a value not in Cube's supported dialect registry, or a dataSource configured with a driver whose dbType has no registered query class.","commonSituations":"Typo like 'postgresdb' or 'psql' instead of 'postgres', custom/experimental driver without a matching dialect registration, or upgrading Cube where a dialect name changed.","solutions":["Check the configured dbType (log this.getDbType(dataSource)) and correct it to a supported value like 'postgres', 'mysql', 'bigquery'","Install the matching driver package (e.g. @cubejs-backend/postgres-driver) so its dialect registers","Ensure the driver's dbType() returns the expected string","If using a custom driver, register a corresponding query/dialect class"],"exampleFix":"// before\ndbType: 'psql'\n// after\ndbType: 'postgres'","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['postgres','mysql','mssql','bigquery','redshift','clickhouse','snowflake','databricks jdbc','duckdb','mongodb','elasticsearch','cubesql'];\nconst dbType = await driver.dbType();\nif (!SUPPORTED.includes(dbType)) throw new Error(`Unsupported dbType '${dbType}'`);","typeGuard":"const isSupportedDbType = (t: unknown): t is SupportedDbType => typeof t === 'string' && SUPPORTED_DB_TYPES.includes(t);","tryCatchPattern":"try { await compilerApi.getSqlGenerator(query, dataSource); } catch (e) { if (/Unknown dbType/.test(e.message)) { /* correct driver config */ } else throw e; }","preventionTips":["Set dbType explicitly in cubejs-server options","Install the matching @cubejs-backend/<db>-driver package","Verify driver.dbType() output for custom drivers","Pin versions so dialect registration changes are deliberate"],"tags":["dialect","configuration","dbtype"],"backgroundTag":"unsupported-database-type","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}