Who can use it?
- Admin and Manager roles can add, edit, and delete custom query widgets
- Anyone who can view a dashboard can view the custom query widgets on it
- You can only add widgets to dashboards you can edit: organization dashboards, or restricted dashboards you created
Adding a custom query widget
- Open a custom dashboard and click the pencil icon to enter edit mode
- Click Add widget
- Under Custom, choose Custom query
Generating SQL with AI
1
Ask a question
Type your question in the Question box, for example “Weekly merged PRs by team over the last quarter” or “AI spend per engineer this month”. Press Enter or click Generate SQL. Use Shift+Enter for a new line.
2
Watch the agent work
A Thinking panel shows each step the agent takes: inspecting tables, running test queries, and revising its answer. A run stops after 5 minutes if the agent hasn’t finished.
3
Review the result
When the agent is done, the SQL, chart type, and chart settings are filled in. If you left Widget title blank, the agent suggests one.
Writing SQL manually
Click Write SQL manually to skip the AI and write the query yourself. A widget title is required in this mode. Click Use AI to switch back. Custom queries use the ClickHouse SQL dialect. See SQL rules for what’s supported.Previewing and saving
- Click Preview to run the SQL. The preview shows up to 10,000 rows, with dashboard filters already applied
- Adjust the chart type and settings (see Chart types)
- Optionally add a Description, shown beneath the chart title
- Click Save to dashboard
Editing and removing a widget
In dashboard edit mode, each custom query widget has:- A chart type switcher in its header to change the chart type
- An Edit query button to reopen the modal with the question and SQL filled in
- An inline title and description you can click to edit
- An X button in the top-right corner to remove it from the dashboard
Chart types
Weave picks a default based on the query: scatter when the query has x and y columns, line when it has a time column, bar when the AI provided chart settings, and table otherwise. Scatter queries can switch between table and scatter. All other queries can switch between table, bar, line, and pie. A line chart with no time column falls back to bar.
Chart settings
For bar, line, pie, and scatter charts, you can change:
Ratio divides the sum of a Numerator column by the sum of a Denominator column in each group, for example bugs opened divided by PRs merged. You can also raise the summed numerator to a Numerator power of 2 or 3. Ratio needs at least two numeric columns in the preview.
The grouping column, value column, time column, and top-N limit are set by the AI. To change them, edit the question or the SQL.
Bar and line charts grouped by people or teams have a sort menu: Alphabetical, Value, or Random.
Tables
For tables, Group by collapses rows into one summary row per value of a text column. Expand a group to see its rows. The chart’s value column uses the widget’s aggregation (Sum, Average, or Count; Ratio shows as a sum), other numeric columns are summed by default, and text columns show a count of distinct values. Click any column header to sort.Headline number
Bar and line charts show a headline number in the top-right corner: a total for Sum and Count, or an average for Average and Ratio. When the chart has a time axis and a date filter is set, a pill shows the change against the previous period of the same length.Dashboard filters and granularity
Dashboard filters apply to a custom query only when its results include a matching column:
If a query has no matching column for a filter, that filter doesn’t affect the widget and no warning is shown. The AI includes these columns by default. If you write SQL yourself, keep them in your
SELECT so filters work, and leave date ranges out of the WHERE clause.
Charts with a time column group rows by the dashboard’s granularity (day, week, month, quarter, year) in your organization’s timezone. See Filters and granularity.
Queries that use a relative time axis, such as “weeks since each engineer’s first PR”, ignore the date filter.
Drill-down and export
In view mode, click a bar, line point, pie slice, or scatter point to see the underlying rows. Drill-down shows the rows your SQL returned, so a query that returns one row per PR drills down to individual PRs, while a pre-aggregated query drills down to its aggregate rows. Drill-down requires drill-down permission for your role. Admins can click Export as CSV in a widget’s menu to download what’s on screen. See CSV export.Available data
Custom queries can read Weave’s analytics tables for your organization. Commonly used tables include:
There are also tables for AI tool usage (Claude Code, Cursor, GitHub Copilot, Codex, Gemini, Windsurf, and others), CI/CD pipelines, calendars, and connected accounts. The AI can inspect any table’s columns while it works, so you don’t need to know table names to ask a question.
Names and privacy
Columns that hold people, repository, team, or PR IDs display as names and avatars. This works only when the column keeps its original name, such asauthor_account_id, repository_id, or team_id. Renaming an ID column with AS shows the raw ID instead.
To protect sensitive content, some columns can’t be queried, including email addresses, usernames, display names, PR descriptions, comment bodies, chat message text, and AI prompt content.
SQL rules
Custom queries accept a single ClickHouseSELECT statement.
- Supported: joins, subqueries, CTEs (
WITH),GROUP BY,HAVING,UNION ALL, and window functions (row_number,rank,dense_rank) - Not supported: anything other than
SELECT,UNION/INTERSECT/EXCEPT,WITH RECURSIVE, and comma-separated tables inFROM(use explicitJOINs) - Functions: common aggregate, math, string, date, type conversion, conditional, array, and null-handling functions are allowed. For example
count,sum,avg,countIf,uniqExact,round,lower,toStartOfWeek,dateDiff,if,multiIf,coalesce, andarrayJoin. Other functions returnfunction "x" is not allowed. For conditional aggregates other thancountIfandsumIf, usemax(if(condition, column, NULL)) - Reserved words: quote columns such as
url,type,key, andstatuswhen you prefix them with a table alias, for examplepr."url" - Order: if you don’t add
ORDER BY, results are sorted by the first timestamp column, newest first
Limits
Row limits are applied as a
LIMIT, so a higher LIMIT in your SQL is lowered to the cap. If a query runs too long or scans too much data, narrow the date range or add filters.
Data freshness
When you save a widget, Weave runs the query and stores the result. Saved widgets refresh about every hour as new data syncs, and the dashboard shows the stored result between refreshes. A newly saved widget may briefly show “Widget data is still being prepared. It will appear on the next refresh.”Privacy
Your question is sent to Weave’s AI model provider to generate the SQL. If your organization has opted out of prompt retention, the question text isn’t stored with the saved widget.Troubleshooting
A dashboard filter doesn't change my widget
A dashboard filter doesn't change my widget
The query’s results don’t include a column that filter can match. Edit the query and add the column, for example
author_account_id for the user filter or repository_id for the repository filter. See Dashboard filters and granularity.IDs show instead of names
IDs show instead of names
The ID column was renamed with
AS. Keep the original column name, such as author_account_id or team_id, and set the widget title or unit instead."Query timed out" or "Query scanned too much data"
"Query timed out" or "Query scanned too much data"
The query hit the 10-second or 1 GB limit. Narrow the dashboard’s date range, add filters, or select fewer columns.
"function is not allowed" or "column is not available"
"function is not allowed" or "column is not available"
The function isn’t on the allowed list, or the column is blocked for privacy. See SQL rules and Names and privacy.
The chart shows "Unable to build chart"
The chart shows "Unable to build chart"
The results don’t fit the selected chart type. For example, bar and line charts need a category or time column plus a numeric column, and scatter charts need x and y columns. Switch to Table to inspect the results, or regenerate the query.
