Skip to content
Queria Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Compare with your local data

JOIN your own CSV or Parquet files with Queria datasets using the Queria CLI or Python API

The Queria CLI and Python API run SQL on DuckDB, so DuckDB functions such as read_csv and read_parquet read your local files. You can JOIN your files with Queria datasets in one SQL statement.

Example: add prefecture population to an office list

Say you have an office list offices.csv on hand:

pref,office
東京都,本社
大阪府,西日本支社
福岡県,九州支社

JOIN it with e-Stat total population on the prefecture name. The CLI attaches the datasets your SQL names.

queria sql "
  SELECT o.office, e.area_name, e.value AS population
  FROM read_csv('offices.csv') o
  JOIN e_stat.ssds.a_pref_population e
    ON e.area_name = o.pref
  WHERE e.item_name = 'A1101_総人口' AND e.year = 2024
  ORDER BY population DESC
"

To save the result to a file, add --out.

queria sql "..." --out result.parquet

Read Parquet or JSON

Any file format DuckDB can read can be joined the same way.

queria sql "
  SELECT *
  FROM read_parquet('sales.parquet') s
  JOIN zipcode.main.mart_zipcode z ON z.zipcode = s.zipcode
"

From Python

The Python API takes the same SQL. Your pandas DataFrames can also be read from the SQL in con.sql by their variable names.

import queria

con = queria.connect()
df = con.sql("""
  SELECT o.office, e.value AS population
  FROM read_csv('offices.csv') o
  JOIN e_stat.ssds.a_pref_population e ON e.area_name = o.pref
  WHERE e.item_name = 'A1101_総人口' AND e.year = 2024
""").df()

Was this page helpful?