cube-js/cube · error · UserError
To members are not found in [${memberPaths.map(m => m.join('
Error message
To members are not found in [${memberPaths.map(m => m.join('.')).join(', ')}] for join ${JSON.stringify(j)}. Please make sure join fields are referencing dimensions instead of columns. What it means
Symmetric to the from-side check: Cube expects at least one member in the join sql to belong to the join's 'to' cube (the cube being joined to). If none resolve to j.originalTo, this UserError is thrown, again usually because columns are referenced directly instead of dimensions.
Source
Thrown at packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts:1127
private resolveJoinMembers(join: FinishedJoinTree): JoinEdgeWithMembers[] {
const joinMap = new Set<string>();
return join.joins.map(j => {
joinMap.add(j.originalFrom);
const memberPaths = this.query.collectMemberNamesFor(() => this.query.evaluateSql(j.originalFrom, j.join.sql)).map(m => m.split('.'));
const invalidMembers = memberPaths.filter(m => !joinMap.has(m[0]) && m[0] !== j.originalTo);
if (invalidMembers.length) {
throw new UserError(`Members ${invalidMembers.join(', ')} in join from '${j.originalFrom}' to '${j.originalTo}' doesn't reference join cubes`);
}
const fromMembers = memberPaths.filter(m => joinMap.has(m[0])).map(m => m.join('.'));
if (!fromMembers.length) {
throw new UserError(`From members are not found in [${memberPaths.map(m => m.join('.')).join(', ')}] for join ${JSON.stringify(j)}. Please make sure join fields are referencing dimensions instead of columns.`);
}
const toMembers = memberPaths.filter(m => m[0] === j.originalTo).map(m => m.join('.'));
if (!toMembers.length) {
throw new UserError(`To members are not found in [${memberPaths.map(m => m.join('.')).join(', ')}] for join ${JSON.stringify(j)}. Please make sure join fields are referencing dimensions instead of columns.`);
}
joinMap.add(j.originalTo);
return {
...j,
fromMembers,
toMembers,
};
});
}
private cubesHintsFromPreAggregation(preAggObj: PreAggregationForQuery): string[][] {
return R.uniq(
preAggObj.references.measures.concat(
preAggObj.references.dimensions
).map(p => p.split('.').slice(0, -1))
);
}View on GitHub (pinned to 7d981676b3)
Solutions
- Reference at least one dimension from the to cube in the join sql, e.g. '${Customers}.id'.
- Fix the cube name in the join definition so originalTo matches the cube actually referenced.
- Replace raw column names with template member references for the to cube.
Example fix
// before
join: { sql: '${CUBE}.customer_id = ${CUBE}.cust_id' } // both sides from same cube
// after
join: { sql: '${CUBE}.customer_id = ${Customers}.id' } Defensive patterns
Strategy: validation
Validate before calling
// Ensure the to-cube is referenced in the rollupJoin's sql
function hasToSideMember(joinSql, toCube) {
return collectMemberNames(joinSql).some(name => name.split('.')[0] === toCube);
}
if (!hasToSideMember(join.sql, join.to)) throw new Error(`Join sql must reference ${join.to} dimensions`); Type guard
null
Try / catch
try { await cube.query(query); } catch (e) { if (/To members are not found/.test(e.message)) { console.error('Join sql never references the to cube; check cube name and member prefixes:', e.message); } else throw e; } Prevention
- Confirm join.to matches the cube name used in the sql template
- Reference exactly one dimension per side of the ON condition
- Avoid same-cube self-joins written via rollupJoin sql without distinct cube prefixes
- Compile schemas in CI to catch these early
When it happens
Trigger: A rollupJoin join sql containing no member whose cube prefix equals j.originalTo — e.g. both sides of the ON condition reference from-cube dimensions or raw SQL — during buildJoinPreAggregationForQuery.
Common situations: Typo in the 'to' cube name in the join definition; join sql written with both sides from the same cube; raw SQL columns instead of '${ToCube}.member' references; wrong join direction configured in the joins array.
Related errors
- From members are not found in [${memberPaths.map(m => m.join
- Members ${invalidMembers.join(', ')} in join from '${j.origi
- Can't build join tree for pre-aggregation ${preAggObj.cube}.
- Nothing to join in rollup join. Target joins ${JSON.stringif
- No rollups found that can be used for a rollup join from "${
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/0ae3b23fefd6f5a1.
Report an issue: GitHub.