Exploring Data with SQL
The SQL Viewer is a browser-based data exploration tool that lets you write and run SQL queries against your model’s data. It runs DuckDB entirely in the browser via WebAssembly, so there are no server-side queries — everything executes locally.
How to access the SQL Viewer
You can open the SQL Viewer from two places in pdView:
-
From the forecast dashboard — in the options sidebar, hover over a run datetime and click the Explore run data icon (a folder with a magnifying glass). This opens the SQL Viewer with that run’s DuckDB database file pre-loaded, containing all input and output data for that specific run.
-
From the performance metrics page — click the Explore link to open the SQL Viewer with the metrics DuckDB data, which contains historical forecast output stored as hive-partitioned Parquet files.
Interface layout
The SQL Viewer has three main areas:
-
Left sidebar — a schema tree showing all tables and their columns. Click a table name to expand it and see its columns. The sidebar is resizable by dragging its right edge.
-
Editor — a Monaco code editor (the same editor used in VS Code) with SQL syntax highlighting. It includes autocomplete that suggests table names after
FROMorJOINkeywords, and column names afterSELECTor when you type a table name followed by a dot. -
Results viewer — an interactive Perspective data grid that displays query results below the editor. A green progress bar between the editor and results indicates when a query is running.
Writing and running queries
Write your SQL in the editor using DuckDB SQL syntax. DuckDB supports standard SQL along with its own extensions for working with Parquet, CSV, and JSON files.
To run a query:
- Write your SQL in the editor. The default query is
SELECT * FROM output. - Click the play button in the bottom-right corner of the editor. Alternatively, select a portion of text to run only that selection.
- Results appear in the Perspective viewer below.
If your query has an error, the error message is displayed in the results area.
Viewing results
Query results render in an interactive Perspective data grid that supports several features:
- Sorting — click column headers to sort.
- Filtering — use the Perspective toolbar to add filters to columns.
- Pivoting and aggregation — open the Perspective settings panel to group, split, and aggregate your data.
- Visualisations — switch between the default datagrid view and D3FC chart visualisations using the Perspective view selector.
Available data
The data available in the SQL Viewer depends on how you accessed it:
-
Model run data — when opened from a run datetime in the forecast dashboard, the database contains input data tables and an
outputtable for that specific run datetime. Each input corresponds to a table named after its input key. -
Performance metrics data — when opened from the metrics page, the database contains historical forecast output as hive-partitioned Parquet files, organised by model, run date, and extract date.
Tips
-
The editor height and sidebar width are resizable. Drag the divider between the editor and results to adjust the editor height. Your preferred sizes are saved across sessions.
-
DuckDB can read Parquet, CSV, and JSON files natively. If you have additional data sources accessible via URL, you can query them directly, for example:
SELECT * FROM 'https://example.com/data.parquet'. -
Use
DESCRIBE tablenameorSHOW TABLESto quickly inspect the available schema without checking the sidebar.
Next steps
To learn about monitoring model runs and debugging failures, see Publisher Tools. For an overview of all platform features, see the Platform Overview.