Skip to content

Connecting multiple identical join tables to a cubeΒ #9151

@rihor93

Description

@rihor93

I encountered a strange problem:

First cube:

cube(`Unispr`, {
  sql_table: `dfd."Unispr"`,

  title: `NewGenUniSpr`,

  data_source: `default`,

  joins: {

    ser_table21: {
      sql: `${Cube}."VCode" = ${ser_table21}."column70"`,
      relationship: `many_to_one`
    }
  },

  dimensions: {
    VCode: {
      sql: `${CUBE}."VCode"`,
      type: `number`,
      primary_key: true,
    },
    Name: {
      sql: `${CUBE}."Name"`,
      type: `string`,
    },
  },

  pre_aggregations: {
    // Pre-aggregation definitions go here.
    // Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started
  }
});

Second cube:

cube(`ser_table21`, {
  sql_table: `public."ser_table21"`,

  title: `NewGenTable21`,

  data_source: `default`,

  joins: {

    column70Cube: {
      sql: `${CUBE}.column70 = ${Unispr}."VCode"`,
      relationship: `many_to_one`
    }, 
   column72Cube: {
      sql: `${CUBE}.column72 = ${Unispr}."VCode"`,
      relationship: `many_to_one`
    }, 
  },

  dimensions: {
    VCode: {
      sql: `${CUBE}."VCode"`,
      type: `number`,
      primary_key: true,
    },
    column70: {
      sql: `${column70Cube.Name}`,
      title: `Test1`,
      type: `string`,
    },
    column72: {
      sql: `${column72Cube.Name}`,
      title: `Test2`,
      type: `string`,
    },

  },
  measures: {
    count: {
      title: `Count`,
      type: `count`
    },
  },

  pre_aggregations: {
    // Pre-aggregation definitions go here.
    // Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started
  }

});

When executed, it gives the error missing FROM-clause entry for table "unispr", in sql you can see that the left join is set incorrectly

SELECT
  "column70_cube"."Name" "ser_table21__column70",
  count("ser_table21"."VCode") "ser_table21__count"
FROM
  public."ser_table21" AS "ser_table21"
  LEFT JOIN dfd."Unispr" AS "column70_cube" ON "ser_table21".column70 = "unispr"."VCode"
GROUP BY
  1
ORDER BY
  2 DESC
LIMIT
  10000

Is this a feature or a bug?

Metadata

Metadata

Assignees

Labels

questionThe issue is a question. Please use Stack Overflow for questions.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions