Note: Tables are an experimental feature in RAW. Although the format is considered stable, features are missing and the public API is still subject to changes.
Tables are used in RAW to permanently store data.
Tables are designed for "tabular" structure, similarly to SQL tables in relational databases.
The raw_magic extension is already loaded. To reload it, use: %reload_ext raw_magic
To create a table in RAW we use the
%%table magic. The type must be passed as an argument.
The type is described in RQL syntax and must consist of a tabular structure, i.e. a collection of records of primitive types.
To create a table called
%%table table1 type: 'collection(record(column_1: int, column_2: string))'
table table1 replaced
This table is now empty.
To insert data into the table, we use the
tables_insert magic. This requires the table name and the contents to be inserted into the table.
The contents are an RQL query.
This allows users to load data into a RAW table from another location as in:
%%tables_insert table1 SELECT Altitude AS column_1, City AS column_2 FROM READ("https://raw-tutorial.s3.amazonaws.com/airports.csv")
The table contents can now be queried:
%%rql SELECT * FROM table1 LIMIT 10
It is also possible to insert data that does not originate from another location.
This can be done by creating a RAW query that includes the data to be inserted.
Let's create a new table, and insert data into it:
%%table table2 type: 'collection(record(column_1: int, column_2: string))'
table table2 replaced
To insert data, we write an RQL query using RAW's syntax to create collections and records.
To create a collection in RAW we use
To create records in RAW we use
(<field>: <value>, ...).
Therefore, we can insert data manually as in:
%%tables_insert table2 [ (column_1: 1, column_2: "Row 1"), (column_1: 2, column_2: "Row 2"), (column_1: 3, column_2: "Row 3") ]
%%rql SELECT * FROM table2
Tables use multiversion concurrency control.