cube-js / cube-js/cube

Filter by string measure doesn't work (equals operator)

Open
#9,595 2 comments 1 reaction 0 assignees View on GitHub
data source driver driver:clickhouse
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Describe the bug**
I have a string measure (it's supported https://cube.dev/docs/reference/data-model/types-and-formats#string) in my schema and I'm trying to run a query which contains a filter by this measure ("equals" operator). Cubejs returns following error message:
`Query failed: Error: Cannot parse string 'device_A' as Float64: syntax error at begin of string. Note: there are toFloat64OrZero and toFloat64OrNull functions, which returns zero/NULL instead of throwing exception.: While processing argMax(device_name, max_timestamp) = toFloat64('device_A'). ; query id: d9ca2185-8df2-4638-8470-7b919d33bd5b`

Query I'm running:
```
{
"dimensions": [
"Cube.id"
],
"measures": [
"Cube.latest_device_name"
],
"filters": [
{
"member": "Cube.latest_device_name",
"operator": "equals",
"values": [
"device_A"
]
}
]
}
```
Noticed also that "operator": "contains" works as expected.

**Expected behavior**
Filter by string measure works.

**Screenshots**
Image

**Minimally reproducible Cube Schema**
```javascript
cube(`Cube`, {
measures: {
latest_device_name: {
sql: `argMax(device_name, timestamp)`,
type: `string`
},
},
dimensions: {
device_name: {
sql: `device_name`,
type: `string`
},
id: {
sql: `id`,
type: `string`
},
timestamp: {
sql: `timestamp`,
type: `time`
}
}
});
```

**Version:**
[e.g. 1.3.16]

**Additional context**
Previosly I had a similar issue with time measures and it has been fixed: https://github.com/cube-js/cube/issues/9435

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.