cube-js / cube-js/cube

No results returned when a value of a contains filter has an underscore (duckdb driver)

Open
#7,492 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

**Describe the bug**
If a value passed to the filter has an underscore when using the `contains` operator, no results are returned. I'm using duckdb driver.

I did some investigation on how the SQL query is executed by the cube api backend and found that it add `\\` before the `_`. Due to this reason the first `\` escapes the second `\` and the search term passed to the db becomes `transfer\_only` instead of `transfer_only`.

As far as I understand (I could be wrong) duckdb does not need extra escape characters, but you can provide one if you want.

Any help would be greatly appreciated. Happy to do more debugging if that would help with the process.

Example JSON Query.

```json
{
"measures": [
"employees.COUNT"
],
"filters": [
{
"member": "employees.ALL_SPLITS",
"operator": "contains",
"values": [
"transfer_only",
"fixed_only"
]
}
]
}
```

**To Reproduce**
Steps to reproduce the behavior:

- Select measures or dimensions from the playground
- Add filter by selecting an appropriate column and add values with _ (underscore) i.e. "transfer_only"
- No results retured even though you have data that contains the "transfer_only".

**Expected behavior**
- Select measures or dimensions from the playground
- Add filter by selecting an appropriate column and add values with _ (underscore) i.e. "transfer_only"
- No results retured even though you have data that contains the "transfer_only".

**Version:**
0.34.16

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.