Skip to main content

Module read_functions

Module read_functions 

Source
Expand description

read_parquet(path), read_csv(path, header => false) and read_json(path): files as tables, as in DuckDB.

Each is a thin wrapper over the path: FROM read_csv('edges.csv') reads the same table as FROM 'edges.csv' ([crate::file_table]), so a relative path, a glob, a directory or a URL behaves the same, and a graph’s index cache knows the files by the same identity. What the function adds is the format, whatever the extension, and a few options:

  • read_csv: header, delim (or sep or delimiter), quote, compression;
  • read_json: compression, and format => 'array' for a file holding one JSON array of objects rather than one object per line;
  • read_parquet: none.

The first argument is a path or a list of paths (['a.csv', 'b.csv']). Options are named, name => value as Ursa’s graph functions take them, or name = value as DuckDB writes them. read_csv_auto, read_json_auto and read_ndjson are DuckDB’s other names for the same functions.

§Opened before planning

Opening files is async (it lists them and infers a schema), and a relation planner is not. So open_reads walks a statement before it is planned, opens every read_* call in it, and keeps each table under the call’s text in the session’s ReadTables; ReadFunctions, the relation planner, then finds the table there by the same text. Ursa’s SQL layer (ursa_sql::execute) does this for every statement, so a call in a view, a subquery, a CTE, a COPY or an EXPLAIN is opened too.

Structs§

OpenReads
The tables open_reads opened for one statement. Dropping it forgets them, once the statement is planned.
ReadFunctions
Plans read_* calls in FROM as scans of the tables open_reads opened.
ReadTables
The tables of the read_* calls in the statements being planned, by the call’s text, with how many statements are using each.

Functions§

names
The names of the read_* functions.
open_reads
Open the table of every read_* call in statement, for ReadFunctions to plan. Keep the result until the statement is planned.
paths_mut
The paths factor reads, if it is a read_* call: the strings of its first argument, for a database to rewrite relative to its directory.