Skip to main content

How to Read a Parquet File with SQL

A Parquet file is binary and columnar, and it stores its own schema and per-column statistics, so a text editor shows nothing useful: you read it with a program that understands the format. With SereneDB that program is a single SELECT from psql or any Postgres driver. SereneDB reads the file where it is, on local disk, in S3 or over HTTPS, without an import step.

Tested with SereneDB 26.11.2 on 2026-11-20.

Read a Parquet file in one query​

SereneDB reads a Parquet file when you put its path in the FROM clause. The steps below start a server, create a small file, and read it back.

Start SereneDB with your files mounted​

SereneDB reads files on the server side, so a path in your SQL is a path inside the container. Mount the folder that holds your Parquet files and connect with psql:

bash
mkdir -p data && chmod a+rwx data

docker run -d --name serenedb -p 7890:7890 \
-e SERENEDB_HOST_AUTH_METHOD=trust \
-v "$PWD/data":/data \
serenedb/serenedb

psql -h localhost -p 7890 -U postgres

A file at ./data/events.parquet on your machine is then /data/events.parquet in SQL. Inside the container SereneDB runs as an unprivileged user: it needs read access to your files, and write access to the folder only for the examples below that write files with COPY … TO. To read only, skip the chmod and mount the folder with :ro. See Docker and psql for the other options.

Make a sample file​

The examples on this page read a small file of support tickets. To follow along without a file of your own, have SereneDB write it into the mounted folder:

SQL
COPY (    SELECT * FROM (VALUES        (1, DATE '2026-03-02', 'search',  'high',   'Search results are empty after the index rebuild'),        (2, DATE '2026-03-02', 'billing', 'low',    'Invoice PDF shows the wrong company address'),        (3, DATE '2026-03-03', 'search',  'medium', 'Slow search when the query has many words'),        (4, DATE '2026-03-04', 'api',     'high',   'Export endpoint times out on large result sets'),        (5, DATE '2026-03-05', 'search',  'low',    'Typo on the search settings page')    ) AS t(id, opened_on, product, priority, body)) TO '/data/tickets.parquet' (FORMAT parquet);

COPY … (FORMAT parquet) is how SereneDB writes Parquet; Parquet Export covers its options.

Read the rows​

A path that ends in .parquet can stand in for a table name:

SQL
SELECT * FROM '/data/tickets.parquet';
 id | opened_on  | product | priority | body
----+------------+---------+----------+--------------------------------------------------
  1 | 2026-03-02 | search  | high     | Search results are empty after the index rebuild
  2 | 2026-03-02 | billing | low      | Invoice PDF shows the wrong company address
  3 | 2026-03-03 | search  | medium   | Slow search when the query has many words
  4 | 2026-03-04 | api     | high     | Export endpoint times out on large result sets
  5 | 2026-03-05 | search  | low      | Typo on the search settings page

The read_parquet function does the same and also reads files with any other extension. Filters, ordering and joins work as they do on a table:

SQL
SELECT id, priority, bodyFROM read_parquet('/data/tickets.parquet')WHERE product = 'search'ORDER BY id;
 id | priority | body
----+----------+--------------------------------------------------
  1 | high     | Search results are empty after the index rebuild
  3 | medium   | Slow search when the query has many words
  5 | low      | Typo on the search settings page

Look inside the file: columns, types, row groups and statistics​

SereneDB shows a Parquet file's schema with DESCRIBE, a per-column profile with SUMMARIZE, and the file's internal layout with parquet_metadata. Together they answer what a Parquet viewer would show you.

Column names and types:

SQL
DESCRIBE SELECT * FROM '/data/tickets.parquet';
 column_name | column_type | null | key  | default | extra
-------------+-------------+------+------+---------+-------
 id          | INTEGER     | YES  | NULL | NULL    | NULL
 opened_on   | DATE        | YES  | NULL | NULL    | NULL
 product     | VARCHAR     | YES  | NULL | NULL    | NULL
 priority    | VARCHAR     | YES  | NULL | NULL    | NULL
 body        | VARCHAR     | YES  | NULL | NULL    | NULL

Minimum, maximum and the share of NULLs for every column (SUMMARIZE also reports averages, quantiles and distinct counts):

SQL
SELECT column_name, min, max, null_percentageFROM (SUMMARIZE SELECT * FROM '/data/tickets.parquet');
 column_name | min                                            | max                              | null_percentage
-------------+------------------------------------------------+----------------------------------+-----------------
 id          | 1                                              | 5                                |            0.00
 opened_on   | 2026-03-02                                     | 2026-03-05                       |            0.00
 product     | api                                            | search                           |            0.00
 priority    | high                                           | medium                           |            0.00
 body        | Export endpoint times out on large result sets | Typo on the search settings page |            0.00

Row groups, physical types, compression and the min/max statistics stored in the file:

SQL
SELECT row_group_id, path_in_schema, type, compression, stats_min, stats_maxFROM parquet_metadata('/data/tickets.parquet')ORDER BY row_group_id, column_id;
 row_group_id | path_in_schema | type       | compression | stats_min                                      | stats_max
--------------+----------------+------------+-------------+------------------------------------------------+----------------------------------
            0 | id             | INT32      | SNAPPY      | 1                                              | 5
            0 | opened_on      | INT32      | SNAPPY      | 2026-03-02                                     | 2026-03-05
            0 | product        | BYTE_ARRAY | SNAPPY      | api                                            | search
            0 | priority       | BYTE_ARRAY | SNAPPY      | high                                           | medium
            0 | body           | BYTE_ARRAY | SNAPPY      | Export endpoint times out on large result sets | Typo on the search settings page

Those statistics are why a filtered query on a large Parquet file can be fast. SereneDB reads only the columns a query uses, and it can skip row groups whose min/max range cannot match the filter (Partial Reading). Parquet Metadata lists every metadata function.

Read many Parquet files as one table​

read_parquet accepts a glob pattern or a list of paths and returns their rows as one result. To try it, split the sample file into one folder per product:

SQL
COPY (SELECT * FROM '/data/tickets.parquet')TO '/data/by_product' (FORMAT parquet, PARTITION_BY (product));

A glob reads every file in the tree. With hive_partitioning = true, the product=… folder names become a product column:

SQL
SELECT product, count(*) AS ticketsFROM read_parquet('/data/by_product/*/*.parquet', hive_partitioning = true)GROUP BY productORDER BY product;
 product | tickets
---------+---------
 api     |       1
 billing |       1
 search  |       3

filename = true adds the path each row came from:

SQL
SELECT filename, count(*) AS ticketsFROM read_parquet('/data/by_product/*/*.parquet', filename = true)GROUP BY filenameORDER BY filename;
 filename                                        | tickets
-------------------------------------------------+---------
 /data/by_product/product=api/data_0.parquet     |       1
 /data/by_product/product=billing/data_0.parquet |       1
 /data/by_product/product=search/data_0.parquet  |       3

When files have different columns, union_by_name = true lines them up by name and fills the missing ones with NULL. Here a second file has a team column and no priority:

SQL
COPY (    SELECT 6 AS id, DATE '2026-03-06' AS opened_on, 'api' AS product,           'Webhook retries never stop' AS body, 'support' AS team) TO '/data/tickets_extra.parquet' (FORMAT parquet);
SELECT id, product, priority, teamFROM read_parquet(['/data/tickets.parquet', '/data/tickets_extra.parquet'], union_by_name = true)ORDER BY id;
 id | product | priority | team
----+---------+----------+---------
  1 | search  | high     | NULL
  2 | billing | low      | NULL
  3 | search  | medium   | NULL
  4 | api     | high     | NULL
  5 | search  | low      | NULL
  6 | api     | NULL     | support

The options most often used together with a glob:

OptionWhat it does
filenameAdds a column with the path of the file each row came from.
hive_partitioningTurns key=value folder names into columns. It is detected automatically when the paths follow that layout.
union_by_nameMatches columns across files by name instead of by position.
schemaSets column names and types explicitly instead of reading them from the files.

The Parquet reference lists all parameters, and Multiple Files and Hive Partitioning cover globs and partitions in depth.

Read Parquet from S3 or over HTTPS​

SereneDB reads s3:// and https:// paths with the same SQL as local files, including globs, filters and the metadata functions above.

For a private bucket, create a secret with your keys and region. SCOPE ties the secret to one bucket, so secrets for different buckets do not get in each other's way:

SQL
CREATE SECRET (    TYPE s3,    KEY_ID '⟨your-access-key-id⟩',    SECRET '⟨your-secret-access-key⟩',    REGION '⟨us-east-1⟩',    SCOPE 's3://⟨my-bucket⟩');

A public bucket needs only its region. This reads one file of Ookla's open data set on the AWS Registry of Open Data:

SQL
CREATE SECRET ookla (TYPE s3, REGION 'us-west-2', SCOPE 's3://ookla-open-data');
SELECT count(*)FROM read_parquet('s3://ookla-open-data/parquet/performance/type=fixed/year=2023/quarter=1/2023-01-01_performance_fixed_tiles.parquet');
 count
---------
 6336489

An HTTPS URL needs no setup. This shows the columns of a public data set on Hugging Face:

SQL
DESCRIBE SELECT *FROM 'https://huggingface.co/datasets/neuralwork/arxiver/resolve/main/data/train.parquet';
 column_name    | column_type | null | key  | default | extra
----------------+-------------+------+------+---------+-------
 id             | VARCHAR     | YES  | NULL | NULL    | NULL
 title          | VARCHAR     | YES  | NULL | NULL    | NULL
 abstract       | VARCHAR     | YES  | NULL | NULL    | NULL
 authors        | VARCHAR     | YES  | NULL | NULL    | NULL
 published_date | VARCHAR     | YES  | NULL | NULL    | NULL
 link           | VARCHAR     | YES  | NULL | NULL    | NULL
 markdown       | VARCHAR     | YES  | NULL | NULL    | NULL

See S3 Parquet Import, HTTP Parquet Import and AWS Credentials for endpoints, other S3-compatible stores and the ways to pass credentials.

Read it from Python or any Postgres client​

SereneDB speaks the PostgreSQL wire protocol, so any Postgres driver can read a Parquet file: send the same SQL you would type in psql. With psycopg:

python
import psycopg

with psycopg.connect("host=localhost port=7890 user=postgres") as conn:
rows = conn.execute(
"SELECT id, priority, body FROM read_parquet('/data/tickets.parquet') "
"WHERE product = %s ORDER BY id",
("search",),
).fetchall()

for row in rows:
print(row)
Text
(1, 'high', 'Search results are empty after the index rebuild')
(3, 'medium', 'Slow search when the query has many words')
(5, 'low', 'Typo on the search settings page')

Write the file path into the SQL text, as above, and pass values such as product as query parameters. The same query works from JDBC, Go, Node.js and BI tools such as DBeaver. If your code already reads Parquet with pandas or PyArrow, it keeps working on the same files.

Keep it in place or load it​

SereneDB can keep querying the file where it is, or copy its rows into a table. A view keeps the data in the file; a table stores a copy in SereneDB.

Query it as a view​

A view gives the file a name. The view stores only the query, so every query on it reads the file as it is at that moment:

SQL
CREATE VIEW tickets AS    SELECT * FROM read_parquet('/data/tickets.parquet');
SELECT priority, count(*) AS ticketsFROM ticketsGROUP BY priorityORDER BY priority;
 priority | tickets
----------+---------
 high     |       2
 low      |       2
 medium   |       1

Load it into a table​

CREATE TABLE … AS copies rows into a new table, and INSERT INTO … SELECT appends more:

SQL
CREATE TABLE urgent_tickets AS    SELECT * FROM '/data/tickets.parquet' WHERE priority = 'high';
INSERT INTO urgent_tickets    SELECT * FROM '/data/tickets.parquet' WHERE priority = 'medium';
SELECT count(*) FROM urgent_tickets;
 count
-------
     3

Parquet Import shows how to load into an existing table and adjust the schema on the way in. File Formats explains when loading pays off.

Convert it to CSV​

COPY … TO writes the result of any query to CSV. Spreadsheet tools such as Excel open the CSV file directly:

SQL
COPY (SELECT * FROM '/data/tickets.parquet')TO '/data/tickets.csv' (HEADER);

Search the text in a Parquet file with BM25​

SereneDB can build an inverted index over a view of Parquet files and rank matches with BM25, without loading the rows into a table. This uses the tickets view created above.

Define how text is split into terms:

SQL
CREATE TEXT SEARCH DICTIONARY english_dict AS    split_text(case := 'lower') | normalize_tokens('en_US.UTF-8', accent := false) | stem_words('en_US.UTF-8')    WITH (frequency, position, offset);

Index the view. body gets full-text processing with the dictionary; id and product are indexed as exact values:

SQL
CREATE INDEX tickets_idx ON tickets    USING inverted (id, product, body english_dict);

Query the index by name and order by relevance. Stemming lets "searches" match "search", and the ticket that also contains "slow" ranks first:

SQL
SELECT id, bodyFROM tickets_idxWHERE body @@ 'slow searches'ORDER BY BM25(tickets_idx.tableoid) DESC, id;
 id | body
----+--------------------------------------------------
  3 | Slow search when the query has many words
  1 | Search results are empty after the index rebuild
  5 | Typo on the search settings page

The index holds a snapshot of the files. After files are added, changed or removed behind the view, refresh it in one pass:

SQL
REINDEX INDEX tickets_idx;

Indexing External Data and the external data reference cover phrase queries, filters, automatic refresh and indexes over S3.

The same index can also hold an embedding column from the Parquet file, for nearest-neighbor and hybrid search next to BM25. Cast the column to a fixed-size array such as FLOAT[384] in the view, because Parquet stores it as a list; see Vector Search and Hybrid Search.

FAQ​

Is a Parquet file human-readable?​

No. Parquet stores data in binary, compressed column chunks with a footer that describes the schema and statistics. To look at the rows, read the file with a tool that understands the format, such as a SELECT in SereneDB, or convert it to CSV.

How do I open a Parquet file in Excel?​

Convert the file to CSV first, then open the CSV in Excel. In SereneDB that is one statement: COPY (SELECT * FROM 'file.parquet') TO 'file.csv' (HEADER), as shown in Convert it to CSV.

Can I convert a Parquet file to CSV?​

Yes. COPY (SELECT … FROM 'file.parquet') TO 'file.csv' (HEADER) writes any query result to CSV, so you can choose the columns and filter the rows during the conversion. CSV Export lists the CSV options.

Is Parquet faster to read than CSV?​

For queries that use some of the columns or filter on a column, usually yes. A Parquet reader fetches only the columns a query needs and can skip row groups by their min/max statistics, while a CSV file has to be parsed in full. File Formats has more detail.

Do I need Spark to read a Parquet file?​

No. A single SQL query in SereneDB reads a Parquet file on disk, in S3 or over HTTPS, from psql or any Postgres driver.