cube-js/cube

How to join same table twice ?

Open

#3,692 opened on 2021年11月17日

GitHub で見る
 (8 comments) (1 reaction) (1 assignee)Rust (1,965 forks)batch import
help wanted

Repository metrics

Stars
 (19,563 stars)
PR merge metrics
 (平均マージ 5d 16h) (30d で 138 merged PRs)

説明

Problem

Want to join same table twice, but the key must be the cube name

Related Cube.js schema

// how to avoid this ?
cube(`CalleeUsers`, {
  extends: Users,
});

cube(`PhoneCallEvents`, {
  sql: `SELECT * FROM public.phone_call_events`,
  joins: {
    // want to use the key as CallerUser, but CallerUser cube not exists
    Users: {
     toCude: Users, // maybe support specify the target cube in here ?
      relationship: `belongsTo`,
      sql: `${PhoneCallEvents}.caller_object_id = ${Users}.id`,
    },
    // above cube make this work
    CalleeUsers: {
      relationship: `belongsTo`,
      sql: `${PhoneCallEvents}.callee_object_id = ${CalleeUsers}.id`,
    },
  },
}
)

New to cubejs, don't know if there is a way to handle join same table twice.

コントリビューターガイド