Description
Describe the bug
An error is reported while executing queries involving cubes with joins. This happens only for Clickhouse datasources (the same query works for Mysql datasources). The generated SQL query is valid and can be executed successfully, so the issue seems to occur while mapping the result set values. The reported error message is Error: Member name not found for alias: 'q_0.acube__id'
(no stacktrace is present).
To Reproduce
Execute the following query via the REST API:
{
"dimensions": [
"Acube.id"
],
"measures": [
"Acube.AcubeTotalValue",
"Acube.BcubeTotalValue",
"Acube.CcubeTotalAmount"
]
}
Equivalent SQL API query:
SELECT
Acube.id,
MEASURE(Acube.AcubeTotalValue),
MEASURE(Acube.BcubeTotalValue),
MEASURE(Acube.CcubeTotalAmount)
FROM
Acube
GROUP BY
1
LIMIT
10000;
Minimally reproducible Cube Schema
To test the failing query, a minimal set of 3 joined cubes was used:
cube(`Acube`, {
sql: `SELECT 1 as id, 'Category A' as category, 10 as value UNION ALL
SELECT 2, 'Category B', 20 UNION ALL
SELECT 3, 'Category C', 30`,
joins: {
Bcube: {
relationship: `one_to_many`,
sql: `${Acube}.id = ${Bcube}.id`
},
Ccube: {
relationship: `one_to_many`,
sql: `${Acube}.id = ${Ccube}.id`
},
},
measures: {
AcubeCount: {
type: `count`,
},
AcubeTotalValue: {
type: `sum`,
sql: `value`
},
BcubeTotalValue: {
sql: `${Bcube.totalValue}`,
type: `number`
},
CcubeTotalAmount: {
sql: `${Ccube.totalAmount}`,
type: `number`
},
},
dimensions: {
id: {
sql: `id`,
type: `number`,
primaryKey: true,
shown: true
},
category: {
sql: `category`,
type: `string`
},
appId: {
sql: `'fmgutp'`,
type: `string`
}
}
});
cube(`Bcube`, {
sql: `SELECT 1 as id, 'Bgroup1' as groupName, 50 as value UNION ALL
SELECT 2, 'Bgroup2', 60 UNION ALL
SELECT 3, 'Bgroup3', 70`,
measures: {
count: {
type: `count`
},
totalValue: {
type: `sum`,
sql: `value`
}
},
dimensions: {
id: {
sql: `id`,
type: `number`,
primaryKey: true
},
groupName: {
sql: `groupName`,
type: `string`
}
}
});
cube(`Ccube`, {
sql: `SELECT 1 as id, 'Ctype1' as type, 15 as amount UNION ALL
SELECT 2, 'Ctype2', 25 UNION ALL
SELECT 3, 'Ctype3', 35`,
measures: {
count: {
type: `count`
},
totalAmount: {
type: `sum`,
sql: `amount`
}
},
dimensions: {
id: {
sql: `id`,
type: `number`,
primaryKey: true,
shown: true
},
type: {
sql: `type`,
type: `string`
}
}
});
Version:
v1.2.26 (Docker image)