{"record":{"id":"3ce3554db52b3770","repo":"cube-js/cube","slug":"can-t-resolve-tablename-schema-does-not-e","errorCode":null,"errorMessage":"Can't resolve ${tableName}: '${schema}' does not exist","messagePattern":"Can't resolve (.+?): '(.+?)' does not exist","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/scaffolding/ScaffoldingSchema.ts","lineNumber":216,"sourceCode":"      tableNames.map(tableName => {\n        const [schema, table] = this.parseTableName(tableName);\n        const tableDefinition = this.resolveTableDefinition(tableName);\n        const definition: TableData = {\n          schema, table, tableDefinition, tableName\n        };\n        const tableizeName = inflection.tableize(this.fixCase(table));\n        const parts = tableizeName.split('_');\n        const tableNamesFromParts = R.range(0, parts.length - 1).map(toDrop => inflection.tableize(R.drop(toDrop, parts).join('_')));\n        const names = R.uniq([table, tableizeName].concat(tableNamesFromParts));\n        return names.map(n => [n, definition]);\n      })\n    ) as any;\n  }\n\n  public resolveTableDefinition(tableName: TableName) {\n    const [schema, table] = this.parseTableName(tableName);\n    if (!this.dbSchema[schema]) {\n      throw new UserError(`Can't resolve ${tableName}: '${schema}' does not exist`);\n    }\n    if (!this.dbSchema[schema][table]) {\n      throw new UserError(`Can't resolve ${tableName}: '${table}' does not exist`);\n    }\n    return this.dbSchema[schema][table];\n  }\n\n  protected tableSchema(tableName: TableName, includeJoins: boolean): TableSchema {\n    const [schema, table] = this.parseTableName(tableName);\n    const tableDefinition = this.resolveTableDefinition(tableName);\n    const dimensions = this.dimensions(tableDefinition);\n\n    return {\n      cube: this.options.snakeCase ? toSnakeCase(table) : inflection.camelize(table),\n      tableName,\n      schema,\n      table,\n      measures: this.numberMeasures(tableDefinition),","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/scaffolding/ScaffoldingSchema.ts#L198-L234","documentation":"ScaffoldingSchema.resolveTableDefinition looks up a table in the loaded DB schema by splitting '<schema>.<table>'. When the schema (first segment) is not present in the introspected dbSchema, this UserError is thrown. It means the requested schema name does not match any schema returned by the driver's tablesSchema().","triggerScenarios":"Calling resolveTableName/tableDefinition (directly or via scaffolding/generate-schema flows) with a table name whose schema portion is misspelled, quoted incorrectly, or absent from the driver's introspection results.","commonSituations":"Typos in schema names ('public' vs 'publi'), querying a custom Postgres schema not exposed to the DB user, default schema mismatches across data sources, or case-sensitivity issues where the actual schema is 'Public' or quoted lowercase.","solutions":["Print Object.keys of the driver's tablesSchema() and confirm the schema name exists","Correct the schema portion of the table name to match the introspected schema exactly","Grant the DB user access to the schema so the driver can introspect it","Pass the table name as an explicit ['schema','table'] array to avoid parsing/quoting issues"],"exampleFix":"// before\nschema.resolveTableDefinition('pubic.orders');\n// after\nschema.resolveTableDefinition('public.orders');","handlingStrategy":"validation","validationCode":"const tablesSchema = await driver.tablesSchema();\nif (!tablesSchema[schemaName]) throw new Error(`Schema '${schemaName}' not found; available: ${Object.keys(tablesSchema).join(', ')}`);","typeGuard":"const hasSchema = (s: any, name: string): s is { [k: string]: any } => typeof s === 'object' && s != null && name in s;","tryCatchPattern":"try { schema.resolveTableDefinition(tableName); } catch (e) { if (e instanceof UserError && /does not exist/.test(e.message)) { /* re-list schemas / prompt user */ } else throw e; }","preventionTips":["Log Object.keys(dbSchema) at startup to see exactly what was introspected","Always qualify tables as '<schema>.<table>'","Check DB user grants cover the schema","Use array form ['schema','table'] for names with special characters"],"tags":["scaffolding","schema","configuration"],"backgroundTag":"table-or-schema-not-found","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}