如何从查询中删除 CubeJS 默认的 Group By 子句
How to remove CubeJS default Group By clause from query
CubeJS 默认应用 Group By 子句,当我们 运行 任何查询时。
例如下面是我的 JSON 员工 Cube 查询:
{
"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 :
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.10.62 以来有 ungrouped
查询 属性:https://cube.dev/docs/query-format#query-properties。在您的情况下,可以使用以下查询:
{
"dimensions": [
"Employee.date",
"Employee.state",
"Employee.id"
],
"timeDimensions": [],
"filters": [],
"ungrouped": true
}
CubeJS 默认应用 Group By 子句,当我们 运行 任何查询时。
例如下面是我的 JSON 员工 Cube 查询:
{
"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 :
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.10.62 以来有 ungrouped
查询 属性:https://cube.dev/docs/query-format#query-properties。在您的情况下,可以使用以下查询:
{
"dimensions": [
"Employee.date",
"Employee.state",
"Employee.id"
],
"timeDimensions": [],
"filters": [],
"ungrouped": true
}