Query editor and execution workflow
The Vue query experience lets an engineer choose a data source, shape data through a visual sequence or write native SQL or Python, run the query, and inspect the result in a shared table view. It keeps the query definition, the current result, and the execution state together so that edits can drive new results without losing the context of the query. See the parent page, Data exploration and query building, for the wider analytical flow. See Query utilities for the server-side query support.
Query interface
The query interface selects one of three editing modes after the query document loads. The presence of a source operation also keeps the visual builder visible, which preserves the normal builder view for queries that already have a source. frontend/…/Query.vue.
Visual builder
The visual builder presents the current data as a table and the query steps as an operation list. It is the main path for users who want to build a query by selecting sources and applying guided operations rather than writing code. frontend/…/QueryBuilder.vue.
References: frontend/…/Query.vue• L18-41 frontend/…/QueryBuilder.vue• L13-45
Native SQL editor
The native editor pairs a SQL code area with a data-source selector, schema help, execution controls, and the same result table used by the builder. It formats SQL through the query service and replaces the query operation list with one SQL operation when the user runs the editor. frontend/…/NativeQueryEditor.vue.
References: frontend/…/NativeQueryEditor.vue• L18-40 frontend/…/NativeQueryEditor.vue• L43-61 frontend/…/query.ts• L720-734
Script editor
The script editor runs Python-based query code and shows its result in the shared table. It saves code changes after a short pause, while explicit Run and Force Run actions control execution. The editor also exposes saved variables and live script logs for work that needs inputs or runtime feedback. frontend/…/ScriptQueryEditor.vue.
References: frontend/…/ScriptQueryEditor.vue• L14-46 frontend/…/ScriptQueryEditor.vue• L50-142 frontend/…/query.ts• L736-769
Visual operation pipeline
The visual builder treats a query as an ordered pipeline of operations. Each step changes the shape or meaning of the data produced by the prior step, and the active step marks how far the client should evaluate the pipeline for the current view. frontend/…/query.ts.
The operation list gives each step a short description. A user can select a step to inspect the result at that point, open it for editing, add a new step after it, or remove it. The query state keeps the full ordered list while the result reflects the active portion. frontend/…/QueryOperations.vue.
This diagram shows how a source becomes an ordered query and then becomes a result table.
flowchart LR
A[Table or saved query] --> B[Source operation]
B --> C[Filters and joins]
C --> D[Column and calculation operations]
D --> E[Summary, pivot, sort, or limit]
E --> F[Execution request]
F --> G[Columns and rows]
G --> H[Result table]
Source selection
The pipeline starts with a table or another saved query. Changing an existing source is treated as a major change because the current operation steps may no longer apply; the client asks for confirmation and then resets the pipeline to the new source. frontend/…/QueryBuilderSourceSelector.vue and frontend/…/query.ts.
References: frontend/…/QueryBuilderSourceSelector.vue• L11-37 frontend/…/query.ts• L334-364
Data shaping operations
The builder supports a small set of related operation groups:
- Row and table combination: filters restrict rows; joins combine a second table or query; unions append another table or query.
- Column shape: select and remove control visible columns; rename changes labels; cast changes a column type.
- Derived values: calculate adds a column from an expression; custom operations apply a Python expression.
- Analysis shape: summarize groups dimensions and calculates measures; pivot spreads values into columns.
- Ordering and size: sort changes row order; limit caps the number of rows.
The operation menu maps each user action to one pipeline step. Editing an existing step replaces that step instead of adding a second copy. frontend/…/AddOperationPopover.vue and frontend/…/query.ts.
References: frontend/…/AddOperationPopover.vue• L30-85 frontend/…/QueryOperations.vue• L269-335 frontend/…/query.types.ts• L90-190 frontend/…/query.ts• L366-465
Filter groups
A filter group combines column rules and optional expressions with one logical operator: And or Or. The filter editor checks that each selected column and value is valid before it applies the group. Column actions on the result table create a new And group for a quick filter. frontend/…/FiltersSelector.vue and frontend/…/QueryBuilderTable.vue.
References: frontend/…/FiltersSelector.vue• L24-57 frontend/…/FiltersSelector.vue• L61-149 frontend/…/QueryBuilderTable.vue• L44-59
Join definitions
The join flow combines the current result with a table or saved query. It supports inner, left, right, and full joins. A join can match two selected columns or use a custom expression, and it must state which columns from the added source should enter the result. The client can suggest matching columns when source metadata provides a link. frontend/…/JoinSelectorDialog.vue.
References: frontend/…/JoinSelectorDialog.vue• L31-43 frontend/…/JoinSelectorDialog.vue• L119-149 frontend/…/JoinSelectorDialog.vue• L188-228
Execution lifecycle
Execution turns the current operation state into a server request and stores the returned SQL, columns, rows, timing, and paging information in the query result. The client avoids repeating an unchanged request, marks older requests as stale when a newer run starts, and reports whether the server is busy. frontend/…/query.ts.
Execution queue
The client queue limits the number of query calls that run at the same time in the browser. Waiting work can have a priority so that layouts can favor queries near the top of a view. A busy-server response releases its slot and retries with a delayed, varied backoff. A newer execution can make an older one stale, so the old response does not overwrite the current result. frontend/…/execution_queue.ts and frontend/…/query.ts.
References: frontend/…/execution_queue.ts• L6-16 frontend/…/execution_queue.ts• L20-42 frontend/…/execution_queue.ts• L54-83 frontend/…/query.ts• L157-220
Automatic and explicit runs
The visual builder enables automatic execution when its operation state changes. The SQL and script editors disable that behavior so that the user can control when code runs. The shared toolbar provides Execute and View SQL actions, while the code editors add format, Run, and Force Run actions where needed. frontend/…/QueryBuilder.vue, frontend/…/QueryToolbar.vue, and frontend/…/query.ts.
References: frontend/…/QueryBuilder.vue• L13-20 frontend/…/QueryToolbar.vue• L59-85 frontend/…/query.ts• L1113-1118
Execution status
The status display appears after a successful result has SQL and reports either the elapsed time or a cache hit. It also shows when the result was last executed. During a run the result table uses a loading state; during a remote filter it uses a separate filtering state so the user can distinguish a new query from a table-level filter update. frontend/…/QueryExecutionStatus.vue and frontend/…/QueryDataTable.vue.
References: frontend/…/QueryExecutionStatus.vue• L10-25 frontend/…/QueryDataTable.vue• L32-48 frontend/…/QueryDataTable.vue• L169-189
Result-table workflow
The result table is the common output surface for the builder, SQL editor, and script editor. It receives typed columns and formatted rows from the query state, then adds paging and user actions without changing the basic result contract. frontend/…/QueryDataTable.vue and frontend/…/DataTable.vue.
Result presentation
The query state keeps raw rows for actions and formatted rows for display. It formats grouped dates and removes HTML markup from text before the table renders. Numeric values receive number formatting, while URL values become links. The table also supports sticky columns, column widths, and optional cell formatting supplied by its caller. frontend/…/helpers.ts and frontend/…/DataTable.vue.
References: frontend/…/query.ts• L221-249 frontend/…/helpers.ts• L111-152 frontend/…/DataTable.vue• L527-536 frontend/…/DataTable.vue• L705-739
Paging and table filters
The default result page contains up to 100 rows. The table can request a total count and move between pages through the query state. If the full result fits on one page, text and numeric filters run in memory for an immediate response. Otherwise, the table converts all active column filters into one And filter group and requests page one again. frontend/…/QueryDataTable.vue and frontend/…/DataTable.vue.
References: frontend/…/query.ts• L157-169 frontend/…/query.ts• L268-298 frontend/…/QueryDataTable.vue• L40-48 frontend/…/QueryDataTable.vue• L126-166 frontend/…/DataTable.vue• L162-187
Result actions
The builder table lets users sort, rename, remove, and change the type of columns. It can add a calculated column, export the current query result as CSV or Excel when download access is available, and open a drill-down for summarized numeric cells. Drill-down builds a new short-lived query with filters derived from the selected row and cell. frontend/…/QueryBuilderTable.vue, frontend/…/QueryDataTable.vue, and frontend/…/query.ts.
References: frontend/…/QueryBuilderTable.vue• L79-155 frontend/…/QueryDataTable.vue• L50-124 frontend/…/query.ts• L584-663 frontend/…/query.ts• L773-823
Alerts and exports
The result footer can open query alerts and an export dialog. Alerts let users review existing conditions or start a new one, while export runs a separate download request and closes its dialog when the download finishes. These actions are attached to the result table rather than to one editor mode. frontend/…/QueryDataTable.vue and frontend/…/QueryAlertsDialog.vue.
References: frontend/…/QueryDataTable.vue• L96-124 frontend/…/QueryDataTable.vue• L198-245 frontend/…/QueryAlertsDialog.vue• L19-88 frontend/…/query.ts• L584-659
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the editor-mode flags and the operation types aligned. A mode change can alter which editor renders and whether the query uses one SQL or code operation.
- Keep result columns, raw rows, formatted rows, and total row count aligned. The table uses each for a different purpose.
- Preserve the active-operation boundary when adding, removing, or editing builder steps. It controls both preview results and metadata lookups.
- Keep busy-server handling and stale-result checks together. A retry or late response must not replace a newer result.
- Keep table filter behavior aligned with paging. Single-page filters are local; larger results must produce the query’s ad hoc filter contract.
- Keep join source selection, join condition, and selected columns as one valid unit. A partial join cannot be applied.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| No source is selected in the SQL editor | The run does not start and the user sees an error message | Require a data source before calling setSQL |
| A new run starts before an older run returns | The older response could show data for an obsolete query state | Execution tokens discard stale responses |
| The server rejects a request as busy | The query appears to fail unless it waits for a later slot | The execution queue retries recognized 503 ServiceUnavailableError responses with backoff |
| A source is changed after operations exist | Existing steps may no longer describe the new data | Confirmation clears the operation list before setting the new source |
| A filter group has an unknown column or invalid value | The filter cannot be applied | The filter editor disables Apply Filters until every rule is valid |
| A join lacks a source, condition, or selected columns | The join dialog cannot confirm the operation | Join validation requires all three parts |
| A result has no rows or columns | The table shows its empty state and row actions have no usable data | Result rendering checks for loaded columns or rows before display |
Key files
| File | Why to read it |
|---|---|
| frontend/…/Query.vue | Shows how the client selects the visual, SQL, or script editor. |
| frontend/…/query.ts | Defines shared query state, operation changes, execution, result state, paging, export, and drill-down behavior. |
| frontend/…/QueryBuilder.vue | Shows the visual builder layout and automatic execution choice. |
| frontend/…/AddOperationPopover.vue | Shows the user-facing operation set and how dialogs map to operation types. |
| frontend/…/QueryOperations.vue | Shows how the ordered pipeline is displayed, selected, edited, and removed. |
| frontend/…/NativeQueryEditor.vue | Shows the SQL editing, schema assistance, formatting, and result flow. |
| frontend/…/ScriptQueryEditor.vue | Shows script execution, variables, logs, and result flow. |
| frontend/…/execution_queue.ts | Defines concurrency, priority, busy-server retry, and stale execution handling. |
| frontend/…/QueryDataTable.vue | Connects query results to filters, paging, sorting, exports, alerts, and drill-down. |
| frontend/…/DataTable.vue | Defines the shared result-table presentation and local filter behavior. |
| frontend/…/query.types.ts | Defines the high-level operation and result shapes used by the client. |