cube-js / cube-js/cube

CTE not working as expected via SQL-API

Open
#8,413 1 comment 0 reactions 1 assignee Claimed by @paveltiunov View on GitHub
api:sql
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Failed SQL**

Config:
```js
cube('orders', {
sql_table: 'orders',
});
```

Query via SQL-API

```sql
WITH test_filter AS(
SELECT 'order-1' as filter_1
)
SELECT * FROM orders WHERE order_id IN(SELECT filter_1 FROM test_filter)
```

**Error**
```
Error during rewrite: Error during planning: No field named '__subquery-0.filter_1'. Valid fields are '..'.. Please check logs for additional information.
```

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

**Additional context**
Somehow using CTEs with the SQL-API, is not working as expected, for example when used in `IN` Condition or as `LEFT JOIN`

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.