cube icon indicating copy to clipboard operation
cube copied to clipboard

Joins are not inherited (when` extends` is used)

Open igorlukanin opened this issue 2 years ago • 4 comments

Describe the bug From the docs:

The usual pattern is to extract common measures, dimensions, and joins into the base cube and then extend from the base cube

However, joins are not indeed inherited.

To Reproduce Steps to reproduce the behavior:

  1. Use this data model:
cubes:
  - name: cube_joined
    sql: SELECT 123 AS id, 456 AS value

    dimensions:
      - name: id
        sql: id
        type: number
        primary_key: true

      - name: value
        sql: value
        type: number

  - name: cube_parent
    sql: SELECT 1 AS id, 123 AS joined_id, 789 AS value

    joins:
      - name: cube_joined
        relationship: one_to_one
        sql: "{CUBE.joined_id} = {cube_joined.id}"

    dimensions:
      - name: id
        sql: id
        type: number
        primary_key: true

      - name: joined_id
        sql: joined_id
        type: number

      - name: value
        sql: value
        type: number

  - name: cube_child
    extends: cube_parent
  1. Run the following query—it will work:
{
  "dimensions": [
    "cube_parent.value",
    "cube_joined.value"
  ]
}
  1. Then, run the following query—it will fail:
{
  "dimensions": [
    "cube_child.value",
    "cube_joined.value"
  ]
}

Error: Screenshot 2023-09-15 at 14 33 44

Expected behavior Last query should succeed since cube_child should inherit everything from cube_parent.

Version: 0.33.52

igorlukanin avatar Sep 15 '23 12:09 igorlukanin

I'm running into a similar issue, although with slightly different results. I'm defining my Cubes with js instead of yaml, and if a joins collection isn't defined then the joins are inherited as expected. However, if the child cube has an empty joins section or defines additional joins then the parent joins aren't available.

With the following data model: image

I am able to run the following query: image

However, if I add a join in the OnlineOrder Cube like this: image or add an empty joins collection like this: image

When I run the same query as above, I get a similar error as igorlukanin

Can't find join path to join 'OnlineOrder', 'Customer'

I've worked with Cube support on the issue, and at the moment their solution was to just include the joins in the cube you need to use them with if you have additional joins, so in this example I would have to copy the Customer join to the OnlineOrder Cube.

Version: 0.34.0

Bmarquez1997 avatar Nov 21 '23 15:11 Bmarquez1997

Was this fixed in #7433? (released in 0.34.23)

EDIT: looks like a different issue was fixed in #7433 – pre-aggs, not joins

adamfeldman avatar Nov 28 '23 16:11 adamfeldman

Just to add, defining the parent cube in js and the child in yaml also fails to inherit joins, even if the child yaml cube does not define any additional joins.

CaseCal avatar Mar 28 '24 16:03 CaseCal