Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting multiple identical join tables to a cube #9151

Open
rihor93 opened this issue Jan 28, 2025 · 0 comments
Open

Connecting multiple identical join tables to a cube #9151

rihor93 opened this issue Jan 28, 2025 · 0 comments
Labels
question The issue is a question. Please use Stack Overflow for questions.

Comments

@rihor93
Copy link

rihor93 commented Jan 28, 2025

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?

@rihor93 rihor93 added the question The issue is a question. Please use Stack Overflow for questions. label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue is a question. Please use Stack Overflow for questions.
Projects
None yet
Development

No branches or pull requests

1 participant