cube-js/cube · error · UserError
Incorrect format for '${tableName}'. Should be in '<schema>.
Error message
Incorrect format for '${tableName}'. Should be in '<schema>.<table>' format What it means
parseTableName expects a table reference containing exactly two segments (schema and table). If the string does not parse into exactly 2 parts — e.g. no dot at all, or extra dotted parts — this UserError is thrown.
Source
Thrown at packages/cubejs-schema-compiler/src/scaffolding/ScaffoldingSchema.ts:248
cube: this.options.snakeCase ? toSnakeCase(table) : inflection.camelize(table),
tableName,
schema,
table,
measures: this.numberMeasures(tableDefinition),
dimensions,
joins: includeJoins ? this.joins(tableName, tableDefinition) : []
};
}
protected parseTableName(tableName: TableName): [string, string] {
let schemaAndTable;
if (Array.isArray(tableName)) {
schemaAndTable = tableName;
} else {
schemaAndTable = tableName.match(/(["`].*?["`]|[^`".]+)+(?=\s*|\s*$)/g);
}
if (schemaAndTable.length !== 2) {
throw new UserError(`Incorrect format for '${tableName}'. Should be in '<schema>.<table>' format`);
}
return schemaAndTable;
}
protected dimensions(tableDefinition: ColumnData[]): Dimension[] {
return this.dimensionColumns(tableDefinition).map(column => {
const res: Dimension = {
name: column.name,
types: [column.columnType || this.columnType(column)],
title: inflection.titleize(column.name),
};
if (column.columnType !== 'time') {
res.isPrimaryKey = column.attributes?.includes('primaryKey') ||
this.fixCase(column.name) === 'id';
}
return res;
});View on GitHub (pinned to 7d981676b3)
Solutions
- Prefix the table with its schema: 'public.orders'
- If the name itself contains dots, pass ['schema','table'] as an array instead of a string
- Trim stray whitespace/quotes from the table reference before calling
- Check upstream UI/config that builds the table string for missing schema defaults
Example fix
// before
schema.resolveTableDefinition('orders');
// after
schema.resolveTableDefinition('public.orders');
// or
schema.resolveTableDefinition(['public', 'orders']); Defensive patterns
Strategy: validation
Validate before calling
function assertQualifiedTable(t) {
if (Array.isArray(t)) { if (t.length !== 2) throw new Error('Expected [schema, table]'); return; }
const parts = String(t).split('.');
if (parts.length !== 2 || !parts[0] || !parts[1]) throw new Error(`Table ref '${t}' must be '<schema>.<table>'`);
} Type guard
const isQualifiedTableName = (t: unknown): t is string => typeof t === 'string' && /^[^."]+\.[^."+]+$/.test(t.trim());
Try / catch
try { schema.resolveTableDefinition(tableName); } catch (e) { if (e instanceof UserError && e.message.includes('Incorrect format')) { /* apply default schema and retry */ } else throw e; } Prevention
- Apply a default schema when the UI provides a bare table name
- Use the ['schema','table'] array form for programmatic calls
- Trim user input before passing it
- Never concatenate qualified names with extra dotted segments
When it happens
Trigger: Passing 'orders' (no schema), 'a.b.c' (too many segments), or an empty/whitespace string to any API that resolves a table name during scaffolding.
Common situations: Users submit a table selection without a schema qualifier in the Playground generate-schema flow, or programmatically pass a bare table name assuming a default schema will be applied.
Related errors
- Date range expected to be in ${DEFAULT_TS_FORMAT} format but
- Table names should be in <table> or <schema>.<table> format
- Can't parse date: '${from}'
- Can't parse date: '${to}'
- Can't parse date: '${dateString}'
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/43bc2aa7c693f2b0.
Report an issue: GitHub.