cube-js/cube

How to join same table twice ?

Open

#3 692 ouverte le 17 nov. 2021

Voir sur GitHub
 (8 commentaires) (1 réaction) (1 assigné)Rust (1 965 forks)batch import
help wanted

Métriques du dépôt

Stars
 (19 563 stars)
Métriques de merge PR
 (Merge moyen 5j 16h) (138 PRs mergées en 30 j)

Description

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.

Guide contributeur