Skip to content

Libraries

A library gives a name to something you query often: a whole database, a catalog, a schema, a single table, a folder or a file on this computer, or a folder or object in a cloud connection. With the SQL panel's Libraries button on, every editor knows your libraries by that name, so a query can use them together with the open table and your other tabs:

SELECT o.id, o.amount, c.region
FROM sales.orders o
JOIN raw.customers c USING (customer_id)
WHERE o.placed >= '2026-01-01'

Here sales is a schema of a saved database connection and raw a folder of CSV files. Libraries work everywhere in a query: joins, UNIONs, subqueries and CTEs, like any table. The command line (octa --sql) and the MCP run_sql tool know them always (see The Libraries button).

Making a library

Press + New library... at the bottom of the SQL panel's workspace list, or open Settings > Libraries yourself:

  • Name is what a query writes. Letters, digits and underscores, not starting with a digit, and not a word SQL already uses. The form checks it as you type and greys Save with the reason.
  • Source is where it reads from:
    • Database connection: a saved database connection, and with Pick... the part of it: all of it, a catalog, a schema or one table. The picker lists a level only when you open it.
    • Folder or file: a folder, a data file, or a DuckDB or SQLite file on this computer. For a file that holds several tables (a workbook, a database file), Table in the file picks one; empty maps them all.
    • Cloud connection: a saved cloud connection and a folder (ending in /) or an object in it.
  • Subfolders says how a folder library reads the folders below it (see Subfolders). Greyed for a database, a file or a single cloud object, which have none.
  • Fetch all rows lifts the row limit for the tables this library has to copy (see below).
  • Write it as shows how a query names the tables.
  • Test connection reaches the source without fetching a row, and stays quick however big the source is. A database is only logged in to, with one SELECT 1. A cloud folder is asked for its first object and a cloud file whether it is there, one request each, so the test says Connection OK without counting tables. A folder or file on this computer also says how many tables it maps.

Quicker: right-click a connection, catalog, schema or table in the Databases sidebar, a folder or object in the Cloud sidebar, or a folder or file in the file tree, and pick Add as library.... The form opens with it filled in and its name suggested. A Delta, Iceberg or Lance folder starts at The folder is one table.

Change the order of libraries with the :: handle in front of each one: drag it up or down, or click the arrows to move it one place. The SQL panel's workspace list shows them in this order once you press Apply or Save.

How a query names the tables

The library maps A query writes
One table, one file, one cloud object orders
A schema, a folder, a cloud folder, a SQLite file, a MySQL database sales.orders
A database with schemas, a DuckDB file, a catalog shop.sales.orders
A folder read with Each file is a table raw.crm.contacts
A folder read with The folder is one table orders

A folder's tables are its readable files, named after the file without its extension. All names share one namespace: a library cannot be called data, and an open tab whose name a library has gets _2 in SQL.

Subfolders

A folder library, on this computer or in the cloud, reads the folders below it the way Subfolders says:

Subfolders Tables A query writes
Left out (the default) The files directly in the folder. raw.customers
Each file is a table Every file at any depth. Its folder is the middle part of the name, deeper folders joined with _. Files at the top keep the short form. raw.crm.contacts, raw.finance_2026.invoices
Each folder is a table Each folder directly below is one table of all the files under it. Folder names such as year=2026 become columns. Files at the top stay tables of their own. lake.orders
Files of one name are a table Files with the same name, at any depth and in any format Octa reads, are one table. A folder column says which folder a row came from (folder_2 when the data has a folder). exports.orders
The folder is one table The whole folder: a Delta, Iceberg or Lance table, or all the part files below it, folder names such as year=2026 as columns. orders

Examples, for the three kinds of folder these are made for:

lake/                                 Each folder is a table
  orders/year=2026/month=11/p-1.parquet   lake.orders (+ year, month)
  customers/part-0.parquet                lake.customers

exports/                              Files of one name are a table
  2026-11-01/orders.csv                   exports.orders (+ folder)
  2026-11-02/orders.csv
  2026-11-02/refunds.csv                  exports.refunds

raw/                                  Each file is a table
  customers.csv                           raw.customers
  crm/contacts.csv                        raw.crm.contacts
  finance/2026/invoices.xlsx              raw.finance_2026.invoices
  • Columns are matched by name, so files whose columns differ a little still make one table; a column one file lacks is empty in its rows.
  • A file packed with gzip or zstd (orders.csv.gz, events.jsonl.zst) is read like its unpacked twin and named orders, on this computer and in the cloud, in a folder or as a library of its own. DuckDB reads packed CSV and JSON itself; any other packed format is unpacked first.
  • Each folder is a table and The folder is one table read Parquet, CSV and JSON Lines files. Any other file there (_SUCCESS, README.md, a workbook) is left out, and the status line says how many.
  • A folder and a file of one name side by side (orders/ and orders.csv) become orders and orders_2. So do two files of one name in one folder (orders.csv, orders.parquet), except with Files of one name are a table, which puts them together. A subfolder called main is written main_2 with Each file is a table, since main holds the files at the top.
  • In the cloud, every file of a table is downloaded the first time a query names it, and kept while the object is unchanged. Each query lists the folder again, so new files are seen. Opening the library in the workspace list lists it too.
  • A cloud folder read with any choice but Left out is listed object by object, at any depth. A public bucket can hold millions of objects (NOAA's noaa-ghcn-pds does), so the listing stops at Objects listed in a cloud folder at most (Settings > SQL > Libraries, 100,000 by default, or Unlimited) and the query and the workspace list say the folder holds more. Point the library at a folder further down (csv/by_year/ rather than the whole bucket), or raise the limit. In a test, 100,000 objects took about 25 seconds to list.

Delta, Iceberg and Lance tables

A Delta, Iceberg or Lance table is a folder of files plus a log that says which of them are the table right now: the others hold rows that were deleted or replaced. Octa reads such a folder as the table, never as its files:

  • A library whose folder is such a table is one table under the library's name, with The folder is one table. Any other choice is refused with the reason, so its files are never read on their own.
  • With Each folder is a table, such a folder below is one table (lake.orders). Each file is a table and Files of one name leave it out and say so when a query names it.

On this computer they read like the table folders Octa opens. In the cloud, DuckDB reads them with the saved connection's own credentials:

Format S3 and S3-compatible Azure Google Cloud SFTP, WebDAV
Delta yes yes with HMAC keys no
Iceberg yes yes with HMAC keys no
Lance yes no no no
  • Google Cloud needs an HMAC key pair on the connection (HMAC access ID and HMAC secret in its form), because DuckDB reaches it through its S3 interface. Without them a query says what to add.
  • The credentials go to DuckDB only for the time of the read, held in memory, and in a DuckDB session of Octa's own that runs nothing but Octa's read. Your query never runs where they are, so it cannot write to the bucket, whatever Allow writes says.
  • The table is fetched like a database table: only the columns and the conditions your query needs are read from the bucket, counting and grouping run in that session, and the copy is reused while the table's log has not changed. The Initial-load row cap applies, as to every fetched table.
  • The first such query downloads DuckDB's delta, iceberg or lance add-on, and httpfs, azure or aws for the storage, so it needs the network once (see Other programs Octa works with).

A name one or two letters off a library's (titanic typed, the library saved as titantic) finds no table, and the error starts with No library is called titanic. Did you mean titantic? The SQL panel, the command line and the MCP server all add that line.

A library of several tables named alone (FROM test for a workbook whose sheets are test.sheet1 and test.sheet2) says so in place of DuckDB's own error: test is a library, not a table. Name one of its tables, for example test.sheet1.

When a library connects

Octa's start, reopening the last session, opening the SQL panel and opening an editor reach nothing. A library is reached when a query that uses it runs (Run or Explain), when you press Test connection, or when you open it in the workspace list. Only the libraries a query names are reached, and only the tables it names are fetched.

Browsing a library

Open a library in the SQL panel's workspace list with its triangle. A database library lists its schemas, and a schema opens to its tables, the way the Databases sidebar does: both read the same listing, so anything already open there shows at once without connecting again. A cloud folder lists its files through the Cloud sidebar's listing, and a folder, DuckDB, SQLite or workbook file on this computer lists its tables from disk. A library of one table shows that table without connecting. Click a table to see its columns in the Inspector.

Each library also says whether a query used it yet. A library that could not be used, or a listing that failed, shows why (you can select and copy the text); the next try starts again. A connection that needs a browser sign-in shows Sign in: a query never opens the browser by itself.

The Libraries button

Library names work in a query only while Libraries, beside Run on, is switched on. Switching it on sets Run on to Local DuckDB, the one place library names reach; picking a server in Run on switches it off. It starts off in every new SQL tab. While it is off the libraries stay in the workspace list, greyed, and a query that names one is not run: the editor says which library it uses and how to switch the button on. Run or Insert in the Inspector on a library's table switches it on for you.

The command line (--sql) and MCP (run_sql) always use libraries: they run on local DuckDB anyway.

Two libraries, one source

Before a query uses two or more libraries that read from the same database connection, the same cloud connection, or folders where one holds the other, Run asks first. Each table is copied here and joined in Octa, while running the query on that server itself is usually faster. Run anyway runs it. Don't ask again turns the question off, and Settings > SQL > Libraries > Ask when libraries read from one source turns it back on.

Read live, or fetched

  • Read live, never copied: PostgreSQL, Redshift and MySQL connections, DuckDB and SQLite files, and Parquet, CSV and JSON files on this computer. A query always sees what is there now.
  • Fetched on first use: every other database engine (SQL Server, Oracle, ClickHouse, Exasol, Snowflake, Databricks, BigQuery, Trino, Athena), cloud objects, Delta, Iceberg and Lance tables, and local formats DuckDB cannot read (a workbook, a SAS file). A table is fetched the first time a query names it, so mapping a schema of a thousand tables costs nothing.

A fetch takes only what the query needs: the columns it mentions, and the conditions in its WHERE that concern that table alone go to the server, so only matching rows travel. A plain read of one table sends its LIMIT along too. Octa then runs your whole query again on what came back, so what it sent can only narrow the fetch, never change the answer. Text is sent only for =, IN and LIKE: a server that compares text without regard to case would answer < or <> differently. Dates are not sent.

A fetched table holds at most as many rows as the Initial-load row cap (Settings > Performance; Unlimited is honoured). When a table was cut, the tab says so, because a result built on it may be short. Fetch all rows on the library lifts the limit for it.

Counting and grouping run on the server

A SELECT that only counts and groups one fetched table runs on that table's own server, and only its result comes back: count, sum, avg, min and max of the table's columns, grouped by columns, with a WHERE Octa can send. It does not matter where that SELECT stands: the whole query, a part of a WITH, or a subquery. HAVING, ORDER BY, LIMIT, DISTINCT and window functions then run in Octa over the groups, so the answer is the one DuckDB would give. The server counts every row, so the Initial-load row cap does not apply, and when every SELECT that reads a table ran on its server, the table is not fetched at all.

Octa says which tables were grouped on their server: in the status bar, on standard error for --sql, and as grouped_on_server in the answer of the MCP tool run_sql. Explain shows the plan Octa runs over the servers' answers.

A SELECT stays in Octa, and its table is fetched as above, wherever a server could answer differently:

  • It sorts by text, or takes min or max of text, since every server sorts text its own way. A LIMIT goes to the server only after an order by numbers, dates or the counts themselves.
  • It groups, counts distinct values of or compares text on SQL Server, which ignores trailing spaces when it compares text.
  • It compares a fixed-width CHAR column, which some servers pad with spaces, or compares a date, since dates are not sent.
  • It calls any other function around the counts, uses FILTER, ROLLUP, GROUPING SETS or GROUP BY ALL, groups by something other than a column, or refers to the query around it.

When a server refuses the grouped query, Octa fetches the table instead. That is slower, never different.

Fetched tables are reused while they are current

A fetched table is kept as a Parquet file and reused by the next query only when it holds everything that query needs (a copy of two columns does not serve a SELECT *; a copy filtered by amount > 10 serves amount > 10 AND id < 5 but not id < 5 alone) and its source says it has not changed since. Snowflake, Databricks (Delta tables), BigQuery, ClickHouse (MergeTree tables), SQL Server and Exasol can tell; local files and cloud objects are checked by their modified time and size or ETag, and a Delta, Iceberg or Lance table by its log. Where a source cannot tell (Oracle, Trino, Athena), Keep a fetched table for minutes under Settings > SQL > Libraries decides, and it is 0 by default: fetch again for every query.

Refresh next to a fetched table in the workspace list drops its copy, so the next query fetches it again.

Where fetched tables are kept

In Folder for fetched tables (Settings > SQL > Libraries): by default library_cache in Octa's settings folder; Choose folder... picks your own. Octa deletes only files it wrote there, never anything else. The folder holds data from your servers, so keep it where such data may be.

  • Without Keep fetched tables when Octa closes (Settings > SQL > Libraries, off by default) every run writes into a folder of its own that is removed when Octa closes; one left behind by a crash is removed at the next start.
  • With it, the copies stay after Octa closes and the next session reuses them when their source says it has not changed. It works on its own, whether or not Reopen last session is on.
  • Size limit for fetched tables (1 GB by default, in MB or GB, or Unlimited) applies to the whole folder. Over it, the copies used longest ago go first. A copy a running query needs is never deleted under it; one that alone is larger than the limit serves its query and is not kept, and the status line says so.

On the command line and over MCP

octa --list-libraries
octa --add-library 'name=sales,connection=warehouse,schema=sales'
octa --add-library "name=raw,path=$HOME/exports"
octa --test-library sales
octa --sql -q 'SELECT * FROM sales.orders o JOIN raw.customers c USING (customer_id)'

A query of libraries alone needs no file. See Libraries on the command line and the MCP tools list_libraries and run_sql.

The assistant may read the folders and files of your libraries even when Restrict file access is on: you set them up.

See also