{"record":{"id":"ee8d6e7500c313dd","repo":"cube-js/cube","slug":"from-members-are-not-found-in-memberpaths-map-m","errorCode":null,"errorMessage":"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.","messagePattern":"From 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":1123,"sourceCode":"    }\n    return fromPreAggObj[0];\n  }\n\n  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(","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts#L1105-L1141","documentation":"After validating members, Cube partitions a join's SQL members into fromMembers (belonging to already-known join cubes) and toMembers. If no member in the join sql resolves to a cube already in the join map, there is nothing on the 'from' side and this UserError is thrown. Typically it means the join references columns instead of dimensions, or uses only the 'to' cube's members.","triggerScenarios":"A rollupJoin join sql whose members all resolve to the 'to' cube (or to raw columns), so filter(m => joinMap.has(m[0])) yields an empty fromMembers array during buildJoinPreAggregationForQuery.","commonSituations":"Writing the join sql using raw SQL column names (e.g. 'orders.customer_id = customers.id') instead of Cube member references; writing the join in the wrong direction so all references point at the 'to' cube; missing template interpolation ('${CUBE}.x') so collectMemberNamesFor finds no cube-prefixed members.","solutions":["Rewrite the join sql to use member references from the from cube, e.g. '${CUBE}.customer_id = ${Customers}.id'.","Ensure the join is defined on the correct cube so '${CUBE}' resolves to the expected from cube.","Replace raw column names with cube-qualified dimension references inside the sql template."],"exampleFix":"// before\nsql: 'orders.customer_id = customers.id' // raw columns, no members found\n// after\nsql: '${CUBE}.customer_id = ${Customers}.id'","handlingStrategy":"validation","validationCode":"// Ensure at least one from-side member appears in a rollupJoin's sql before compiling\nfunction hasFromSideMember(joinSql, fromCubes) {\n  return collectMemberNames(joinSql).some(name => fromCubes.includes(name.split('.')[0]));\n}\nif (!hasFromSideMember(join.sql, [join.from])) throw new Error('Join sql must reference from-cube dimensions');","typeGuard":"null","tryCatchPattern":"try { await cube.query(query); } catch (e) { if (/From members are not found/.test(e.message)) { console.error('Replace raw SQL columns with member references in join:', e.message); } else throw e; }","preventionTips":["Always write join sql as '${CUBE}.field = ${OtherCube}.field'","Never use raw table/column names in join sql","Verify the join is declared on the correct (from) cube","Test rollupJoin compilation after any join edit"],"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"}