In-memory query engine over typed columns. Tables are filled row by row or loaded from sources (CSV files, folders, the program's own objects) and queried with SQL-like statements; aggregates, Describe() and Finder (file search) are included. Compile with -lib query.
JsonLinesSource
A JSON Lines file (one JSON object per line, '.jsonl' or '.ndjson') as a table. Nested objects become dotted column names ('address.city'), and each nested array becomes a child table, as JsonSource makes them: an array member 'tags' of table 'runs' is the table 'runs_tags', joined back through '_parent_id' = '_id'. Columns are typed by all their values: whole numbers INT, any decimal FLOAT, true and false BOOL, and any mix, or text, STRING. null and a missing key are empty cells. A line that is not a JSON object is an error naming the line. Columns appear in the order keys are first seen, alphabetical within an object. A name ending in '.gz' is decompressed first.
Example
runs := JsonLinesSource->New("eval.jsonl")->Read();
runs->Describe()->ToString()->PrintLine();Operations
FromText # function
Makes a source over JSON Lines text already in memory
function : FromText(name:String, text:String) ~ JsonLinesSourceParameters
| Name | Type | Description |
|---|---|---|
| name | String | table name |
| text | String | JSON Lines text |
Return
| Type | Description |
|---|---|
| JsonLinesSource | source |
GetChildTables #
Gets the child tables the last Read made, in the order their arrays were first seen
method : public : GetChildTables() ~ Vector<Table>Return
| Type | Description |
|---|---|
| Vector<Table> | child tables, empty if there are none |
GetError #
Gets the reason the last read failed
method : public : GetError() ~ StringReturn
| Type | Description |
|---|---|
| String | error, Nil if none |
GetTables #
Gets the tables the file provides, the main table first; they are known only after reading it
method : public : GetTables() ~ TableSpec[]Return
| Type | Description |
|---|---|
| TableSpec | table shapes |
Load #
Loads the file's tables into a catalog
method : public : Load(catalog:Catalog, hint:ScanHint) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| catalog | Catalog | catalog |
| hint | ScanHint | columns and rows of the main table needed, Nil for everything |
Return
| Type | Description |
|---|---|
| Bool | true if loaded |
New # constructor
Constructor; the table is named after the file
New(path:String)Parameters
| Name | Type | Description |
|---|---|---|
| path | String | JSON Lines file |
New # constructor
Constructor
New(path:String, name:String)Parameters
| Name | Type | Description |
|---|---|---|
| path | String | JSON Lines file |
| name | String | table name |