cube-js / cube-js/cube

Connecting multiple identical join tables to a cube

Open
#9,151 0 comments 0 reactions 1 assignee Claimed by @igorlukanin View on GitHub
question
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 10h
Merged PRs (30d)
203

Description

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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.