{"record":{"id":"0ae3b23fefd6f5a1","repo":"cube-js/cube","slug":"to-members-are-not-found-in-memberpaths-map-m","errorCode":null,"errorMessage":"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.","messagePattern":"To members are not found in \\[(.+?)\\] for join (.+?)\\. Please make sure join fields are referencing dimensions instead of columns\\.","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts","lineNumber":1127,"sourceCode":"  private resolveJoinMembers(join: FinishedJoinTree): JoinEdgeWithMembers[] {\n    const joinMap = new Set<string>();\n\n    return join.joins.map(j => {\n      joinMap.add(j.originalFrom);\n\n      const memberPaths = this.query.collectMemberNamesFor(() => this.query.evaluateSql(j.originalFrom, j.join.sql)).map(m => m.split('.'));\n\n      const invalidMembers = memberPaths.filter(m => !joinMap.has(m[0]) && m[0] !== j.originalTo);\n      if (invalidMembers.length) {\n        throw new UserError(`Members ${invalidMembers.join(', ')} in join from '${j.originalFrom}' to '${j.originalTo}' doesn't reference join cubes`);\n      }\n      const fromMembers = memberPaths.filter(m => joinMap.has(m[0])).map(m => m.join('.'));\n      if (!fromMembers.length) {\n        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.`);\n      }\n      const toMembers = memberPaths.filter(m => m[0] === j.originalTo).map(m => m.join('.'));\n      if (!toMembers.length) {\n        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.`);\n      }\n      joinMap.add(j.originalTo);\n\n      return {\n        ...j,\n        fromMembers,\n        toMembers,\n      };\n    });\n  }\n\n  private cubesHintsFromPreAggregation(preAggObj: PreAggregationForQuery): string[][] {\n    return R.uniq(\n      preAggObj.references.measures.concat(\n        preAggObj.references.dimensions\n      ).map(p => p.split('.').slice(0, -1))\n    );\n  }","sourceCodeStart":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts#L1109-L1145","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\njoin: { sql: '${CUBE}.customer_id = ${CUBE}.cust_id' } // both sides from same cube\n// after\njoin: { sql: '${CUBE}.customer_id = ${Customers}.id' }","handlingStrategy":"validation","validationCode":"// Ensure the to-cube is referenced in the rollupJoin's sql\nfunction hasToSideMember(joinSql, toCube) {\n  return collectMemberNames(joinSql).some(name => name.split('.')[0] === toCube);\n}\nif (!hasToSideMember(join.sql, join.to)) throw new Error(`Join sql must reference ${join.to} dimensions`);","typeGuard":"null","tryCatchPattern":"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; }","preventionTips":["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"],"tags":["pre-aggregation","rollup-join","join-sql","members-not-found"],"backgroundTag":"join-sql-missing-member-references","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}