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.
JsonSource
A JSON document as tables: an array of objects (or one object) becomes a table, nested objects become dotted column names ('address.city'), and each nested array becomes a child table joined back through '_parent_id' = '_id'; an array member 'tags' of table 'runs' is the table 'runs_tags'. Array items that are not objects become a child table with one 'value' column. Columns are typed as JsonLinesSource types them. A name ending in '.gz' is decompressed first.
Example
catalog := Catalog->New();
catalog->Load(JsonSource->New("runs.json"));
rs := catalog->Query("select r.name, t.value from runs r join runs_tags t on t._parent_id = r._id");Operations
FromText # function
Makes a source over JSON text already in memory
function : FromText(name:String, text:String) ~ JsonSourceParameters
| Name | Type | Description |
|---|---|---|
| name | String | table name |
| text | String | JSON text |
Return
| Type | Description |
|---|---|
| JsonSource | source |
GetChildTables #
Gets the child tables the last Read made: depth first, in the order their arrays were first seen, an object's members taken alphabetically
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 document 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 document'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 file |
New # constructor
Constructor
New(path:String, name:String)Parameters
| Name | Type | Description |
|---|---|---|
| path | String | JSON file |
| name | String | table name |