{"record":{"id":"d0e746f21e70f6ec","repo":"cube-js/cube","slug":"unable-to-create-schema-druid-does-not-support-it","errorCode":null,"errorMessage":"Unable to create schema, Druid does not support it","messagePattern":"Unable to create schema, Druid does not support it","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-druid-driver/src/DruidDriver.ts","lineNumber":136,"sourceCode":"  public async query<R = unknown>(query: string, values: unknown[] = []): Promise<Array<R>> {\n    const result = await this.client.query<R>(query, this.normalizeQueryValues(values));\n    return result.rows;\n  }\n\n  public informationSchemaQuery() {\n    return `\n        SELECT\n            COLUMN_NAME as ${this.quoteIdentifier('column_name')},\n            TABLE_NAME as ${this.quoteIdentifier('table_name')},\n            TABLE_SCHEMA as ${this.quoteIdentifier('table_schema')},\n            DATA_TYPE as ${this.quoteIdentifier('data_type')}\n        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","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-druid-driver/src/DruidDriver.ts#L118-L154","documentation":"Druid does not support the SQL 'CREATE SCHEMA' statement — its namespaces are managed outside SQL. The driver therefore overrides createSchemaIfNotExists() to unconditionally throw, rather than sending SQL Druid would reject.","triggerScenarios":"Calling driver.createSchemaIfNotExists('my_schema') directly, or Cube's pre-aggregation/compiler flow attempting to ensure a staging schema exists for a Druid datasource.","commonSituations":"Enabling pre-aggregations with a driver-level staging schema for Druid; migrating generic driver code (e.g. copied from Postgres setup) that calls createSchemaIfNotExists; tooling that assumes all JDBC-ish drivers can create schemas.","solutions":["Do not call createSchemaIfNotExists for Druid — schemas are fixed namespaces (druid, INFORMATION_SCHEMA, sys).","Configure pre-aggregations to use an external store (e.g. Postgres) or in-Druid rollup pre-aggregations instead of external rollup tables.","Wrap the call with a no-op if your abstraction requires it and you know the schema is a Druid namespace."],"exampleFix":"// before\nawait driver.createSchemaIfNotExists('staging');\n// after\nif (driver.constructor.name !== 'DruidDriver') {\n  await driver.createSchemaIfNotExists('staging');\n}","handlingStrategy":"validation","validationCode":"function supportsCreateSchema(driver) {\n  return typeof driver.createSchemaIfNotExists === 'function' &&\n    driver.constructor.name !== 'DruidDriver';\n}\nif (supportsCreateSchema(driver)) await driver.createSchemaIfNotExists(schema);","typeGuard":null,"tryCatchPattern":"try {\n  await driver.createSchemaIfNotExists(schema);\n} catch (e) {\n  if (e.message.includes('Druid does not support')) return; // expected no-op\n  throw e;\n}","preventionTips":["Skip schema-creation steps for Druid datasources","Use external rollup stores (Postgres) or in-Druid pre-aggregations instead of external staging schemas","Feature-detect driver capabilities before generic schema setup code"],"tags":["druid","unsupported-feature","schema","sql"],"backgroundTag":"unsupported-operation","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}