cube-js / cube-js/cube

SQL-API: Preset series limit sub query is not supported

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

Description

**Failed SQL**
```sql
QUERY: SELECT Date_trunc('day', invoice_paid_at) AS invoice_paid_at,
brand AS brand,
Measure(aov.average_order_value) AS average_order_value
FROM "aov"
JOIN (SELECT brand AS brand__,
Measure(aov.average_order_value) AS mme_inner__
FROM "aov"
WHERE invoice_paid_at >= Str_to_date('2024-05-01 00:00:00.000000',
'YYYY-MM-DD HH24:MI:SS.US')
AND invoice_paid_at <
Str_to_date('2024-06-01 00:00:00.000000',
'YYYY-MM-DD HH24:MI:SS.US')
GROUP BY brand
ORDER BY mme_inner__ DESC
LIMIT 5) AS series_limit
ON brand = brand__
WHERE invoice_paid_at >= Str_to_date('2024-05-01 00:00:00.000000',
'YYYY-MM-DD HH24:MI:SS.US')
AND invoice_paid_at < Str_to_date('2024-06-01 00:00:00.000000',
'YYYY-MM-DD HH24:MI:SS.US')
GROUP BY Date_trunc('day', invoice_paid_at),
brand
ORDER BY average_order_value DESC
LIMIT 10000
```

**Logical Plan**
`Error: Error during rewrite: Use __cubeJoinField to join Cubes.`

**Version:**
v0.35.52

**Additional context**
In Preset, I'm trying to add a series limit on my dimension split. However, as it's trying to run a subquery, Cube is spitting out an error.
![image](https://github.com/cube-js/cube/assets/42994656/c8642918-17b7-49d2-87c0-0aac22b71e29)

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.