SQL Queries
The SQL panel runs a SQL query on the open CSV, TSV, or NDJSON file. Use it for what Table view cannot do, such as grouping and counting, combining conditions with OR, or sorting a filtered set of rows. Vaste runs the queries with DuckDB, so the queries use DuckDB’s SQL.
Open the SQL panel
Section titled “Open the SQL panel”The SQL panel works in Table view and NDJSON view. Open it in one of these ways:
- Select SQL in the toolbar.
- Select More actions (
…) → SQL query. - Press
Ctrl + Q.
In Text view and Hex view, the SQL button does not appear and More actions (…) → SQL query is dimmed with the message Available in Table view and NDJSON view.
The panel takes the place of the table. Select SQL again to return to the table. The query stays in the panel until you clear it, switch to Text view or Hex view, or close the file.
Run a query
Section titled “Run a query”The file is the table data. For example, to count the rows for each status in a CSV file with a status column:
SELECT status, COUNT(*) AS nFROM dataGROUP BY statusORDER BY n DESCType the query, then press Ctrl + Enter or select Run. For CSV and TSV files, the editor suggests column names as you type.
Write one SELECT query, without a ; at the end: a trailing ; makes the query fail with Parser Error. Each query can use up to 2 GB of memory.
If a query fails, the panel shows DuckDB’s error message in red above the results.
Read the results
Section titled “Read the results”The panel shows the result below the editor, with the number of rows and the time the query took, for example 250 rows in 412ms. Empty values are blank. Hover over a cell to see a long value in full.
The panel shows at most 10,000 rows. A longer result shows 10,000 rows (truncated): add a LIMIT, or export the result to get every row.
Dates, times, and decimal numbers show as raw text such as Date32(19723). To show them as readable text, cast them in the query, for example CAST(order_date AS VARCHAR).
Export the result
Section titled “Export the result”To save the full result, without the 10,000-row limit:
-
Select Export, then CSV, TSV, or Parquet.
-
Choose where to save the file.
While Vaste writes the file, the panel shows Exporting: N / M. CSV and TSV exports include a header line. The panel shows no message when the export finishes. If it fails, it shows Export failed: followed by the reason.
Clear and cancel
Section titled “Clear and cancel”Clear empties the editor and the results. If a query or an export is running, Clear also stops it. The panel has no separate cancel button.
What a query reads
Section titled “What a query reads”A query reads the file on disk each time you run it:
- CSV and TSV files are read with the current CSV dialect: its delimiter, quote, and header row.
- NDJSON files are read with every key in the records, not only the columns you chose in the Schema panel.
A query does not see the table’s filters, sort, hidden columns, or renamed columns. Use the column names from the file in your queries.
What a query can access
Section titled “What a query can access”A query can read the open file and nothing else. Reading another file or a URL, writing a file with COPY ... TO, listing a folder with glob, loading an extension, attaching a database, or changing a setting with SET fails with a message such as Permission Error: Cannot access file or SQL statement contains blocked keyword. Export is the one exception: it writes to the file you choose in the save dialog.
Next steps
Section titled “Next steps”- Exploring a large CSV file: use filters, statistics, and SQL together
- DuckDB SQL introduction: the SQL that the panel accepts