1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
# ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
# ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
# ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
# ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
# ┃ Copyright (c) 2017, the Perspective Authors. ┃
# ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
# ┃ This file is part of the Perspective library, distributed under the terms ┃
# ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
"""
An interface for implementing a Perspective `VirtualServer`. It operates
thusly:
- A table is selected by name (validated via `get_hosted_tables`).
- The UI will ask the model to create a temporary table with the results
of querying this table with a specific query `config`, a simple struct
which reflects the UI configurable fields (see `get_features`).
- The UI will query slices of the temporary table as it needs them to
render. This may be a rectangular slice, a whole column or the entire
set, and it is returned from teh model via a custom push-only
struct `PerspectiveColumn` for now, though in the future we will support
e.g. Polars and other arrow-native formats directly.
- The UI will delete its own temporary tables via `view_delete` but it is
ok for them to die intermittently, the UI will recover automatically.
"""
"""
[OPTIONAL] Toggle UI features through data model support. For example,
setting `"group_by": False` would hide the "Group By" UI control, as
well as prevent this field from appearing in `config` dicts later
provided to `table_make_view`.
This API defaults to just "columns", e.g. a simple flat datagrid in
which you can just scroll, select and format columns.
# Example
```python
return {
"group_by": True,
"split_by": True,
"sort": True,
"expressions": True,
"filter_ops": {
"integer": ["==", "<"],
},
"aggregates": {
"string": ["count"],
"float": ["count", "sum"],
},
}
```
"""
pass
"""
List of `Table` names available to query from.
"""
pass
"""
Get the _Perspective Schema_ for a `Table`, a mapping of column name to
Perspective column types, a simplified set of six visually-relevant
types mapped from DuckDB's much richer type system. Optionally,
a model may also implement `view_schema` which describes temporary
tables, but for DuckDB this method is identical.
"""
pass
"""
Get a table's row count. Optionally, a model may also implement the
`view_size` method to get the row count for temporary tables, but for
DuckDB this method is identical.
"""
pass
return
return
"""
Create a temporary table `view_name` from the results of querying
`table_name` with a query configuration `config`.
"""
pass
"""
[OPTIONAL] Given a temporary table `view_name`, validate the type of
a column expression string `expression`, or raise an error if the
expression is invalid. This is enabeld by `"expressions"` via
`get_features` and defaults to allow all expressions.
"""
pass
"""
Delete a temporary table. The UI will do this automatically, and it
can recover.
"""
pass
"""
[OPTIONAL] Get the min and max values of a column in a view.
Returns a tuple of (min, max) as native Python values.
"""
pass
"""
Serialize a rectangular slice `viewport` from temporary table
`view_name`, into the `PerspectiveColumn` serialization API injected
via `data`. The push-only `PerspectiveColumn` type can handle casting
Python types as input, but once a type is pushed to a column name it
must not be changed.
"""
pass