Creating and Using Views

So far we have run queries using the %%rql magic.

As data analysis gets more complex, it is difficult to express all transformations in a single query.

Views are a mechanism in RAW to store and reference queries you've done before.

They are conceptually similar to virtual views in classical databases.

To define a view, we use the %%view magic, as:

%%view <view name>

<query>

Let's define our first view, which simply list all the contents of a file.

This creates a view named airports, which consists of reading the CSV file.

To use this view, we can just reference it in a query.

This query now resembles even more traditional SQL.

In fact, it achieved a form of "virtualization" by hiding the exact location of the original data, and presenting it to the consumer under a name.

If the location of the file were changed, or its query changed to clean some data for instance, the view name would be kept stable.

We can create other views similarly:

We can also list the views available using a Jupyter magic:

Next: Querying Complex Data