View

The [View] struct is Perspective's query and serialization interface. It represents a query on the Table's dataset and is always created from an existing Table instance via the [Table::view] method.

[View]s are immutable with respect to the arguments provided to the [Table::view] method; to change these parameters, you must create a new [View] on the same [Table]. However, each [View] is live with respect to the [Table]'s data, and will (within a conflation window) update with the latest state as its parent [Table] updates, including incrementally recalculating all aggregates, pivots, filters, etc. [View] query parameters are composable, in that each parameter works independently and in conjunction with each other, and there is no limit to the number of pivots, filters, etc. which can be applied.

The examples in this module are in JavaScript. See perspective docs for the Rust API.
The examples in this module are in Python. See perspective docs for the Rust API.

Examples

const table = await perspective.table({
    id: [1, 2, 3, 4],
    name: ["a", "b", "c", "d"],
});

const view = await table.view({ columns: ["name"] });
const json = await view.to_json();
await view.delete();
table = perspective.Table({
  "id": [1, 2, 3, 4],
  "name": ["a", "b", "c", "d"]
});

view = table.view(columns=["name"])
arrow = view.to_arrow()
view.delete()
#![allow(unused)]
fn main() {
let opts = TableInitOptions::default();
let data = TableData::Update(UpdateData::Csv("x,y\n1,2\n3,4".into()));
let table = client.table(data, opts).await?;

let view = table.view(None).await?;
let arrow = view.to_arrow().await?;
view.delete().await?;
}