{"record":{"id":"82e01d70bfacb602","repo":"cube-js/cube","slug":"can-t-resolve-tablename-table-does-not-ex","errorCode":null,"errorMessage":"Can't resolve ${tableName}: '${table}' 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":219,"sourceCode":"        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),\n      dimensions,\n      joins: includeJoins ? this.joins(tableName, tableDefinition) : []\n    };","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/scaffolding/ScaffoldingSchema.ts#L201-L237","documentation":"Same lookup path as the schema-level error, but here the schema exists while the table name (second segment) is missing from dbSchema[schema]. The driver introspected the schema but no table with that name was found.","triggerScenarios":"resolveTableDefinition called with a table that does not exist in the given schema, is not visible to the connecting DB user, or whose name differs in case/quoting from the introspected name.","commonSituations":"Table was dropped/renamed after schema cache was built, dev points at the wrong database, using 'users' when the real name is 'user' or '\"Users\"', or insufficient GRANTs hiding the table from information_schema introspection.","solutions":["Verify the table exists: run the equivalent of SELECT from information_schema.tables for that schema","Check the DB user's permissions (GRANT SELECT) so the table appears in introspection","Confirm you are pointing at the correct database/environment credentials","Fix casing/quoting of the table name in the request"],"exampleFix":"// before\nschema.resolveTableDefinition('public.ordrs');\n// after\nschema.resolveTableDefinition('public.orders');","handlingStrategy":"validation","validationCode":"const def = dbSchema?.[schema]?.[table];\nif (!def) throw new Error(`Table '${schema}.${table}' not found in introspected schema`);","typeGuard":"const hasTable = (db: any, schema: string, table: string) => !!db?.[schema] && Object.prototype.hasOwnProperty.call(db[schema], table);","tryCatchPattern":"try { schema.resolveTableDefinition(tableName); } catch (e) { if (e instanceof UserError && /'[^']+' does not exist/.test(e.message)) { /* suggest similar tables */ } else throw e; }","preventionTips":["Confirm table existence in the target DB before scaffolding","Watch for case-sensitive/quoted identifiers","Verify environment credentials point to the intended database","Refresh introspection after DDL changes"],"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"}