Pre-aggregations would not build if they only contain `count_distinct_approx` measures
- Dominant language
- Rust
- Stars
- 20.8k
- Forks
- 2.1k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 181
Description
**Describe the bug**
If a pre-aggregation contains only `count_distinct_approx` measures (one, two, etc.) and no other dimensions or measures, it will not build. Instead, the an error is shown.
**To Reproduce**
Steps to reproduce the behavior:
1. Take the data model below.
2. Run a query to the `mes` measure in Playground so that a p-reaggregation build is triggered.
3. See the following error:
```
Error during create table:
CREATE TABLE prod_pre_aggregations.my_cube_test_main_qilx5vis_ieu50pzh_1jimlbg (`my_cube_test__mes` BYTES) LOCATION ?:
Sort key size can't be 0 for default, columns: [Column { name: "my_cube_test__mes", column_type: Bytes, column_index: 0 }]
```
**Expected behavior**
The pre-aggregation builds.
**Screenshots**
**Minimally reproducible Cube data model**
```javascript
cube(`my_cube_test`, {
sql: `
SELECT 123 AS abc UNION ALL
SELECT 234 AS abc UNION ALL
SELECT 345 AS abc
`,
measures: {
mes: {
sql: `abc`,
type: `count_distinct_approx`
}
},
pre_aggregations: {
main: {
measures: [ mes ]
}
}
})
```
**Version:**
v1.1.2
**Additional context**
Adding a `count` measure or a dimension to the pre-aggregation definition makes the error go away.
Contributor guide
Assessment
This issue has not been assessed yet.