Commit 1d83beb
authored
feat: Add support for dashboard filters on Raw SQL Charts (#1924)
## Summary
This PR updates Raw SQL charts with support for dashboard filters, using the $__filters macro.
Lucene global filters require a Source to be included in the ChartConfig, for schema introspection and the `implicitColumnExpression` value. To support Lucene filters, this PR also updates the RawSqlChartConfig type to include optional `source`, `implicitColumnExpression`, and `from` properties. Only `source` is saved in the database. The external API has been updated to accept the `source` field for raw SQL charts as well.
Dashboard import/export has also been updated to support source mapping for raw sql charts with sources.
### Screenshots or video
Both the global filter and the drop-down filters are applied:
<img width="683" height="574" alt="Screenshot 2026-03-17 at 10 57 36 AM" src="https://github.com/user-attachments/assets/280ba0b5-55f7-4107-a55c-eeb1497ac7de" />
To render Lucene conditions, we require Source information (the `from` and `implicitColumnExpression` fields). When a source is not set, filters are therefore not applied:
<img width="782" height="618" alt="Screenshot 2026-03-17 at 10 54 41 AM" src="https://github.com/user-attachments/assets/3ad19ea7-12ee-4334-abe2-8985a0be952c" />
Similarly, if the `$__filters` macro is not used, then the filters are not applied
<img width="704" height="292" alt="Screenshot 2026-03-17 at 10 56 33 AM" src="https://github.com/user-attachments/assets/e1169e4a-2f64-4cd2-bc05-f699fecef8c1" />
Import:
<img width="993" height="669" alt="Screenshot 2026-03-17 at 3 35 16 PM" src="https://github.com/user-attachments/assets/6ebe20c0-19e2-4e90-95d0-8b02c2af0612" />
### How to test locally or on Vercel
This can be tested in the preview environment.
1. Create a saved dashboard and add some filters.
2. Create a raw sql tile, with or without the $__filters macro
3. Try selecting filters, deselecting filters, and applying global SQL and Lucene filters
4. Inspect the generated queries in the console.
### References
- Linear Issue: Closes HDX-3694
- Related PRs:1 parent 031ca83 commit 1d83beb
29 files changed
Lines changed: 827 additions & 219 deletions
File tree
- .changeset
- packages
- api
- src
- routers/external-api
- __tests__
- v2
- utils
- utils
- app/src
- components
- ChartEditor
- hooks
- common-utils/src
- __tests__
- core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1389 | 1389 | | |
1390 | 1390 | | |
1391 | 1391 | | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1392 | 1397 | | |
1393 | 1398 | | |
1394 | 1399 | | |
| |||
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2311 | 2311 | | |
2312 | 2312 | | |
2313 | 2313 | | |
| 2314 | + | |
2314 | 2315 | | |
2315 | 2316 | | |
2316 | 2317 | | |
| |||
2324 | 2325 | | |
2325 | 2326 | | |
2326 | 2327 | | |
| 2328 | + | |
2327 | 2329 | | |
2328 | 2330 | | |
2329 | 2331 | | |
| |||
2342 | 2344 | | |
2343 | 2345 | | |
2344 | 2346 | | |
| 2347 | + | |
2345 | 2348 | | |
2346 | 2349 | | |
2347 | 2350 | | |
| |||
2359 | 2362 | | |
2360 | 2363 | | |
2361 | 2364 | | |
| 2365 | + | |
2362 | 2366 | | |
2363 | 2367 | | |
2364 | 2368 | | |
| |||
2374 | 2378 | | |
2375 | 2379 | | |
2376 | 2380 | | |
| 2381 | + | |
2377 | 2382 | | |
2378 | 2383 | | |
2379 | 2384 | | |
| |||
2389 | 2394 | | |
2390 | 2395 | | |
2391 | 2396 | | |
| 2397 | + | |
2392 | 2398 | | |
2393 | 2399 | | |
2394 | 2400 | | |
| |||
2457 | 2463 | | |
2458 | 2464 | | |
2459 | 2465 | | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
2460 | 2503 | | |
2461 | 2504 | | |
2462 | 2505 | | |
| |||
3100 | 3143 | | |
3101 | 3144 | | |
3102 | 3145 | | |
| 3146 | + | |
3103 | 3147 | | |
3104 | 3148 | | |
3105 | 3149 | | |
| |||
3114 | 3158 | | |
3115 | 3159 | | |
3116 | 3160 | | |
| 3161 | + | |
3117 | 3162 | | |
3118 | 3163 | | |
3119 | 3164 | | |
| |||
3133 | 3178 | | |
3134 | 3179 | | |
3135 | 3180 | | |
| 3181 | + | |
3136 | 3182 | | |
3137 | 3183 | | |
3138 | 3184 | | |
| |||
3151 | 3197 | | |
3152 | 3198 | | |
3153 | 3199 | | |
| 3200 | + | |
3154 | 3201 | | |
3155 | 3202 | | |
3156 | 3203 | | |
| |||
3167 | 3214 | | |
3168 | 3215 | | |
3169 | 3216 | | |
| 3217 | + | |
3170 | 3218 | | |
3171 | 3219 | | |
3172 | 3220 | | |
| |||
3183 | 3231 | | |
3184 | 3232 | | |
3185 | 3233 | | |
| 3234 | + | |
3186 | 3235 | | |
3187 | 3236 | | |
3188 | 3237 | | |
| |||
3271 | 3320 | | |
3272 | 3321 | | |
3273 | 3322 | | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
3274 | 3362 | | |
3275 | 3363 | | |
3276 | 3364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
102 | 126 | | |
103 | 127 | | |
104 | 128 | | |
| |||
823 | 847 | | |
824 | 848 | | |
825 | 849 | | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
826 | 854 | | |
827 | 855 | | |
828 | 856 | | |
| |||
1669 | 1697 | | |
1670 | 1698 | | |
1671 | 1699 | | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
1675 | | - | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
1676 | 1706 | | |
1677 | 1707 | | |
1678 | 1708 | | |
| |||
1687 | 1717 | | |
1688 | 1718 | | |
1689 | 1719 | | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
1690 | 1727 | | |
1691 | 1728 | | |
1692 | 1729 | | |
| |||
1902 | 1939 | | |
1903 | 1940 | | |
1904 | 1941 | | |
1905 | | - | |
1906 | | - | |
1907 | | - | |
1908 | | - | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
1909 | 1948 | | |
1910 | 1949 | | |
1911 | 1950 | | |
| |||
1920 | 1959 | | |
1921 | 1960 | | |
1922 | 1961 | | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
1923 | 1969 | | |
1924 | 1970 | | |
1925 | 1971 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
| |||
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
| 137 | + | |
134 | 138 | | |
135 | 139 | | |
136 | 140 | | |
| |||
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| 146 | + | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
| |||
342 | 347 | | |
343 | 348 | | |
344 | 349 | | |
| 350 | + | |
345 | 351 | | |
346 | 352 | | |
347 | 353 | | |
| |||
358 | 364 | | |
359 | 365 | | |
360 | 366 | | |
| 367 | + | |
361 | 368 | | |
362 | 369 | | |
363 | 370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| |||
0 commit comments