Zero-option "case" dimensions compile but don't work
- Dominant language
- Rust
- Stars
- 20.8k
- Forks
- 2.1k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 181
Description
**Describe the bug**
It is possible to create a dimension of the "case" type with no options in the "when" array and just the "else" statement. The data model would compile but the resulting SQL would be incorrect and wouldn't run.
**To Reproduce**
Steps to reproduce the behavior:
1. Add a dimension like this:
```js
area: {
case: {
when: [
],
else: { label: `Unknown` }
},
type: `string`,
},
```
2. When querying, see it's compiled to the following:
```sql
SELECT
CASE
ELSE 'Unknown'
END `web_sessions__area`,
...
```
3. See the error:
```
Syntax error: Unexpected keyword ELSE at [3:6]
```
**Expected behavior**
I think that any of these two options would work:
- a dimension like this is considered _incorrect_ and wouldn't validate/compile
- a dimension like this is considered _correct_ and would compile to a correct SQL query (essentially becoming a string dimension)
**Screenshots**
—
**Minimally reproducible Cube Schema**
See above.
**Version:**
0.31.62
Contributor guide
Assessment
This issue has not been assessed yet.