Bug with subquery and JOIN operation within filters
- Dominant language
- Rust
- Stars
- 20.8k
- Forks
- 2.1k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 203
Description
A cube crashes when we use `field_2` as a filter but works well when we use `field_2` as dimensions.
**Steps to reproduce the behavior:**
1. Run a query with filters:
```json
{
"filters": [
{
"member": "model_b.field_2",
"operator": "set"
}
],
"dimensions": [
"model_b.field_2",
"model_b.cube_unique_id"
],
"order": {
"model_b.field_2": "asc"
}
}
```
and then receive an error:
```json
RangeMaximum call stack size exceeded
```
2. Run without filters:
```json
{
"dimensions": [
"model_b.field_2",
"model_b.cube_unique_id"
],
"order": {
"model_b.field_2": "asc"
}
}
```
**Minimally reproducible Cube Schema:**
```javascript
asyncModule(async () => {
cube('model_a', {
sql: `select * from table`,
dimensions: {
field_1: {
sql: `field_1`,
type: 'string'
},
},
});
cube('model_b', {
sql: `select * from table`,
dimensions: {
cube_unique_id: {
sql: `row_id`,
type: 'string',
primary_key: true
},
field_1: {
sql: `sum(${metric_1}) over ()`,
type: `number`,
sub_query: true,
propagate_filters_to_sub_query: true,
},
field_2: {
sql: `${model_a.field_1}`,
type: 'string'
},
},
measures: {
metric_1: {
sql: `metric_1`,
type: 'max'
}
},
joins: {
model_a: {
relationship: 'one_to_one',
sql: `${CUBE.field_1} = ${model_a.field_1}`
},
},
});
})
```
**Version:** 0.35.1
Contributor guide
Research direction
Use the minimally reproducible Cube schema as the entry point, then run the filtered and unfiltered JSON queries to compare their behavior. Trace the interaction between the sub_query, propagate_filters_to_sub_query, and model_a join; done means the filtered query no longer raises a call-stack error and returns successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, sql
- Domain
- backend-api-design, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100