A filtered view is a queryable filter of a table,
collection, or another view. A view can also be referred
to as a result set. A filtered view can be created by filtering an existing
table or view using the /filter
endpoint.
Filtered views can be updated to insert the missing data points for a series from the underlying table using /update/records/byseries.
As they are result sets, and given the need to minimize memory usage, filtered views are given a default time-to-live, after which they will expire and be removed from memory. Each access of the filtered view causes the remaining time-to-live to be reset. Thus, a filtered view accessed more frequently than its time-to-live will effectively remain in memory indefinitely.
Filtered views have the same naming criteria as tables.
To create a filtered view, the /filter endpoint requires three parameters:
In Python, given the nyctaxi
demo table, a filtered view can be created
for all taxi rides from the YCAB
vendor via:
h_db.filter(
table_name = "nyctaxi",
view_name = "nyctaxi_ycab",
expression = "vendor_id = 'YCAB'"
)
The resulting filtered view can then be further filtered for expensive single-passenger rides:
h_db.filter(
table_name = "nyctaxi_ycab",
view_name = "nyctaxi_ycab_single_expensive",
expression = "passenger_count = 1 and total_amount > 150"
)
A filtered view has a relatively lower memory footprint compared to a join view or a memory-only table, such as a projection or union. Read more about memory-only tables and their relative memory implications on Memory-Only Tables.