cube-js / cube-js/cube

Extra brackets need to be specified when using dynamic measures

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

Description

**Is your feature request related to a problem? Please describe.**
Example of schema:
```js
"sales":{
"sql":"sum(${CUBE}."Sales")"
},
"wholesaleCost":{
"sql":"sum(${CUBE}."WholesaleCost")"
},
"profit":{
"sql":"${sales} - ${wholesaleCost}"
},
"someCoef":{
"sql":"${profit} / ${sales}"
}
```
This schema is not working. someCoef generates wrong formula`${sales} - ${wholesaleCost}/${sales}` while correct is `(${sales} - ${wholesaleCost})/${sales}`
It can be fixed in 2 ways:
1) someCoef sql should be `(${profit}) / ${sales}` (profit inside brackets)
2) profit sql should be `(${sales} - ${wholesaleCost})` (whole formula inside brackets)

**Describe the solution you'd like**
Cube should check and automatically add brackets if needed

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.