cube-js / cube-js/cube

type:number_agg seems to not be working

Open
#10,799 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

Trying to use number_agg instead of number cause problems with this dense_rank()
``` measures: {
count: {
type: `count`,
},
count_rank: {
multi_stage: true,
type: `number`,
sql: `DENSE_RANK() OVER (ORDER BY ${count} DESC)`
},
```
vs
``` measures: {
count: {
type: `count`,
},
count_rank: {
multi_stage: true,
type: `number_agg`,
sql: `DENSE_RANK() OVER (ORDER BY ${count} DESC)`
}
```

Gives me
```ER_PARSE_ERROR: Getting analyzing error from line 16, column 69 to line 16, column 132. Detail message: 'dense_rank() OVER (ORDER BY `fk_aggregate`.`orders__count` DESC)' must be an aggregate expression or appear in GROUP BY clause.
```
on the sample cube
```cube(`Orders`, {
sql: `
select 1 as id, 100 as amount, 'new' status
UNION ALL
select 2 as id, 200 as amount, 'new' status
UNION ALL
select 3 as id, 300 as amount, 'processed' status
UNION ALL
select 4 as id, 500 as amount, 'processed' status
UNION ALL
select 5 as id, 600 as amount, 'shipped' status
`,
measures: {
count: {
type: `count`,
},
count_rank: {
multi_stage: true,
type: `number_agg`,
sql: `DENSE_RANK() OVER (ORDER BY ${count} DESC)`
},

totalAmount: {
sql: `amount`,
type: `sum`,
},
toRemove: {
type: `count`,
},
},
dimensions: {
status: {
sql: `status`,
type: `string`,
},
},
});
```
And on my posgresql (starrocks) gives
```
ER_PARSE_ERROR: Getting analyzing error from line 51, column 385 to line 51, column 495. Detail message: No matching function with signature: numberagg(bigint(20)).
```

As the SQL sent has
```(...)
numberAgg(numberAgg(DENSE_RANK() OVER (ORDER BY `fk_aggregate`.`xyx` DESC))) OVER (PARTITION BY `fk_aggregate`.`xxx`,
(...)
```

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.