{"record":{"id":"ebf152fa4a49caaf","repo":"cube-js/cube","slug":"you-are-using-an-old-version-of-druid-unable-to-d","errorCode":null,"errorMessage":"You are using an old version of Druid. Unable to detect column types in readOnly mode.","messagePattern":"You are using an old version of Druid\\. Unable to detect column types in readOnly mode\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-druid-driver/src/DruidDriver.ts","lineNumber":148,"sourceCode":"        FROM INFORMATION_SCHEMA.COLUMNS\n        WHERE TABLE_SCHEMA NOT IN ('INFORMATION_SCHEMA', 'sys')\n    `;\n  }\n\n  public async createSchemaIfNotExists(schemaName: string): Promise<void> {\n    throw new Error('Unable to create schema, Druid does not support it');\n  }\n\n  public async getTablesQuery(schemaName: string) {\n    return this.query<TableQueryResult>('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ?', [\n      schemaName\n    ]);\n  }\n\n  public async downloadQueryResults(query: string, values: unknown[], _options: DownloadQueryResultsOptions): Promise<DownloadQueryResultsResult> {\n    const { rows, columns } = await this.client.query<any>(query, this.normalizeQueryValues(values));\n    if (!columns) {\n      throw new Error(\n        'You are using an old version of Druid. Unable to detect column types in readOnly mode.'\n      );\n    }\n\n    const types: TableStructure = [];\n\n    for (const [name, meta] of Object.entries(columns)) {\n      types.push({\n        name,\n        type: this.toGenericType(meta.sqlType.toLowerCase()),\n      });\n    }\n\n    return {\n      rows,\n      types,\n    };\n  }","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-druid-driver/src/DruidDriver.ts#L130-L166","documentation":"downloadQueryResults() relies on the x-druid-sql-header-included header (Druid 0.22+ SQL API) to return column metadata. If the response has no columns, the driver cannot map column types in readOnly mode and throws, indicating the Druid version is too old to supply type information.","triggerScenarios":"Calling driver.downloadQueryResults() (used by Cube's readOnly/pre-aggregation preview flow) against a Druid version whose SQL endpoint does not return column headers, so client.query() yields columns === null.","commonSituations":"Connecting Cube to Druid < 0.22; broker config disabling the SQL header; proxy stripping response headers so x-druid-sql-header-included is lost.","solutions":["Upgrade Druid to 0.22+ so the SQL API returns column metadata headers.","Run Cube in non-readOnly mode where types are obtained via information schema instead of downloadQueryResults.","Check that no reverse proxy strips the x-druid-sql-* response headers."],"exampleFix":"// before (cube.js)\ndriverFactory: () => new DruidDriver({ ...config, readOnly: true })\n// after\n// upgrade Druid >= 0.22, or disable readOnly\ndriverFactory: () => new DruidDriver({ ...config })","handlingStrategy":"validation","validationCode":"// ensure Druid version supports SQL type headers\nconst version = process.env.DRUID_VERSION; // or fetched\nif (version && semver.lt(version, '0.22.0')) {\n  throw new Error('readOnly/downloadQueryResults requires Druid >= 0.22');\n}","typeGuard":"function hasColumnMetadata(res) {\n  return Array.isArray(res?.columns) && res.columns.length > 0;\n}","tryCatchPattern":"try {\n  const res = await driver.downloadQueryResults(sql, values, {});\n} catch (e) {\n  if (e.message.includes('old version of Druid')) {\n    console.error('Upgrade Druid >= 0.22 or disable readOnly mode');\n  } else throw e;\n}","preventionTips":["Run Druid 0.22+ where the SQL API returns x-druid-sql headers","Avoid readOnly mode on old Druid clusters","Ensure proxies do not strip x-druid-sql-* headers"],"tags":["druid","version-compatibility","metadata","driver"],"backgroundTag":"server-version-unsupported","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}