# Query a Parquet file with SQL

> Run DuckDB SQL on Parquet files directly in your browser using the app's SQL console.

Page: https://structure.fi/tools/market-data-visualizer/guides/query-parquet-with-sql/

Open in the Market Data Visualizer: https://structure.fi/tools/market-data-visualizer/app/#open?article=query-parquet-with-sql

The Market Data Visualizer includes an in-browser SQL console backed by DuckDB-WASM. Queries run locally in your browser; files are never sent to a server. The engine requires WebAssembly exception handling (supported in current Chrome, Firefox, and Safari); if absent, the console reports the missing feature while all other views keep working.

## 1. Open the trades sample

Open the bundled trades sample in the data view.

[Open the trades sample's rows](https://structure.fi/tools/market-data-visualizer/app/#open?sample=trades&place=data&guide=query-parquet-with-sql&section=block-3)

## 2. Open the SQL console

Click **Query this file** in the pane bar to open a file-scoped console pre-filled with:

`SELECT * FROM read_parquet('trades.zstd.parquet') LIMIT 100`

On first open, the browser downloads the DuckDB-WASM engine and shows `SQL engine ready (DuckDB …)` with its version once loaded. To query or join multiple Parquet files in a project, click the **SQL** icon in the left activity bar and press **Open console** (or double-click the project); double-clicking a single table opens a file-scoped console.

Two shortcuts save typing:

- **Views by file name:** every Parquet file is registered as a view named after its file without folders or extensions, so `SELECT * FROM trades` is equivalent to `SELECT * FROM read_parquet('trades.zstd.parquet')`.
- **Schema sidebar and autocomplete:** click a column or file in the **Schema** sidebar to insert it. As you type, autocomplete suggests columns, SQL keywords, DuckDB functions, file paths inside `read_parquet('`, and aliased columns after `t.`. Press `Escape` to dismiss suggestions.

Values match the Data view digit for digit, including over-wide decimals like `notional` (9-byte `DECIMAL(18,4)`, whose first row is `14294250.0000` in both views).

## 3. Run a query

Replace the statement with the query below and press **Run** (`Ctrl+Enter`, or `Cmd+Enter` on macOS):

`SELECT count(*) FROM read_parquet('trades.zstd.parquet')`

This returns one `BIGINT` row (`count_star()`) equal to 2,317, matching the footer row count. The bar above the table reports row count and elapsed time, and each column header shows its DuckDB type.

## 4. Aggregate with exact decimals and nanosecond timestamps

Run a per-symbol summary:

`SELECT symbol, count(*) AS trades, sum(size) AS volume, min(price) AS low, max(price) AS high FROM read_parquet('trades.zstd.parquet') GROUP BY symbol ORDER BY symbol`

- `trades` is `BIGINT`; `volume` is DuckDB's 128-bit `HUGEINT`, displayed as `DECIMAL(38,0)`.
- `low` and `high` preserve `price`'s exact `DECIMAL(18,9)` type (never converted to float), with missing values shown as `NULL` ([decimals in Parquet](https://structure.fi/guides/prices-and-times-as-integers/#decimals-in-parquet)).

Timestamps also keep full precision. Run:

`SELECT ts_recv, symbol, price FROM read_parquet('trades.zstd.parquet') ORDER BY ts_recv LIMIT 5`

`ts_recv` arrives as `TIMESTAMPTZ_NS`, keeping all nine fractional digits and trailing `Z` (for example `2026-12-04T13:28:29.243430949Z`; see [timestamps as integers](https://structure.fi/guides/prices-and-times-as-integers/#a-note-on-timestamps-the-same-integer-idea)).

## Limits and DuckDB quirks to watch for

- **Row display cap:** the grid renders at most the first 1,000 rows (and says when truncated), while aggregates like `count(*)` still scan every row.
- **File console isolation:** a file-scoped console rejects queries referencing other files; use the project console to join files.
- **Errors and recovery:** invalid SQL shows DuckDB's error (such as `Binder Error: Referenced column "missing" not found`). If a statement crashes the engine, the console restarts a fresh engine automatically for the next query. Statements stay preserved while the app remains open.
- **Min/max nanosecond timestamps:** DuckDB maps the extreme nanosecond values to `infinity` / `-infinity`, displayed as `2262-04-11T23:47:16.854775807Z` and `1677-09-21T00:12:43.145224193Z`. Compare against `'infinity'` / `'-infinity'` in SQL (`epoch_ns()` returns `NULL` for them).
- **Time zone bug on `TIMESTAMPTZ_NS`:** passing `ts_recv AT TIME ZONE 'America/Chicago'` to `strftime()` or `hour()` crashes DuckDB with `memory access out of bounds`. Instead run `SET TimeZone = 'America/Chicago'` first, then call `strftime(ts_recv, '%Y-%m-%d %H:%M:%S.%n')` to keep all nine nanosecond digits.
- **Extracting parts from `TIMESTAMPTZ_NS`:** `hour()`, `date_part()`, and `extract()` fail with `Binder Error: No function matches`. Use `strftime(ts_recv, '%H')::INTEGER`, or cast to microseconds first (`hour(ts_recv::TIMESTAMPTZ)`), which rounds to microseconds.

For inspecting the underlying file structure and statistics, see [inspect a Parquet file in the browser](https://structure.fi/tools/market-data-visualizer/guides/inspect-parquet-file.md).

## Sources

- https://duckdb.org/docs/stable/data/parquet/overview
- https://duckdb.org/docs/stable/clients/wasm/overview
- https://github.com/duckdb/duckdb-wasm
- https://webassembly.org/features/
- https://parquet.apache.org/docs/file-format/

Reviewed by Structure on 2026-11-11. Last changed 2026-11-26.
