CubeJS 默认会应用 Group By 子句。
例如下面是我对雇员多维数据集的JSON查询:
{
"dimensions": [
"Employee.date",
"Employee.state",
"Employee.id"
],
"timeDimensions": [],
"filters": []
}
当我在CubeJS中的JSON查询上运行时,它将在SQL下运行:
SELECT
`employee`.updatedAt `employee__date`,
`employee`.state `employee__state`,
`employee`.EmpId `employee__id`
FROM
DEMO.Employee AS `employee`
GROUP BY
1,
2,
3
ORDER BY
1 ASC
LIMIT
10000
下面供参考的是我拥有的 Employee 多维数据集:
cube(`Employee`, {
sql: `SELECT * FROM DEMO.Employee `,
title: `Employee`,
measures: {
count: {
type: `count`
}
},
dimensions: {
id: {
sql: `EmpId`,
type: `string`
},
date: {
sql: `updatedAt`,
type: `time`
},
state: {
sql: `state`,
type: `string`
}
}
});
如果我期望在SQL下运行,我需要创建什么JSON查询:
SELECT
`employee`.updatedAt `employee__date`,
`employee`.state `employee__state`,
`employee`.EmpId `employee__id`
FROM
DEMO.Employee AS `employee`
WHERE
`employee`.updatedAt ` BETWEEN '2019-01-01' AND '2019-05-01'
LIMIT
10000
是否可以从CubeJS本身生成的SQL查询中删除 Group By 子句。
答案 0 :(得分:0)
自0.10.62开始,有ungrouped
个查询属性,用于:https://cube.dev/docs/query-format#query-properties。在您的情况下,可以使用以下查询:
{
"dimensions": [
"Employee.date",
"Employee.state",
"Employee.id"
],
"timeDimensions": [],
"filters": [],
"ungrouped": true
}