{"record":{"id":"167575cec42cfdbd","repo":"cube-js/cube","slug":"can-t-find-any-table-with-tablename-name","errorCode":null,"errorMessage":"Can't find any table with '${tableName}' name","messagePattern":"Can't find any table with '(.+?)' name","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/scaffolding/ScaffoldingSchema.ts","lineNumber":149,"sourceCode":"\n  public resolveTableName(tableName: TableName) {\n    let tableParts;\n    if (Array.isArray(tableName)) {\n      tableParts = tableName;\n    } else {\n      tableParts = tableName.match(/([\"`].*?[\"`]|[^`\".]+)+(?=\\s*|\\s*$)/g);\n    }\n\n    if (tableParts.length === 2) {\n      this.resolveTableDefinition(tableName);\n      return tableName;\n    } else if (tableParts.length === 1 && typeof tableName === 'string') {\n      const schema = Object.keys(this.dbSchema).find(\n        (tableSchema) => this.dbSchema[tableSchema][tableName] ||\n          this.dbSchema[tableSchema][inflection.tableize(tableName)]\n      );\n      if (!schema) {\n        throw new UserError(`Can't find any table with '${tableName}' name`);\n      }\n      if (this.dbSchema[schema][tableName]) {\n        return `${schema}.${tableName}`;\n      }\n      if (this.dbSchema[schema][inflection.tableize(tableName)]) {\n        return `${schema}.${inflection.tableize(tableName)}`;\n      }\n    }\n\n    throw new UserError(\n      'Table names should be in <table> or <schema>.<table> format'\n    );\n  }\n\n  public cubeDescriptors(tableNames: TableName[]): CubeDescriptor[] {\n    const cubes = this.generateForTables(tableNames);\n\n    function member(type: MemberType) {","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/scaffolding/ScaffoldingSchema.ts#L131-L167","documentation":"Thrown by ScaffoldingSchema.resolveTableName() when given a bare table name (no schema part) that cannot be found in the supplied dbSchema — neither the exact name nor its inflected (pluralized/tableized) form exists in any schema. The scaffolding tool needs the table's columns to generate a cube, so it fails with a UserError.","triggerScenarios":"Running schema scaffolding (cube scaffolding / generateDataModel) with a TableName like 'users' while dbSchema (populated from driver metadata via metaData() / tablesSchema) contains no matching table in any schema, including after inflection.tableize('users').","commonSituations":"Typo in the table name, querying the wrong database/connection, table living in a non-searched schema, case-sensitive names (Users vs users), or driver metadata not yet loaded/empty (missing permissions to read schema).","solutions":["Verify the exact table name against the database (\\dt or information_schema.tables) and correct the spelling/case","Pass the fully qualified 'schema.table' name instead of the bare name","Confirm the Cube driver's dbSchema/metadata actually includes the table (check connection and schema-search settings)","If you reference a singular name, ensure inflection.tableize() pluralizes to the real table (users -> users; person -> people); use the real name otherwise"],"exampleFix":"// before\nscaffoldingTableNames: [\"user\"]   // db has 'users'\n// after (either)\nscaffoldingTableNames: [\"users\"]\nscaffoldingTableNames: [\"public.users\"]","handlingStrategy":"validation","validationCode":"function assertTableExists(tableName, dbSchema) {\n  const inflection = require('inflection');\n  if (String(tableName).includes('.')) return; // qualified name: checked elsewhere\n  const found = Object.keys(dbSchema).some(s =>\n    dbSchema[s][tableName] || dbSchema[s][inflection.tableize(tableName)]);\n  if (!found) throw new Error(`Table '${tableName}' not present in driver metadata`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const resolved = scaffoldingSchema.resolveTableName('users');\n} catch (e) {\n  if (e instanceof UserError && e.message.includes(\"Can't find any table\")) {\n    throw new Error('Verify table name/connection; or pass schema.table');\n  }\n  throw e;\n}","preventionTips":["Cross-check table names against information_schema.tables for the connected DB","Use exact case-sensitive names or fully qualified schema.table form","Ensure the driver has permission to read schema metadata (dbSchema is populated)","Remember inflection pluralization: singular names only work if tableize() matches the real table"],"tags":["scaffolding","schema","table-not-found","data-model"],"backgroundTag":"table-not-found","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}