## Summary
This PR extends Raw SQL Charts to support [macros that are supported by the Grafana ClickHouse plugin](https://github.com/grafana/clickhouse-datasource?tab=readme-ov-file#macros).
Query Params and Macros are also now included as auto-complete suggestions in the SQL Editor.
### Screenshots or video
<img width="1434" height="1080" alt="Screenshot 2026-03-16 at 12 53 03 PM" src="https://github.com/user-attachments/assets/07f753e4-28f1-43f4-8add-f123dae0b12a" />
### How to test locally or on Vercel
This can be tested in Vercel preview - just reference the supported macros in a raw SQL chart.
### References
- Linear Issue: Closes HDX-3651
- Related PRs:
## Summary
This PR
1. Refactors the SQLEditor and SQLInlineEditor to share code (and a directory) where possible.
2. Adds auto-complete to SQLEditor, for SQL Keywords, table names, database names, columns, map keys, and functions
The SQL editor autocompletion values are pulled from any tables that are registered in HyperDX as a source (or a materialized view on a source).
The PR is broken into one commit which is just file relocation and a second where the other changes are included.
### Screenshots or video
<img width="777" height="923" alt="Screenshot 2026-03-12 at 2 26 01 PM" src="https://github.com/user-attachments/assets/238bb46d-c459-4722-837c-b1682d971c32" />
### How to test locally or on Vercel
This can be tested in the preview environment.
Things to test include the `SQLEditor` for Raw SQL Charting and the `SQLInlineEditor` (used for WHERE and ORDER BY inputs, as well as in the SourceForm.
### References
- Linear Issue: Closes HDX-3620
- Related PRs:
Closes HDX-3580
Closes HDX-3034
## Summary
This PR enhances the support for SQL-driven tables
1. The selected date range can now be referenced in the query with query params. The available query params are outlined in a new section above the SQL input.
2. The table no longer OOMs on large result sets (it is now truncated to the first 10k results), or crashes when selecting columns that are Map or JSON type
3. The table can now be sorted client-side for sql-driven tables
4. There is now placeholder / example SQL in the input
### Screenshots or video
https://github.com/user-attachments/assets/4f39fd0a-d33e-4f8c-9e91-84143d23e293
### How to test locally or on Vercel
This feature can be tested locally or on the preview environment without any special toggles.
### References
- Linear Issue: HDX-3580
- Related PRs:
## Summary
This PR is the first step towards raw SQL-driven charts.
- It introduces updated ChartConfig types, which are now unions of `BuilderChartConfig` (which is unchanged from the current `ChartConfig` types` and `RawSqlChartConfig` types which represent sql-driven charts.
- It adds _very basic_ support for SQL-driven tables in the Chart Explorer and Dashboard pages. This is currently behind a feature toggle and enabled only in preview environments and for local development.
The changes in most of the files in this PR are either type updates or the addition of type guards to handle the new ChartConfig union type.
The DBEditTimeChartForm has been updated significantly to (a) add the Raw SQL option to the table chart editor and (b) handle conversion from internal form state (which can now include properties from either branch of the ChartConfig union) to valid SavedChartConfigs (which may only include properties from one branch).
Significant changes are in:
- packages/app/src/components/ChartEditor/types.ts
- packages/app/src/components/ChartEditor/RawSqlChartEditor.tsx
- packages/app/src/components/ChartEditor/utils.ts
- packages/app/src/components/DBEditTimeChartForm.tsx
- packages/app/src/components/DBTableChart.tsx
- packages/app/src/components/SQLEditor.tsx
- packages/app/src/hooks/useOffsetPaginatedQuery.tsx
Future PRs will add templating to the Raw SQL driven charts for date range and granularity injection; support for other chart types driven by SQL; improved placeholder, validation, and error states; and improved support in the external API and import/export.
### Screenshots or video
https://github.com/user-attachments/assets/008579cc-ef3c-496e-9899-88bbb21eaa5e
### How to test locally or on Vercel
The SQL-driven table can be tested in the preview environment or locally.
### References
- Linear Issue: HDX-3580
- Related PRs: