cube-js / cube-js/cube

Min measure for a Date field throws "Float cannot represent non numeric value"

Open
#5,652 1 comment 1 reaction 1 assignee Claimed by @vasilev-alex View on GitHub
api:graphql
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Describe the bug**
When using a `min` measure type on a DateTime field there is a casting error when querying via GraphQL

**To Reproduce**
1. Have a Cube with a min measure type on a DateTime field (we are using PostGres):
```javascript
minDate: {
sql: `created_at`,
type: `min`,
},
```
2. Query for the field using GraphQL:
```javascript
query CubeQuery {
cube {
generalLedger_Income {
minDate
}
}
}
```

3.
```javascript
{"errors":[{"message":"**Float cannot represent non numeric value: \"2020-06-25T14:00:00.000\**"","locations":[{"line":6,"column":7}],"path":["cube",0,"generalLedger_Income","minDate"]}],"data":{"cube":[{"generalLedger_Income":{"minDate":null,"__typename":"GeneralLedger_IncomeMembers"},"__typename":"Result"}]}}
```

**Expected behavior**
Min and Max should be able to be used on Date fields as well

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Minimally reproducible Cube Schema**
In case your bug report is data modelling related please put your minimally reproducible Cube Schema here.
You can use selects without tables in order to achieve that as follows.

```javascript
cube(`generalLedger_Income`, {
sql: `
select now() as created_at
UNION ALL
select now() as created_at
`,
measures: {
minDate: {
sql: `created_at`,
type: `min`,
},
},
});
```

**Version:**
0.31.11

**Additional context**

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.