cube-js / cube-js/cube

SQL API: Join with CTEs is not working

Open
#8,420 1 comment 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

**Failed SQL**
```sql
with this_week as (
SELECT country, MEASURE(num_customers) AS total_customers_this_week
FROM customers
WHERE week_utc = (EXTRACT(YEAR FROM CURRENT_DATE) + 0) * 100 + EXTRACT(WEEK FROM CURRENT_DATE) + 0
GROUP BY country
), last_week as (
SELECT country, MEASURE(num_customers) AS total_customers_last_week
FROM customers
WHERE week_utc = (EXTRACT(YEAR FROM CURRENT_DATE) + 0) * 100 + EXTRACT(WEEK FROM CURRENT_DATE) - 1
GROUP BY country
)
SELECT this_week.country, total_customers_this_week, total_customers_last_week
FROM this_week
join last_week
on this_week.country = last_week.country
```

**Error**
SQL Error [XX000]: ERROR: Error during rewrite: Use `__cubeJoinField` to join Cubes.

**Logical Plan**
Error during planning

**Version:**
v0.35.55

**Additional context**
I see same error when enabling SQL pushdown

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.