@perspective-dev/client 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/perspective.js +1 -1
- package/dist/cdn/perspective.js.map +2 -2
- package/dist/esm/perspective.inline.js +2 -2
- package/dist/esm/perspective.inline.js.map +3 -3
- package/dist/esm/perspective.js +1 -1
- package/dist/esm/perspective.js.map +2 -2
- package/dist/esm/perspective.node.js +9 -9
- package/dist/esm/perspective.node.js.map +1 -1
- package/dist/esm/ts-rs/Features.d.ts +10 -3
- package/dist/esm/ts-rs/ListFlatten.d.ts +1 -0
- package/dist/esm/ts-rs/SplitRollupMode.d.ts +9 -0
- package/dist/esm/ts-rs/TableInitOptions.d.ts +9 -0
- package/dist/esm/ts-rs/ViewConfig.d.ts +2 -0
- package/dist/esm/ts-rs/ViewConfigUpdate.d.ts +15 -0
- package/dist/esm/ts-rs/WindowAggSpec.d.ts +25 -0
- package/dist/esm/ts-rs/WindowSpec.d.ts +3 -2
- package/dist/esm/virtual_servers/clickhouse.js +1 -1
- package/dist/esm/virtual_servers/clickhouse.js.map +3 -3
- package/dist/esm/virtual_servers/duckdb.js +1 -1
- package/dist/esm/virtual_servers/duckdb.js.map +3 -3
- package/dist/wasm/perspective-js.d.ts +6 -6
- package/dist/wasm/perspective-js.js +10 -10
- package/dist/wasm/perspective-js.wasm +0 -0
- package/dist/wasm/perspective-js.wasm.d.ts +5 -5
- package/package.json +1 -1
- package/src/rust/lib.rs +1 -1
- package/src/rust/typed_array.rs +22 -3
- package/src/ts/ts-rs/Features.ts +10 -3
- package/src/ts/ts-rs/ListFlatten.ts +3 -0
- package/src/ts/ts-rs/SplitRollupMode.ts +11 -0
- package/src/ts/ts-rs/TableInitOptions.ts +10 -1
- package/src/ts/ts-rs/ViewConfig.ts +2 -1
- package/src/ts/ts-rs/ViewConfigUpdate.ts +15 -1
- package/src/ts/ts-rs/WindowAggSpec.ts +25 -0
- package/src/ts/ts-rs/WindowSpec.ts +3 -2
- package/src/ts/virtual_servers/clickhouse.ts +55 -23
- package/src/ts/virtual_servers/duckdb.ts +123 -49
- package/dist/esm/ts-rs/WindowAggregate.d.ts +0 -1
- package/src/ts/ts-rs/WindowAggregate.ts +0 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AggSpec } from "./AggSpec.js";
|
|
2
2
|
import type { ColumnType } from "./ColumnType.js";
|
|
3
3
|
import type { GroupRollupMode } from "./GroupRollupMode.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { SplitRollupMode } from "./SplitRollupMode.js";
|
|
5
|
+
import type { WindowAggSpec } from "./WindowAggSpec.js";
|
|
5
6
|
/**
|
|
6
7
|
* Describes the capabilities supported by a virtual server handler.
|
|
7
8
|
*
|
|
@@ -22,6 +23,12 @@ export type Features = {
|
|
|
22
23
|
* Whether split-by (pivot) operations are supported.
|
|
23
24
|
*/
|
|
24
25
|
split_by?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Which `split_rollup_mode` options are supported. Empty (the default)
|
|
28
|
+
* means `["flat"]` - a server must opt in to `"rollup"` explicitly, as
|
|
29
|
+
* it requires emitting subtotal and grand-total column groups.
|
|
30
|
+
*/
|
|
31
|
+
split_rollup_mode?: Array<SplitRollupMode>;
|
|
25
32
|
/**
|
|
26
33
|
* Available filter operators per column type.
|
|
27
34
|
*/
|
|
@@ -43,10 +50,10 @@ export type Features = {
|
|
|
43
50
|
*/
|
|
44
51
|
expressions?: boolean;
|
|
45
52
|
/**
|
|
46
|
-
* Available window aggregates.
|
|
53
|
+
* Available window aggregates per column type.
|
|
47
54
|
*/
|
|
48
55
|
window_aggregates?: {
|
|
49
|
-
[key in ColumnType]?: Array<
|
|
56
|
+
[key in ColumnType]?: Array<WindowAggSpec>;
|
|
50
57
|
};
|
|
51
58
|
/**
|
|
52
59
|
* Whether update callbacks are supported.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ListFlatten = "zip" | "cartesian" | "stringify";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `split_by` corollary to [`GroupRollupMode`]. `Flat` (the default,
|
|
3
|
+
* matching this crate's historical behavior) emits only full-depth split
|
|
4
|
+
* combinations as columns; `Rollup` additionally emits grand-total and
|
|
5
|
+
* subtotal column groups in "totals before" order. There is no `Total`
|
|
6
|
+
* variant - an empty `split_by` already expresses a single grand-total
|
|
7
|
+
* column group.
|
|
8
|
+
*/
|
|
9
|
+
export type SplitRollupMode = "flat" | "rollup";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListFlatten } from "./ListFlatten.js";
|
|
1
2
|
import type { TableReadFormat } from "./TableReadFormat.js";
|
|
2
3
|
/**
|
|
3
4
|
* Options which impact the behavior of [`Client::table`], as well as
|
|
@@ -25,4 +26,12 @@ export type TableInitOptions = {
|
|
|
25
26
|
* WASM it is OPFS (Worker only). Defaults to in-memory.
|
|
26
27
|
*/
|
|
27
28
|
page_to_disk?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* How Arrow `LIST` and JSON `Array` columns are ingested. `zip` (the
|
|
31
|
+
* default) and `cartesian` expand a row into one row per list element,
|
|
32
|
+
* and are incompatible with `index`, as the rows of an expansion
|
|
33
|
+
* repeat their index. `stringify` encodes each list as a JSON array in
|
|
34
|
+
* a single string column instead.
|
|
35
|
+
*/
|
|
36
|
+
list_flatten?: ListFlatten;
|
|
28
37
|
};
|
|
@@ -4,6 +4,7 @@ import type { Filter } from "./Filter.js";
|
|
|
4
4
|
import type { FilterReducer } from "./FilterReducer.js";
|
|
5
5
|
import type { GroupRollupMode } from "./GroupRollupMode.js";
|
|
6
6
|
import type { Sort } from "./Sort.js";
|
|
7
|
+
import type { SplitRollupMode } from "./SplitRollupMode.js";
|
|
7
8
|
import type { Windows } from "./Windows.js";
|
|
8
9
|
export type ViewConfig = {
|
|
9
10
|
group_by: Array<string>;
|
|
@@ -11,6 +12,7 @@ export type ViewConfig = {
|
|
|
11
12
|
sort: Array<Sort>;
|
|
12
13
|
filter: Array<Filter>;
|
|
13
14
|
group_rollup_mode: GroupRollupMode;
|
|
15
|
+
split_rollup_mode: SplitRollupMode;
|
|
14
16
|
filter_op?: FilterReducer;
|
|
15
17
|
expressions: Expressions;
|
|
16
18
|
windows?: Windows;
|
|
@@ -4,6 +4,7 @@ import type { Filter } from "./Filter.js";
|
|
|
4
4
|
import type { FilterReducer } from "./FilterReducer.js";
|
|
5
5
|
import type { GroupRollupMode } from "./GroupRollupMode.js";
|
|
6
6
|
import type { Sort } from "./Sort.js";
|
|
7
|
+
import type { SplitRollupMode } from "./SplitRollupMode.js";
|
|
7
8
|
import type { Windows } from "./Windows.js";
|
|
8
9
|
export type ViewConfigUpdate = {
|
|
9
10
|
/**
|
|
@@ -61,6 +62,12 @@ export type ViewConfigUpdate = {
|
|
|
61
62
|
* name and a string sort direction. When `column-pivots` are applied,
|
|
62
63
|
* the additional sort directions `"col asc"` and `"col desc"` will
|
|
63
64
|
* determine the order of pivot columns groups.
|
|
65
|
+
*
|
|
66
|
+
* `sort` is the ONLY thing that orders a `View`'s rows — without it
|
|
67
|
+
* they keep the `Table`'s natural (insertion) order, which any
|
|
68
|
+
* consumer reading rows sequentially will reflect. Not to be
|
|
69
|
+
* confused with a window column's `order_by`, which orders rows
|
|
70
|
+
* WITHIN a window frame and does not reorder the `View`.
|
|
64
71
|
*/
|
|
65
72
|
sort?: Array<Sort>;
|
|
66
73
|
/**
|
|
@@ -91,6 +98,13 @@ export type ViewConfigUpdate = {
|
|
|
91
98
|
* Perspective provides a selection of aggregate functions that can be
|
|
92
99
|
* applied to columns in the `View` constructor using a dictionary of
|
|
93
100
|
* column name to aggregate function name.
|
|
101
|
+
*
|
|
102
|
+
* An aggregate also determines the column's RESULT TYPE, which need
|
|
103
|
+
* not match the input: `"count"` yields an `integer` whatever it
|
|
104
|
+
* counts, so a `date` column left on the default `"count"` is an
|
|
105
|
+
* `integer` in the resulting `View` — no longer a date. Set an
|
|
106
|
+
* aggregate that preserves the type (e.g. `"any"`, `"last"`) when
|
|
107
|
+
* the original type matters, such as a date used as a chart axis.
|
|
94
108
|
*/
|
|
95
109
|
aggregates?: {
|
|
96
110
|
[key in string]?: Aggregate;
|
|
@@ -98,4 +112,5 @@ export type ViewConfigUpdate = {
|
|
|
98
112
|
group_by_depth?: number;
|
|
99
113
|
filter_op?: FilterReducer;
|
|
100
114
|
group_rollup_mode?: GroupRollupMode;
|
|
115
|
+
split_rollup_mode?: SplitRollupMode;
|
|
101
116
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ColumnType } from "./ColumnType.js";
|
|
2
|
+
/**
|
|
3
|
+
* Specification for a window aggregate.
|
|
4
|
+
*/
|
|
5
|
+
export type WindowAggSpec = {
|
|
6
|
+
name: string;
|
|
7
|
+
/**
|
|
8
|
+
* Frame kinds this aggregate accepts (`rows`, `range`, `cumulative`).
|
|
9
|
+
* Empty means it takes no frame at all.
|
|
10
|
+
*/
|
|
11
|
+
frames?: Array<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Takes a row offset, as `lag` / `lead` / `diff` do.
|
|
14
|
+
*/
|
|
15
|
+
offset?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Takes a smoothing factor, as `ema` does.
|
|
18
|
+
*/
|
|
19
|
+
alpha?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The output column type. `None` means the source column's type, which
|
|
22
|
+
* is what `min` / `max` / `lag` do.
|
|
23
|
+
*/
|
|
24
|
+
result_type?: ColumnType;
|
|
25
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { WindowAggregate } from "./WindowAggregate.js";
|
|
2
1
|
import type { WindowSort } from "./WindowSort.js";
|
|
3
2
|
/**
|
|
4
3
|
* The serialized form of [`WindowSpec`].
|
|
@@ -9,7 +8,7 @@ export type WindowSpec = {
|
|
|
9
8
|
* alias from the same `ViewConfig`.
|
|
10
9
|
*/
|
|
11
10
|
column: string;
|
|
12
|
-
aggregate:
|
|
11
|
+
aggregate: string;
|
|
13
12
|
/**
|
|
14
13
|
* Columns whose distinct value tuples partition the rows; empty
|
|
15
14
|
* partitions the whole `Table` as one group.
|
|
@@ -17,6 +16,8 @@ export type WindowSpec = {
|
|
|
17
16
|
partition_by?: Array<string>;
|
|
18
17
|
/**
|
|
19
18
|
* The `Table` column which orders each partition, and the direction.
|
|
19
|
+
* This orders rows WITHIN the window frame only — it does not
|
|
20
|
+
* reorder the `View`, which is what the view-level `sort` does.
|
|
20
21
|
*/
|
|
21
22
|
order_by?: WindowSort | null;
|
|
22
23
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=["sum","count","any_value","arbitrary","array_agg","avg","bit_and","bit_or","bit_xor","bitstring_agg","bool_and","bool_or","countif","favg","fsum","geomean","kahan_sum","last","max","min","product","string_agg","sumkahan"],f=["count","any_value","arbitrary","first","countif","last","string_agg"],l=["rows","range","cumulative"],T=[{name:"sum",frames:l,result_type:"float"},{name:"avg",frames:l,result_type:"float"},{name:"count",frames:l,result_type:"float"},{name:"min",frames:l},{name:"max",frames:l},{name:"stddev_samp",frames:l,result_type:"float"},{name:"var_samp",frames:l,result_type:"float"},{name:"lag",offset:!0},{name:"lead",offset:!0},{name:"diff",offset:!0,result_type:"float"},{name:"rate",frames:["range"],result_type:"float"}],d=[{name:"count",frames:l,result_type:"float"},{name:"min",frames:l},{name:"max",frames:l},{name:"lag",offset:!0},{name:"lead",offset:!0}],p=["==","!=","IS DISTINCT FROM","IS NOT DISTINCT FROM",">=","<=",">","<","is null","is not null"],E=[...p,"begins with","not begins with","contains","not contains","ends with","not ends with","matches","not matches","in","not in","LIKE","NOT LIKE","ILIKE","NOT ILIKE"];function _(i){if(i.startsWith("Nullable")&&(i=i.match(/Nullable\((.+?)\)/)[1]),i.startsWith("Array"))return"string";if(i==="Int64"||i==="UInt64"||i==="Float64")return"float";if(i==="String")return"string";if(i==="DateTime")return"datetime";if(i==="Date")return"date";throw new Error(`Unknown type '${i}'`)}function V(i,t){if(!(i instanceof Uint32Array||i instanceof Int32Array))return i;let e=BigInt(0);for(let r=0;r<i.length;r++)e|=BigInt(i[r])<<BigInt(r*32);let s=t.match(/Decimal\[\d+e(\d+)\]/);if(s){let r=parseInt(s[1]);return Number(e)/Math.pow(10,r)}else return Number(e)}var h=class{lockPromise;constructor(){this.lockPromise=Promise.resolve()}acquire(){let t,e=new Promise(r=>{t=r}),s=this.lockPromise.then(()=>t);return this.lockPromise=e,s}},q=new h;async function u(i,t,e={}){t=t.replace(/\s+/g," ").trim();let s=await q.acquire();try{let r=await i.query({query:t});if(!e.execute){let{data:o,meta:a}=await r.json();return e.columns?{rows:o,columns:a.map(c=>c.name),dtypes:a.map(c=>c.type)}:o}}catch(r){throw console.error("Query error:",r),console.error("Query:",t),r}finally{s()}}var I=class{db;sqlBuilder;constructor(t,e){if(!e&&customElements){let s=customElements.get("perspective-viewer");if(s)e=s.__wasm_module__;else throw new Error("Missing perspective-client.wasm")}this.db=t,this.sqlBuilder=new e.GenericSQLVirtualServerModel({create_entity:"VIEW",grouping_fn:"GROUPING",column_separator:"|",backslash_escaped_literals:!0,regex_fn:"match"})}getFeatures(){return{group_by:!0,split_by:!1,sort:!0,expressions:!0,unordered:!0,window_aggregates:{integer:T,float:T,string:d,date:d,datetime:d,boolean:d},group_rollup_mode:["rollup","flat","total"],filter_ops:{integer:p,float:p,string:E,boolean:p,date:p,datetime:p},aggregates:{integer:S,float:S,string:f,boolean:f,date:f,datetime:f}}}async getHostedTables(){return(await u(this.db,"SHOW TABLES")).map(s=>`${s.name}`)}async tableSchema(t,e){let s=this.sqlBuilder.tableSchema(t),r=await u(this.db,s),o={};for(let a of r){let c=a.name;c.startsWith("__")||(o[c]=_(a.type))}return o}async viewColumnSize(t,e){let s=`SELECT COUNT() FROM system.columns WHERE table = '${t}'`,r=await u(this.db,s),o=e.group_by?.length||0,a=Number(r[0]["COUNT()"]);return console.log(a),a-(o===0?0:o+(e.split_by?.length===0?1:0))}async tableSize(t){let e=this.sqlBuilder.tableSize(t),s=await u(this.db,e);return Number(s[0]["COUNT()"])}async tableMakeView(t,e,s){let r=this.sqlBuilder.tableMakeView(t,e,s);await u(this.db,r,{execute:!0})}async tableValidateExpression(t,e){let s=this.sqlBuilder.tableValidateExpression(t,e),r=await u(this.db,s);return _(r[0].type)}async viewDelete(t){let e=this.sqlBuilder.viewDelete(t);await u(this.db,e,{execute:!0})}async viewGetData(t,e,s,r,o){let a=this.sqlBuilder.viewGetData(t,e,r,s),{rows:c,columns:b,dtypes:y}=await u(this.db,a,{columns:!0});for(let m=0;m<b.length;m++){let v=b[m],w=_(y[m]),N=y[m].startsWith("Decimal");for(let g=0;g<c.length;g++){let C=c[g],k=C.__GROUPING_ID__,n=C[v];N&&(n=V(n,y[m])),typeof n=="bigint"&&(n=Number(n)),w==="datetime"&&typeof n=="string"&&(n=+new Date(n)),w==="string"&&typeof n!="string"&&(n=`${n}`),o.setCol(w,v,g,n,k)}}}};export{I as ClickhouseHandler};
|
|
2
2
|
//# sourceMappingURL=clickhouse.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ts/virtual_servers/clickhouse.ts"],
|
|
4
|
-
"sourcesContent": ["// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * An implementation of a Perspective Virtual Server for DuckDB.\n *\n * This import is optional, and so must be imported manually from either\n * `@perspective-dev/client/dist/esm/virtual_servers/duckdb.js` or\n * `@perspective-dev/client/src/ts/virtual_servers/duckdb.ts`, it is not\n * exported from the package root `@perspective-dev/client`\n *\n * @module\n */\n\nimport type * as perspective from \"@perspective-dev/client\";\nimport type { ColumnType } from \"@perspective-dev/client/dist/esm/ts-rs/ColumnType.d.ts\";\nimport type { ViewConfig } from \"@perspective-dev/client/dist/esm/ts-rs/ViewConfig.d.ts\";\nimport type { ViewConfigUpdate } from \"@perspective-dev/client/dist/esm/ts-rs/ViewConfigUpdate.d.ts\";\nimport type { ViewWindow } from \"@perspective-dev/client/dist/esm/ts-rs/ViewWindow.d.ts\";\nimport type { WindowAggregate } from \"@perspective-dev/client/dist/esm/ts-rs/WindowAggregate.d.ts\";\nimport type * as clickhouse from \"@clickhouse/client-web\";\n\nconst NUMBER_AGGS = [\n \"sum\",\n \"count\",\n \"any_value\",\n \"arbitrary\",\n \"array_agg\",\n \"avg\",\n \"bit_and\",\n \"bit_or\",\n \"bit_xor\",\n \"bitstring_agg\",\n \"bool_and\",\n \"bool_or\",\n \"countif\",\n \"favg\",\n \"fsum\",\n \"geomean\",\n \"kahan_sum\",\n \"last\",\n \"max\",\n \"min\",\n \"product\",\n \"string_agg\",\n \"sumkahan\",\n];\n\nconst STRING_AGGS = [\n \"count\",\n \"any_value\",\n \"arbitrary\",\n \"first\",\n \"countif\",\n \"last\",\n \"string_agg\",\n];\n\n// The window aggregates the SQL translation supports, per source\n// column type (`ema` is recursive - no SQL window equivalent).\nconst WINDOW_AGGREGATES: WindowAggregate[] = [\n \"sum\",\n \"avg\",\n \"count\",\n \"min\",\n \"max\",\n \"stddev\",\n \"var\",\n \"lag\",\n \"lead\",\n \"diff\",\n \"rate\",\n];\n\nconst WINDOW_AGGREGATES_ANY: WindowAggregate[] = [\n \"count\",\n \"min\",\n \"max\",\n \"lag\",\n \"lead\",\n];\n\nconst FILTER_OPS = [\n \"==\",\n \"!=\",\n \"LIKE\",\n \"IS DISTINCT FROM\",\n \"IS NOT DISTINCT FROM\",\n \">=\",\n \"<=\",\n \">\",\n \"<\",\n];\n\nfunction duckdbTypeToPsp(name: string): ColumnType {\n if (name.startsWith(\"Nullable\")) {\n name = name.match(/Nullable\\((.+?)\\)/)![1];\n }\n\n if (name.startsWith(\"Array\")) {\n return \"string\";\n }\n\n if (name === \"Int64\" || name === \"UInt64\" || name === \"Float64\") {\n return \"float\";\n }\n\n if (name === \"String\") {\n return \"string\";\n }\n\n if (name === \"DateTime\") {\n return \"datetime\";\n }\n\n if (name === \"Date\") {\n return \"date\";\n }\n\n throw new Error(`Unknown type '${name}'`);\n}\n\nfunction convertDecimalToNumber(value: any, dtypeString: string) {\n if (!(value instanceof Uint32Array || value instanceof Int32Array)) {\n return value;\n }\n\n let bigIntValue = BigInt(0);\n for (let i = 0; i < value.length; i++) {\n bigIntValue |= BigInt(value[i]) << BigInt(i * 32);\n }\n\n const scaleMatch = dtypeString.match(/Decimal\\[\\d+e(\\d+)\\]/);\n if (scaleMatch) {\n const scale = parseInt(scaleMatch[1]);\n return Number(bigIntValue) / Math.pow(10, scale);\n } else {\n return Number(bigIntValue);\n }\n}\n\nclass Lock {\n lockPromise: Promise<void>;\n constructor() {\n this.lockPromise = Promise.resolve();\n }\n\n acquire() {\n let releaseLock: (value: void) => void;\n const newLockPromise: Promise<void> = new Promise((resolve) => {\n releaseLock = resolve;\n });\n\n const acquirePromise = this.lockPromise.then(() => releaseLock);\n this.lockPromise = newLockPromise;\n return acquirePromise;\n }\n}\n\nconst LOCK = new Lock();\n\nasync function runQuery(\n db: clickhouse.ClickHouseClient,\n query: string,\n options: { columns?: true; execute?: boolean },\n): Promise<{\n rows: any[];\n columns: string[];\n dtypes: string[];\n}>;\n\nasync function runQuery(\n db: clickhouse.ClickHouseClient,\n query: string,\n options?: { columns?: false; execute?: boolean },\n): Promise<any[]>;\n\nasync function runQuery(\n db: clickhouse.ClickHouseClient,\n query: string,\n options: { columns?: boolean; execute?: boolean } = {},\n) {\n query = query.replace(/\\s+/g, \" \").trim();\n const release = await LOCK.acquire();\n try {\n const result = await db.query({ query });\n if (!options.execute) {\n const { data, meta } =\n (await result.json()) as clickhouse.ResponseJSON<unknown>;\n\n if (options.columns) {\n return {\n rows: data,\n columns: meta!.map((f) => f.name),\n dtypes: meta!.map((f) => f.type),\n };\n }\n\n return data;\n }\n } catch (error) {\n console.error(\"Query error:\", error);\n console.error(\"Query:\", query);\n throw error;\n } finally {\n release();\n }\n}\n\n/**\n * An implementation of Perspective's Virtual Server for `@duckdb/duckdb-wasm`.\n */\nexport class ClickhouseHandler implements perspective.VirtualServerHandler {\n private db: clickhouse.ClickHouseClient;\n private sqlBuilder: perspective.GenericSQLVirtualServerModel;\n constructor(db: clickhouse.ClickHouseClient, mod?: typeof perspective) {\n if (!mod) {\n if (customElements) {\n const viewer_class: any =\n customElements.get(\"perspective-viewer\");\n if (viewer_class) {\n mod = viewer_class.__wasm_module__;\n } else {\n throw new Error(\"Missing perspective-client.wasm\");\n }\n } else {\n }\n }\n\n this.db = db;\n this.sqlBuilder = new mod!.GenericSQLVirtualServerModel({\n create_entity: \"VIEW\",\n grouping_fn: \"GROUPING\",\n column_separator: \"|\",\n });\n }\n\n getFeatures(): perspective.Features {\n return {\n group_by: true,\n split_by: false,\n sort: true,\n expressions: true,\n // ClickHouse has no stable `rowid`, so natural-order windows\n // are unsupported.\n unordered: true,\n window_aggregates: {\n // `ema` is recursive and has no SQL window translation.\n integer: WINDOW_AGGREGATES,\n float: WINDOW_AGGREGATES,\n string: WINDOW_AGGREGATES_ANY,\n date: WINDOW_AGGREGATES_ANY,\n datetime: WINDOW_AGGREGATES_ANY,\n boolean: WINDOW_AGGREGATES_ANY,\n },\n group_rollup_mode: [\"rollup\", \"flat\", \"total\"],\n filter_ops: {\n integer: FILTER_OPS,\n float: FILTER_OPS,\n string: FILTER_OPS,\n boolean: FILTER_OPS,\n date: FILTER_OPS,\n datetime: FILTER_OPS,\n },\n aggregates: {\n integer: NUMBER_AGGS,\n float: NUMBER_AGGS,\n string: STRING_AGGS,\n boolean: STRING_AGGS,\n date: STRING_AGGS,\n datetime: STRING_AGGS,\n },\n };\n }\n\n async getHostedTables() {\n const query = \"SHOW TABLES\";\n const results = await runQuery(this.db, query);\n return results.map((row) => {\n return `${row.name}`;\n });\n }\n\n async tableSchema(tableId: string, config?: ViewConfig) {\n const query = this.sqlBuilder.tableSchema(tableId);\n const results = await runQuery(this.db, query);\n const schema = {} as Record<string, ColumnType>;\n for (const result of results) {\n const colName = result.name;\n if (!colName.startsWith(\"__\")) {\n schema[colName] = duckdbTypeToPsp(result.type) as ColumnType;\n }\n }\n\n return schema;\n }\n\n async viewColumnSize(viewId: string, config: ViewConfig) {\n const query = `SELECT COUNT() FROM system.columns WHERE table = '${viewId}'`;\n const results = await runQuery(this.db, query);\n const gs = config.group_by?.length || 0;\n const count = Number(results[0][\"COUNT()\"]);\n console.log(count);\n return (\n count -\n (gs === 0 ? 0 : gs + (config.split_by?.length === 0 ? 1 : 0))\n );\n }\n\n async tableSize(tableId: string) {\n const query = this.sqlBuilder.tableSize(tableId);\n const results = await runQuery(this.db, query);\n return Number(results[0][\"COUNT()\"]);\n }\n\n async tableMakeView(\n tableId: string,\n viewId: string,\n config: ViewConfigUpdate,\n ) {\n const query = this.sqlBuilder.tableMakeView(tableId, viewId, config);\n await runQuery(this.db, query, { execute: true });\n }\n\n async tableValidateExpression(tableId: string, expression: string) {\n const query = this.sqlBuilder.tableValidateExpression(\n tableId,\n expression,\n );\n const results = await runQuery(this.db, query);\n return duckdbTypeToPsp(results[0][\"type\"]) as ColumnType;\n }\n\n async viewDelete(viewId: string) {\n const query = this.sqlBuilder.viewDelete(viewId);\n await runQuery(this.db, query, { execute: true });\n }\n\n async viewGetData(\n viewId: string,\n config: ViewConfig,\n schema: Record<string, ColumnType>,\n viewport: ViewWindow,\n dataSlice: perspective.VirtualDataSlice,\n ) {\n const query = this.sqlBuilder.viewGetData(\n viewId,\n config,\n viewport,\n schema,\n );\n\n const { rows, columns, dtypes } = await runQuery(this.db, query, {\n columns: true,\n });\n\n for (let cidx = 0; cidx < columns.length; cidx++) {\n const col = columns[cidx];\n const dtype = duckdbTypeToPsp(dtypes[cidx]) as ColumnType;\n\n const isDecimal = dtypes[cidx].startsWith(\"Decimal\");\n for (let ridx = 0; ridx < rows.length; ridx++) {\n const row = rows[ridx];\n const grouping_id = row[\"__GROUPING_ID__\"];\n let value = row[col];\n if (isDecimal) {\n value = convertDecimalToNumber(value, dtypes[cidx]);\n }\n\n if (typeof value === \"bigint\") {\n value = Number(value);\n }\n\n if (dtype === \"datetime\" && typeof value === \"string\") {\n value = +new Date(value);\n }\n\n if (dtype === \"string\" && typeof value !== \"string\") {\n value = `${value}`;\n }\n\n dataSlice.setCol(dtype, col, ridx, value, grouping_id);\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AA+BA,IAAMA,EAAc,CAChB,MACA,QACA,YACA,YACA,YACA,MACA,UACA,SACA,UACA,gBACA,WACA,UACA,UACA,OACA,OACA,UACA,YACA,OACA,MACA,MACA,UACA,aACA,UACJ,EAEMC,EAAc,CAChB,QACA,YACA,YACA,QACA,UACA,OACA,YACJ,
|
|
6
|
-
"names": ["NUMBER_AGGS", "STRING_AGGS", "WINDOW_AGGREGATES", "WINDOW_AGGREGATES_ANY", "FILTER_OPS", "duckdbTypeToPsp", "name", "convertDecimalToNumber", "value", "dtypeString", "bigIntValue", "i", "scaleMatch", "scale", "Lock", "releaseLock", "newLockPromise", "resolve", "acquirePromise", "LOCK", "runQuery", "db", "query", "options", "release", "result", "data", "meta", "f", "error", "ClickhouseHandler", "mod", "viewer_class", "row", "tableId", "config", "results", "schema", "colName", "viewId", "gs", "count", "expression", "viewport", "dataSlice", "rows", "columns", "dtypes", "cidx", "col", "dtype", "isDecimal", "ridx", "grouping_id"]
|
|
4
|
+
"sourcesContent": ["// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * An implementation of a Perspective Virtual Server for DuckDB.\n *\n * This import is optional, and so must be imported manually from either\n * `@perspective-dev/client/dist/esm/virtual_servers/duckdb.js` or\n * `@perspective-dev/client/src/ts/virtual_servers/duckdb.ts`, it is not\n * exported from the package root `@perspective-dev/client`\n *\n * @module\n */\n\nimport type * as perspective from \"@perspective-dev/client\";\nimport type { ColumnType } from \"@perspective-dev/client/dist/esm/ts-rs/ColumnType.d.ts\";\nimport type { ViewConfig } from \"@perspective-dev/client/dist/esm/ts-rs/ViewConfig.d.ts\";\nimport type { ViewConfigUpdate } from \"@perspective-dev/client/dist/esm/ts-rs/ViewConfigUpdate.d.ts\";\nimport type { ViewWindow } from \"@perspective-dev/client/dist/esm/ts-rs/ViewWindow.d.ts\";\nimport type { WindowAggSpec } from \"@perspective-dev/client/dist/esm/ts-rs/WindowAggSpec.d.ts\";\nimport type * as clickhouse from \"@clickhouse/client-web\";\n\nconst NUMBER_AGGS = [\n \"sum\",\n \"count\",\n \"any_value\",\n \"arbitrary\",\n \"array_agg\",\n \"avg\",\n \"bit_and\",\n \"bit_or\",\n \"bit_xor\",\n \"bitstring_agg\",\n \"bool_and\",\n \"bool_or\",\n \"countif\",\n \"favg\",\n \"fsum\",\n \"geomean\",\n \"kahan_sum\",\n \"last\",\n \"max\",\n \"min\",\n \"product\",\n \"string_agg\",\n \"sumkahan\",\n];\n\nconst STRING_AGGS = [\n \"count\",\n \"any_value\",\n \"arbitrary\",\n \"first\",\n \"countif\",\n \"last\",\n \"string_agg\",\n];\n\n// Window functions. Renamed from Perspective's `stddev`/`var` to the SQL\n// standard spellings DuckDB and ClickHouse both accept, since the advertised\n// name is now emitted verbatim.\n//\n// NOTE: this set is inherited from the DuckDB handler and has NOT been audited\n// against a live ClickHouse - see the aggregate lists below, which have the\n// same problem. ClickHouse's own navigation functions are `lagInFrame` /\n// `leadInFrame`, and its ranking set differs; both need verifying before being\n// advertised here.\nconst FRAMES = [\"rows\", \"range\", \"cumulative\"];\n\nconst WINDOW_AGGREGATES: WindowAggSpec[] = [\n { name: \"sum\", frames: FRAMES, result_type: \"float\" },\n { name: \"avg\", frames: FRAMES, result_type: \"float\" },\n { name: \"count\", frames: FRAMES, result_type: \"float\" },\n { name: \"min\", frames: FRAMES },\n { name: \"max\", frames: FRAMES },\n { name: \"stddev_samp\", frames: FRAMES, result_type: \"float\" },\n { name: \"var_samp\", frames: FRAMES, result_type: \"float\" },\n { name: \"lag\", offset: true },\n { name: \"lead\", offset: true },\n { name: \"diff\", offset: true, result_type: \"float\" },\n { name: \"rate\", frames: [\"range\"], result_type: \"float\" },\n];\n\nconst WINDOW_AGGREGATES_ANY: WindowAggSpec[] = [\n { name: \"count\", frames: FRAMES, result_type: \"float\" },\n { name: \"min\", frames: FRAMES },\n { name: \"max\", frames: FRAMES },\n { name: \"lag\", offset: true },\n { name: \"lead\", offset: true },\n];\n\nconst FILTER_OPS = [\n \"==\",\n \"!=\",\n \"IS DISTINCT FROM\",\n \"IS NOT DISTINCT FROM\",\n \">=\",\n \"<=\",\n \">\",\n \"<\",\n \"is null\",\n \"is not null\",\n];\n\n// Perspective's canonical string ops (translated to `ILIKE` / `match` by the\n// SQL builder), plus ClickHouse's raw infix pattern ops spliced verbatim.\nconst STRING_FILTER_OPS = [\n ...FILTER_OPS,\n \"begins with\",\n \"not begins with\",\n \"contains\",\n \"not contains\",\n \"ends with\",\n \"not ends with\",\n \"matches\",\n \"not matches\",\n \"in\",\n \"not in\",\n \"LIKE\",\n \"NOT LIKE\",\n \"ILIKE\",\n \"NOT ILIKE\",\n];\n\nfunction duckdbTypeToPsp(name: string): ColumnType {\n if (name.startsWith(\"Nullable\")) {\n name = name.match(/Nullable\\((.+?)\\)/)![1];\n }\n\n if (name.startsWith(\"Array\")) {\n return \"string\";\n }\n\n if (name === \"Int64\" || name === \"UInt64\" || name === \"Float64\") {\n return \"float\";\n }\n\n if (name === \"String\") {\n return \"string\";\n }\n\n if (name === \"DateTime\") {\n return \"datetime\";\n }\n\n if (name === \"Date\") {\n return \"date\";\n }\n\n throw new Error(`Unknown type '${name}'`);\n}\n\nfunction convertDecimalToNumber(value: any, dtypeString: string) {\n if (!(value instanceof Uint32Array || value instanceof Int32Array)) {\n return value;\n }\n\n let bigIntValue = BigInt(0);\n for (let i = 0; i < value.length; i++) {\n bigIntValue |= BigInt(value[i]) << BigInt(i * 32);\n }\n\n const scaleMatch = dtypeString.match(/Decimal\\[\\d+e(\\d+)\\]/);\n if (scaleMatch) {\n const scale = parseInt(scaleMatch[1]);\n return Number(bigIntValue) / Math.pow(10, scale);\n } else {\n return Number(bigIntValue);\n }\n}\n\nclass Lock {\n lockPromise: Promise<void>;\n constructor() {\n this.lockPromise = Promise.resolve();\n }\n\n acquire() {\n let releaseLock: (value: void) => void;\n const newLockPromise: Promise<void> = new Promise((resolve) => {\n releaseLock = resolve;\n });\n\n const acquirePromise = this.lockPromise.then(() => releaseLock);\n this.lockPromise = newLockPromise;\n return acquirePromise;\n }\n}\n\nconst LOCK = new Lock();\n\nasync function runQuery(\n db: clickhouse.ClickHouseClient,\n query: string,\n options: { columns?: true; execute?: boolean },\n): Promise<{\n rows: any[];\n columns: string[];\n dtypes: string[];\n}>;\n\nasync function runQuery(\n db: clickhouse.ClickHouseClient,\n query: string,\n options?: { columns?: false; execute?: boolean },\n): Promise<any[]>;\n\nasync function runQuery(\n db: clickhouse.ClickHouseClient,\n query: string,\n options: { columns?: boolean; execute?: boolean } = {},\n) {\n query = query.replace(/\\s+/g, \" \").trim();\n const release = await LOCK.acquire();\n try {\n const result = await db.query({ query });\n if (!options.execute) {\n const { data, meta } =\n (await result.json()) as clickhouse.ResponseJSON<unknown>;\n\n if (options.columns) {\n return {\n rows: data,\n columns: meta!.map((f) => f.name),\n dtypes: meta!.map((f) => f.type),\n };\n }\n\n return data;\n }\n } catch (error) {\n console.error(\"Query error:\", error);\n console.error(\"Query:\", query);\n throw error;\n } finally {\n release();\n }\n}\n\n/**\n * An implementation of Perspective's Virtual Server for `@duckdb/duckdb-wasm`.\n */\nexport class ClickhouseHandler implements perspective.VirtualServerHandler {\n private db: clickhouse.ClickHouseClient;\n private sqlBuilder: perspective.GenericSQLVirtualServerModel;\n constructor(db: clickhouse.ClickHouseClient, mod?: typeof perspective) {\n if (!mod) {\n if (customElements) {\n const viewer_class: any =\n customElements.get(\"perspective-viewer\");\n if (viewer_class) {\n mod = viewer_class.__wasm_module__;\n } else {\n throw new Error(\"Missing perspective-client.wasm\");\n }\n } else {\n }\n }\n\n this.db = db;\n this.sqlBuilder = new mod!.GenericSQLVirtualServerModel({\n create_entity: \"VIEW\",\n grouping_fn: \"GROUPING\",\n column_separator: \"|\",\n backslash_escaped_literals: true,\n regex_fn: \"match\",\n });\n }\n\n getFeatures(): perspective.Features {\n return {\n group_by: true,\n split_by: false,\n sort: true,\n expressions: true,\n // ClickHouse has no stable `rowid`, so natural-order windows\n // are unsupported.\n unordered: true,\n window_aggregates: {\n // `ema` is recursive and has no SQL window translation.\n integer: WINDOW_AGGREGATES,\n float: WINDOW_AGGREGATES,\n string: WINDOW_AGGREGATES_ANY,\n date: WINDOW_AGGREGATES_ANY,\n datetime: WINDOW_AGGREGATES_ANY,\n boolean: WINDOW_AGGREGATES_ANY,\n },\n group_rollup_mode: [\"rollup\", \"flat\", \"total\"],\n filter_ops: {\n integer: FILTER_OPS,\n float: FILTER_OPS,\n string: STRING_FILTER_OPS,\n boolean: FILTER_OPS,\n date: FILTER_OPS,\n datetime: FILTER_OPS,\n },\n aggregates: {\n integer: NUMBER_AGGS,\n float: NUMBER_AGGS,\n string: STRING_AGGS,\n boolean: STRING_AGGS,\n date: STRING_AGGS,\n datetime: STRING_AGGS,\n },\n };\n }\n\n async getHostedTables() {\n const query = \"SHOW TABLES\";\n const results = await runQuery(this.db, query);\n return results.map((row) => {\n return `${row.name}`;\n });\n }\n\n async tableSchema(tableId: string, config?: ViewConfig) {\n const query = this.sqlBuilder.tableSchema(tableId);\n const results = await runQuery(this.db, query);\n const schema = {} as Record<string, ColumnType>;\n for (const result of results) {\n const colName = result.name;\n if (!colName.startsWith(\"__\")) {\n schema[colName] = duckdbTypeToPsp(result.type) as ColumnType;\n }\n }\n\n return schema;\n }\n\n async viewColumnSize(viewId: string, config: ViewConfig) {\n const query = `SELECT COUNT() FROM system.columns WHERE table = '${viewId}'`;\n const results = await runQuery(this.db, query);\n const gs = config.group_by?.length || 0;\n const count = Number(results[0][\"COUNT()\"]);\n console.log(count);\n return (\n count -\n (gs === 0 ? 0 : gs + (config.split_by?.length === 0 ? 1 : 0))\n );\n }\n\n async tableSize(tableId: string) {\n const query = this.sqlBuilder.tableSize(tableId);\n const results = await runQuery(this.db, query);\n return Number(results[0][\"COUNT()\"]);\n }\n\n async tableMakeView(\n tableId: string,\n viewId: string,\n config: ViewConfigUpdate,\n ) {\n const query = this.sqlBuilder.tableMakeView(tableId, viewId, config);\n await runQuery(this.db, query, { execute: true });\n }\n\n async tableValidateExpression(tableId: string, expression: string) {\n const query = this.sqlBuilder.tableValidateExpression(\n tableId,\n expression,\n );\n const results = await runQuery(this.db, query);\n return duckdbTypeToPsp(results[0][\"type\"]) as ColumnType;\n }\n\n async viewDelete(viewId: string) {\n const query = this.sqlBuilder.viewDelete(viewId);\n await runQuery(this.db, query, { execute: true });\n }\n\n async viewGetData(\n viewId: string,\n config: ViewConfig,\n schema: Record<string, ColumnType>,\n viewport: ViewWindow,\n dataSlice: perspective.VirtualDataSlice,\n ) {\n const query = this.sqlBuilder.viewGetData(\n viewId,\n config,\n viewport,\n schema,\n );\n\n const { rows, columns, dtypes } = await runQuery(this.db, query, {\n columns: true,\n });\n\n for (let cidx = 0; cidx < columns.length; cidx++) {\n const col = columns[cidx];\n const dtype = duckdbTypeToPsp(dtypes[cidx]) as ColumnType;\n\n const isDecimal = dtypes[cidx].startsWith(\"Decimal\");\n for (let ridx = 0; ridx < rows.length; ridx++) {\n const row = rows[ridx];\n const grouping_id = row[\"__GROUPING_ID__\"];\n let value = row[col];\n if (isDecimal) {\n value = convertDecimalToNumber(value, dtypes[cidx]);\n }\n\n if (typeof value === \"bigint\") {\n value = Number(value);\n }\n\n if (dtype === \"datetime\" && typeof value === \"string\") {\n value = +new Date(value);\n }\n\n if (dtype === \"string\" && typeof value !== \"string\") {\n value = `${value}`;\n }\n\n dataSlice.setCol(dtype, col, ridx, value, grouping_id);\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AA+BA,IAAMA,EAAc,CAChB,MACA,QACA,YACA,YACA,YACA,MACA,UACA,SACA,UACA,gBACA,WACA,UACA,UACA,OACA,OACA,UACA,YACA,OACA,MACA,MACA,UACA,aACA,UACJ,EAEMC,EAAc,CAChB,QACA,YACA,YACA,QACA,UACA,OACA,YACJ,EAWMC,EAAS,CAAC,OAAQ,QAAS,YAAY,EAEvCC,EAAqC,CACvC,CAAE,KAAM,MAAO,OAAQD,EAAQ,YAAa,OAAQ,EACpD,CAAE,KAAM,MAAO,OAAQA,EAAQ,YAAa,OAAQ,EACpD,CAAE,KAAM,QAAS,OAAQA,EAAQ,YAAa,OAAQ,EACtD,CAAE,KAAM,MAAO,OAAQA,CAAO,EAC9B,CAAE,KAAM,MAAO,OAAQA,CAAO,EAC9B,CAAE,KAAM,cAAe,OAAQA,EAAQ,YAAa,OAAQ,EAC5D,CAAE,KAAM,WAAY,OAAQA,EAAQ,YAAa,OAAQ,EACzD,CAAE,KAAM,MAAO,OAAQ,EAAK,EAC5B,CAAE,KAAM,OAAQ,OAAQ,EAAK,EAC7B,CAAE,KAAM,OAAQ,OAAQ,GAAM,YAAa,OAAQ,EACnD,CAAE,KAAM,OAAQ,OAAQ,CAAC,OAAO,EAAG,YAAa,OAAQ,CAC5D,EAEME,EAAyC,CAC3C,CAAE,KAAM,QAAS,OAAQF,EAAQ,YAAa,OAAQ,EACtD,CAAE,KAAM,MAAO,OAAQA,CAAO,EAC9B,CAAE,KAAM,MAAO,OAAQA,CAAO,EAC9B,CAAE,KAAM,MAAO,OAAQ,EAAK,EAC5B,CAAE,KAAM,OAAQ,OAAQ,EAAK,CACjC,EAEMG,EAAa,CACf,KACA,KACA,mBACA,uBACA,KACA,KACA,IACA,IACA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"duckdbTypeToPsp", "name", "convertDecimalToNumber", "value", "dtypeString", "bigIntValue", "i", "scaleMatch", "scale", "Lock", "releaseLock", "newLockPromise", "resolve", "acquirePromise", "LOCK", "runQuery", "db", "query", "options", "release", "result", "data", "meta", "f", "error", "ClickhouseHandler", "mod", "viewer_class", "row", "tableId", "config", "results", "schema", "colName", "viewId", "gs", "count", "expression", "viewport", "dataSlice", "rows", "columns", "dtypes", "cidx", "col", "dtype", "isDecimal", "ridx", "grouping_id"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d=["sum","count","any_value","arbitrary","array_agg","avg","bit_and","bit_or","bit_xor","bitstring_agg","bool_and","bool_or","countif","favg","fsum","geomean","kahan_sum","last","max","min","product","string_agg","sumkahan"],p=["count","any_value","arbitrary","first","countif","last","string_agg"],n=["rows","range","cumulative"],y=[{name:"sum",frames:n,result_type:"float"},{name:"avg",frames:n,result_type:"float"},{name:"count",frames:n,result_type:"float"},{name:"min",frames:n},{name:"max",frames:n},{name:"product",frames:n,result_type:"float"},{name:"median",frames:n,result_type:"float"},{name:"stddev_samp",frames:n,result_type:"float"},{name:"stddev_pop",frames:n,result_type:"float"},{name:"var_samp",frames:n,result_type:"float"},{name:"var_pop",frames:n,result_type:"float"},{name:"first_value",frames:n},{name:"last_value",frames:n},{name:"nth_value",frames:n,offset:!0},{name:"lag",offset:!0},{name:"lead",offset:!0},{name:"row_number",result_type:"float"},{name:"rank",result_type:"float"},{name:"dense_rank",result_type:"float"},{name:"percent_rank",result_type:"float"},{name:"cume_dist",result_type:"float"},{name:"ntile",offset:!0,result_type:"float"},{name:"diff",offset:!0,result_type:"float"},{name:"rate",frames:["range"],result_type:"float"}],f=[{name:"count",frames:n,result_type:"float"},{name:"min",frames:n},{name:"max",frames:n},{name:"first_value",frames:n},{name:"last_value",frames:n},{name:"nth_value",frames:n,offset:!0},{name:"lag",offset:!0},{name:"lead",offset:!0},{name:"row_number",result_type:"float"},{name:"rank",result_type:"float"},{name:"dense_rank",result_type:"float"},{name:"percent_rank",result_type:"float"},{name:"cume_dist",result_type:"float"},{name:"ntile",offset:!0,result_type:"float"}],m=["==","!=","IS DISTINCT FROM","IS NOT DISTINCT FROM",">=","<=",">","<","is null","is not null"],w=[...m,"begins with","not begins with","contains","not contains","ends with","not ends with","matches","not matches","in","not in","LIKE","NOT LIKE","ILIKE","NOT ILIKE"];function g(t){return t=t.toLowerCase(),t.startsWith("bool")?"boolean":["tinyint","smallint","integer","utinyint","usmallint"].includes(t)||["int8","int16","int32","uint8","uint16"].includes(t)?"integer":["bigint","hugeint","uhugeint","uinteger","ubigint"].includes(t)||["float","real","double","varint"].includes(t)||["int64","uint32","uint64","float32","float64"].includes(t)||t.startsWith("decimal")||t.startsWith("numeric")?"float":t.startsWith("date")?"date":t.startsWith("time")?"datetime":(t.startsWith("varchar")||t==="utf8"||t.startsWith("enum")||["json","uuid","blob","bit","interval"].includes(t)||t.startsWith("struct")||t.startsWith("map")||t.startsWith("union")||t.endsWith("[]")||console.warn(`Unknown type '${t}'`),"string")}async function u(t,s,r={}){s=s.replace(/\s+/g," ").trim();try{let e=await t.query(s);return r.columns?{rows:e.toArray(),columns:e.schema.fields.map(i=>i.name),dtypes:e.schema.fields.map(i=>i.type.toString())}:e.toArray()}catch(e){throw console.error("Query error:",e),console.error("Query:",s),e}}var _=class{db;sqlBuilder;constructor(s,r){if(!r&&customElements){let e=customElements.get("perspective-viewer");if(e)r=e.__wasm_module__;else throw new Error("Missing perspective-client.wasm")}this.db=s,this.sqlBuilder=new r.GenericSQLVirtualServerModel({column_separator:"|",like_escape_clause:"\\",regex_fn:"regexp_matches"})}getFeatures(){return{group_by:!0,split_by:!0,sort:!0,expressions:!0,window_aggregates:{integer:y,float:y,string:f,date:f,datetime:f,boolean:f},group_rollup_mode:["rollup","flat","total"],split_rollup_mode:["flat","rollup"],filter_ops:{integer:m,float:m,string:w,boolean:m,date:m,datetime:m},aggregates:{integer:d,float:d,string:p,boolean:p,date:p,datetime:p}}}async getHostedTables(){let s=this.sqlBuilder.getHostedTables();return(await u(this.db,s)).map(e=>{let i=e.toJSON();return`${i.database||"memory"}.${i.name}`})}async tableSchema(s,r){let e=this.sqlBuilder.tableSchema(s),i=await u(this.db,e),c={};for(let o of i){let a=o.toJSON(),l=a.column_name;l.startsWith("__")||(c[l]=g(a.column_type))}return c}async viewColumnSize(s,r){let e=this.sqlBuilder.viewColumnSize(s),i=await u(this.db,e),c=Number(Object.values(i[0].toJSON())[0]),o=r.group_by?.length||0,a=r.group_rollup_mode==="flat";return c-(o===0?0:a?o:o+1)}async tableSize(s){let r=this.sqlBuilder.tableSize(s),e=await u(this.db,r);return Number(e[0].toJSON()["count_star()"])}async tableMakeView(s,r,e){let i=this.sqlBuilder.tableMakeView(s,r,e);await u(this.db,i)}async tableValidateExpression(s,r){let e=this.sqlBuilder.tableValidateExpression(s,r),i=await u(this.db,e);return g(i[0].toJSON().column_type)}async viewDelete(s){let r=this.sqlBuilder.viewDelete(s);await u(this.db,r)}async viewGetMinMax(s,r,e){let i=this.sqlBuilder.viewGetMinMax(s,r,e),o=(await u(this.db,i))[0].toJSON(),[a,l]=Object.values(o);return typeof a=="bigint"&&(a=Number(a)),typeof l=="bigint"&&(l=Number(l)),{min:a??null,max:l??null}}async viewGetData(s,r,e,i,c){let o=this.sqlBuilder.viewGetData(s,r,i,e),a=await this.db.useUnsafe((l,b)=>l.runQuery(b,o));c.fromArrowIpc(a)}};export{_ as DuckDBHandler};
|
|
2
2
|
//# sourceMappingURL=duckdb.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ts/virtual_servers/duckdb.ts"],
|
|
4
|
-
"sourcesContent": ["// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * An implementation of a Perspective Virtual Server for DuckDB.\n *\n * This import is optional, and so must be imported manually from either\n * `@perspective-dev/client/dist/esm/virtual_servers/duckdb.js` or\n * `@perspective-dev/client/src/ts/virtual_servers/duckdb.ts`, it is not\n * exported from the package root `@perspective-dev/client`\n *\n * @module\n */\n\nimport type * as perspective from \"@perspective-dev/client\";\nimport type { ColumnType } from \"@perspective-dev/client/dist/esm/ts-rs/ColumnType.d.ts\";\nimport type { ViewConfig } from \"@perspective-dev/client/dist/esm/ts-rs/ViewConfig.d.ts\";\nimport type { ViewConfigUpdate } from \"@perspective-dev/client/dist/esm/ts-rs/ViewConfigUpdate.d.ts\";\nimport type { ViewWindow } from \"@perspective-dev/client/dist/esm/ts-rs/ViewWindow.d.ts\";\nimport type { WindowAggregate } from \"@perspective-dev/client/dist/esm/ts-rs/WindowAggregate.d.ts\";\nimport type { Scalar } from \"@perspective-dev/client/dist/esm/ts-rs/Scalar.d.ts\";\nimport type * as duckdb from \"@duckdb/duckdb-wasm\";\n\nconst NUMBER_AGGS = [\n \"sum\",\n \"count\",\n \"any_value\",\n \"arbitrary\",\n \"array_agg\",\n \"avg\",\n \"bit_and\",\n \"bit_or\",\n \"bit_xor\",\n \"bitstring_agg\",\n \"bool_and\",\n \"bool_or\",\n \"countif\",\n \"favg\",\n \"fsum\",\n \"geomean\",\n \"kahan_sum\",\n \"last\",\n \"max\",\n \"min\",\n \"product\",\n \"string_agg\",\n \"sumkahan\",\n];\n\nconst STRING_AGGS = [\n \"count\",\n \"any_value\",\n \"arbitrary\",\n \"first\",\n \"countif\",\n \"last\",\n \"string_agg\",\n];\n\n// The window aggregates the SQL translation supports, per source\n// column type (`ema` is recursive - no SQL window equivalent).\nconst WINDOW_AGGREGATES: WindowAggregate[] = [\n \"sum\",\n \"avg\",\n \"count\",\n \"min\",\n \"max\",\n \"stddev\",\n \"var\",\n \"lag\",\n \"lead\",\n \"diff\",\n \"rate\",\n];\n\nconst WINDOW_AGGREGATES_ANY: WindowAggregate[] = [\n \"count\",\n \"min\",\n \"max\",\n \"lag\",\n \"lead\",\n];\n\nconst FILTER_OPS = [\n \"==\",\n \"!=\",\n \"LIKE\",\n \"IS DISTINCT FROM\",\n \"IS NOT DISTINCT FROM\",\n \">=\",\n \"<=\",\n \">\",\n \"<\",\n];\n\nfunction duckdbTypeToPsp(name: string): ColumnType {\n name = name.toLowerCase();\n if (name === \"varchar\" || name == \"utf8\") {\n return \"string\";\n }\n\n if (\n name === \"double\" ||\n name === \"bigint\" ||\n name === \"hugeint\" ||\n name === \"float64\" ||\n name.startsWith(\"decimal\")\n ) {\n return \"float\";\n }\n\n if (name.startsWith(\"int\")) {\n return \"integer\";\n }\n\n if (name.startsWith(\"date\")) {\n return \"date\";\n }\n\n if (name.startsWith(\"bool\")) {\n return \"boolean\";\n }\n\n if (name.startsWith(\"timestamp\")) {\n return \"datetime\";\n }\n\n if (name.startsWith(\"json\")) {\n return \"string\";\n }\n\n if (name.startsWith(\"struct\")) {\n return \"string\";\n }\n\n if (name.startsWith(\"time\")) {\n return \"float\";\n }\n\n console.warn(`Unknown type '${name}'`);\n return \"string\";\n}\n\nasync function runQuery(\n db: duckdb.AsyncDuckDBConnection,\n query: string,\n options: { columns: true },\n): Promise<{\n rows: any[];\n columns: string[];\n dtypes: string[];\n}>;\n\nasync function runQuery(\n db: duckdb.AsyncDuckDBConnection,\n query: string,\n options?: { columns: false },\n): Promise<any[]>;\n\nasync function runQuery(\n db: duckdb.AsyncDuckDBConnection,\n query: string,\n options: { columns?: boolean } = {},\n) {\n query = query.replace(/\\s+/g, \" \").trim();\n try {\n const result = await db.query(query);\n if (options.columns) {\n return {\n rows: result.toArray(),\n columns: result.schema.fields.map((f) => f.name),\n dtypes: result.schema.fields.map((f) => f.type.toString()),\n };\n }\n\n return result.toArray();\n } catch (error) {\n console.error(\"Query error:\", error);\n console.error(\"Query:\", query);\n throw error;\n }\n}\n\n/**\n * An implementation of Perspective's Virtual Server for `@duckdb/duckdb-wasm`.\n */\nexport class DuckDBHandler implements perspective.VirtualServerHandler {\n private db: duckdb.AsyncDuckDBConnection;\n private sqlBuilder: perspective.GenericSQLVirtualServerModel;\n constructor(db: duckdb.AsyncDuckDBConnection, mod?: typeof perspective) {\n if (!mod) {\n if (customElements) {\n const viewer_class: any =\n customElements.get(\"perspective-viewer\");\n if (viewer_class) {\n mod = viewer_class.__wasm_module__;\n } else {\n throw new Error(\"Missing perspective-client.wasm\");\n }\n } else {\n }\n }\n\n this.db = db;\n this.sqlBuilder = new mod!.GenericSQLVirtualServerModel({\n column_separator: \"|\",\n });\n }\n\n getFeatures(): perspective.Features {\n return {\n group_by: true,\n split_by: true,\n sort: true,\n expressions: true,\n window_aggregates: {\n // `ema` is recursive and has no SQL window translation.\n integer: WINDOW_AGGREGATES,\n float: WINDOW_AGGREGATES,\n string: WINDOW_AGGREGATES_ANY,\n date: WINDOW_AGGREGATES_ANY,\n datetime: WINDOW_AGGREGATES_ANY,\n boolean: WINDOW_AGGREGATES_ANY,\n },\n group_rollup_mode: [\"rollup\", \"flat\", \"total\"],\n filter_ops: {\n integer: FILTER_OPS,\n float: FILTER_OPS,\n string: FILTER_OPS,\n boolean: FILTER_OPS,\n date: FILTER_OPS,\n datetime: FILTER_OPS,\n },\n aggregates: {\n integer: NUMBER_AGGS,\n float: NUMBER_AGGS,\n string: STRING_AGGS,\n boolean: STRING_AGGS,\n date: STRING_AGGS,\n datetime: STRING_AGGS,\n },\n };\n }\n\n async getHostedTables() {\n const query = this.sqlBuilder.getHostedTables();\n const results = await runQuery(this.db, query);\n return results.map((row) => {\n const json = row.toJSON();\n return `${json.database || \"memory\"}.${json.name}`;\n });\n }\n\n async tableSchema(tableId: string, config?: ViewConfig) {\n const query = this.sqlBuilder.tableSchema(tableId);\n const results = await runQuery(this.db, query);\n const schema = {} as Record<string, ColumnType>;\n for (const result of results) {\n const res = result.toJSON();\n const colName = res.column_name;\n if (!colName.startsWith(\"__\")) {\n schema[colName] = duckdbTypeToPsp(\n res.column_type,\n ) as ColumnType;\n }\n }\n\n return schema;\n }\n\n async viewColumnSize(viewId: string, config: ViewConfig) {\n const query = this.sqlBuilder.viewColumnSize(viewId);\n const results = await runQuery(this.db, query);\n const count = Number(Object.values(results[0].toJSON())[0]);\n const gs = config.group_by?.length || 0;\n const is_flat = config.group_rollup_mode === \"flat\";\n return count - (gs === 0 ? 0 : is_flat ? gs : gs + 1);\n }\n\n async tableSize(tableId: string) {\n const query = this.sqlBuilder.tableSize(tableId);\n const results = await runQuery(this.db, query);\n return Number(results[0].toJSON()[\"count_star()\"]);\n }\n\n async tableMakeView(\n tableId: string,\n viewId: string,\n config: ViewConfigUpdate,\n ) {\n const query = this.sqlBuilder.tableMakeView(tableId, viewId, config);\n await runQuery(this.db, query);\n }\n\n async tableValidateExpression(tableId: string, expression: string) {\n const query = this.sqlBuilder.tableValidateExpression(\n tableId,\n expression,\n );\n const results = await runQuery(this.db, query);\n return duckdbTypeToPsp(\n results[0].toJSON()[\"column_type\"],\n ) as ColumnType;\n }\n\n async viewDelete(viewId: string) {\n const query = this.sqlBuilder.viewDelete(viewId);\n await runQuery(this.db, query);\n }\n\n async viewGetMinMax(\n viewId: string,\n columnName: string,\n config: ViewConfig,\n ) {\n const query = this.sqlBuilder.viewGetMinMax(viewId, columnName, config);\n const results = await runQuery(this.db, query);\n const row = results[0].toJSON();\n let [min, max] = Object.values(row);\n if (typeof min === \"bigint\") min = Number(min);\n if (typeof max === \"bigint\") max = Number(max);\n return { min: (min ?? null) as Scalar, max: (max ?? null) as Scalar };\n }\n\n async viewGetData(\n viewId: string,\n config: ViewConfig,\n schema: Record<string, ColumnType>,\n viewport: ViewWindow,\n dataSlice: perspective.VirtualDataSlice,\n ) {\n const query = this.sqlBuilder.viewGetData(\n viewId,\n config,\n viewport,\n schema,\n );\n\n const ipc = await this.db.useUnsafe((bindings, conn) =>\n bindings.runQuery(conn, query),\n );\n\n dataSlice.fromArrowIpc(ipc);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAgCA,IAAMA,EAAc,CAChB,MACA,QACA,YACA,YACA,YACA,MACA,UACA,SACA,UACA,gBACA,WACA,UACA,UACA,OACA,OACA,UACA,YACA,OACA,MACA,MACA,UACA,aACA,UACJ,EAEMC,EAAc,CAChB,QACA,YACA,YACA,QACA,UACA,OACA,YACJ,
|
|
6
|
-
"names": ["NUMBER_AGGS", "STRING_AGGS", "WINDOW_AGGREGATES", "WINDOW_AGGREGATES_ANY", "FILTER_OPS", "duckdbTypeToPsp", "name", "runQuery", "db", "query", "options", "result", "f", "error", "DuckDBHandler", "mod", "viewer_class", "row", "json", "tableId", "config", "results", "schema", "res", "colName", "viewId", "count", "gs", "is_flat", "expression", "columnName", "min", "max", "viewport", "dataSlice", "ipc", "bindings", "conn"]
|
|
4
|
+
"sourcesContent": ["// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * An implementation of a Perspective Virtual Server for DuckDB.\n *\n * This import is optional, and so must be imported manually from either\n * `@perspective-dev/client/dist/esm/virtual_servers/duckdb.js` or\n * `@perspective-dev/client/src/ts/virtual_servers/duckdb.ts`, it is not\n * exported from the package root `@perspective-dev/client`\n *\n * @module\n */\n\nimport type * as perspective from \"@perspective-dev/client\";\nimport type { ColumnType } from \"@perspective-dev/client/dist/esm/ts-rs/ColumnType.d.ts\";\nimport type { ViewConfig } from \"@perspective-dev/client/dist/esm/ts-rs/ViewConfig.d.ts\";\nimport type { ViewConfigUpdate } from \"@perspective-dev/client/dist/esm/ts-rs/ViewConfigUpdate.d.ts\";\nimport type { ViewWindow } from \"@perspective-dev/client/dist/esm/ts-rs/ViewWindow.d.ts\";\nimport type { WindowAggSpec } from \"@perspective-dev/client/dist/esm/ts-rs/WindowAggSpec.d.ts\";\nimport type { Scalar } from \"@perspective-dev/client/dist/esm/ts-rs/Scalar.d.ts\";\nimport type * as duckdb from \"@duckdb/duckdb-wasm\";\n\nconst NUMBER_AGGS = [\n \"sum\",\n \"count\",\n \"any_value\",\n \"arbitrary\",\n \"array_agg\",\n \"avg\",\n \"bit_and\",\n \"bit_or\",\n \"bit_xor\",\n \"bitstring_agg\",\n \"bool_and\",\n \"bool_or\",\n \"countif\",\n \"favg\",\n \"fsum\",\n \"geomean\",\n \"kahan_sum\",\n \"last\",\n \"max\",\n \"min\",\n \"product\",\n \"string_agg\",\n \"sumkahan\",\n];\n\nconst STRING_AGGS = [\n \"count\",\n \"any_value\",\n \"arbitrary\",\n \"first\",\n \"countif\",\n \"last\",\n \"string_agg\",\n];\n\nconst FRAMES = [\"rows\", \"range\", \"cumulative\"];\n\nconst WINDOW_AGGREGATES: WindowAggSpec[] = [\n { name: \"sum\", frames: FRAMES, result_type: \"float\" },\n { name: \"avg\", frames: FRAMES, result_type: \"float\" },\n { name: \"count\", frames: FRAMES, result_type: \"float\" },\n { name: \"min\", frames: FRAMES },\n { name: \"max\", frames: FRAMES },\n { name: \"product\", frames: FRAMES, result_type: \"float\" },\n { name: \"median\", frames: FRAMES, result_type: \"float\" },\n // DuckDB spells sample and population variants separately, so both are\n // offered rather than one being picked on the user's behalf.\n { name: \"stddev_samp\", frames: FRAMES, result_type: \"float\" },\n { name: \"stddev_pop\", frames: FRAMES, result_type: \"float\" },\n { name: \"var_samp\", frames: FRAMES, result_type: \"float\" },\n { name: \"var_pop\", frames: FRAMES, result_type: \"float\" },\n // Navigation.\n { name: \"first_value\", frames: FRAMES },\n { name: \"last_value\", frames: FRAMES },\n { name: \"nth_value\", frames: FRAMES, offset: true },\n { name: \"lag\", offset: true },\n { name: \"lead\", offset: true },\n // Ranking. These take no source column - the window's `order_by` is their\n // input - but Perspective requires one, so the choice of source is\n // immaterial for them.\n { name: \"row_number\", result_type: \"float\" },\n { name: \"rank\", result_type: \"float\" },\n { name: \"dense_rank\", result_type: \"float\" },\n { name: \"percent_rank\", result_type: \"float\" },\n { name: \"cume_dist\", result_type: \"float\" },\n // `ntile`'s argument is a bucket count rather than a row offset.\n { name: \"ntile\", offset: true, result_type: \"float\" },\n // Perspective's own, with no DuckDB equivalent - the SQL translation\n // synthesizes them from `lag` and `first_value`.\n { name: \"diff\", offset: true, result_type: \"float\" },\n { name: \"rate\", frames: [\"range\"], result_type: \"float\" },\n];\n\n// Arithmetic is undefined for the non-numeric types; ordering and navigation\n// are not.\nconst WINDOW_AGGREGATES_ANY: WindowAggSpec[] = [\n { name: \"count\", frames: FRAMES, result_type: \"float\" },\n { name: \"min\", frames: FRAMES },\n { name: \"max\", frames: FRAMES },\n { name: \"first_value\", frames: FRAMES },\n { name: \"last_value\", frames: FRAMES },\n { name: \"nth_value\", frames: FRAMES, offset: true },\n { name: \"lag\", offset: true },\n { name: \"lead\", offset: true },\n { name: \"row_number\", result_type: \"float\" },\n { name: \"rank\", result_type: \"float\" },\n { name: \"dense_rank\", result_type: \"float\" },\n { name: \"percent_rank\", result_type: \"float\" },\n { name: \"cume_dist\", result_type: \"float\" },\n { name: \"ntile\", offset: true, result_type: \"float\" },\n];\n\nconst FILTER_OPS = [\n \"==\",\n \"!=\",\n \"IS DISTINCT FROM\",\n \"IS NOT DISTINCT FROM\",\n \">=\",\n \"<=\",\n \">\",\n \"<\",\n \"is null\",\n \"is not null\",\n];\n\n// Perspective's canonical string ops (translated to `ILIKE` / `regexp_matches`\n// by the SQL builder), plus DuckDB's raw infix pattern ops spliced verbatim.\nconst STRING_FILTER_OPS = [\n ...FILTER_OPS,\n \"begins with\",\n \"not begins with\",\n \"contains\",\n \"not contains\",\n \"ends with\",\n \"not ends with\",\n \"matches\",\n \"not matches\",\n \"in\",\n \"not in\",\n \"LIKE\",\n \"NOT LIKE\",\n \"ILIKE\",\n \"NOT ILIKE\",\n];\n\n/**\n * Convert a DuckDB `dtype` to a Perspective `ColumnType`.\n */\nfunction duckdbTypeToPsp(name: string): ColumnType {\n name = name.toLowerCase();\n\n if (name.startsWith(\"bool\")) {\n return \"boolean\";\n }\n\n // 32-bit and narrower - `coerce_column` widens these to `Int32`.\n if (\n [\"tinyint\", \"smallint\", \"integer\", \"utinyint\", \"usmallint\"].includes(\n name,\n ) ||\n [\"int8\", \"int16\", \"int32\", \"uint8\", \"uint16\"].includes(name)\n ) {\n return \"integer\";\n }\n\n // Wider than `Int32`, or fractional - all coerce to `Float64`.\n if (\n [\"bigint\", \"hugeint\", \"uhugeint\", \"uinteger\", \"ubigint\"].includes(\n name,\n ) ||\n [\"float\", \"real\", \"double\", \"varint\"].includes(name) ||\n [\"int64\", \"uint32\", \"uint64\", \"float32\", \"float64\"].includes(name) ||\n name.startsWith(\"decimal\") ||\n name.startsWith(\"numeric\")\n ) {\n return \"float\";\n }\n\n if (name.startsWith(\"date\")) {\n return \"date\";\n }\n\n // `timestamp`, `timestamptz`, `timestamp_ns`, and `time`/`timetz`,\n // which coerce to `Timestamp(Millisecond)` rather than to a number.\n if (name.startsWith(\"time\")) {\n return \"datetime\";\n }\n\n // Everything else renders as text: `varchar`, `enum(...)` (which\n // arrives dictionary-encoded), `json`, `uuid`, `blob`, `interval`,\n // and the nested types.\n if (\n !(\n name.startsWith(\"varchar\") ||\n name === \"utf8\" ||\n name.startsWith(\"enum\") ||\n [\"json\", \"uuid\", \"blob\", \"bit\", \"interval\"].includes(name) ||\n name.startsWith(\"struct\") ||\n name.startsWith(\"map\") ||\n name.startsWith(\"union\") ||\n name.endsWith(\"[]\")\n )\n ) {\n // Unknown, not fatal - the column still renders, as text.\n console.warn(`Unknown type '${name}'`);\n }\n\n return \"string\";\n}\n\nasync function runQuery(\n db: duckdb.AsyncDuckDBConnection,\n query: string,\n options: { columns: true },\n): Promise<{\n rows: any[];\n columns: string[];\n dtypes: string[];\n}>;\n\nasync function runQuery(\n db: duckdb.AsyncDuckDBConnection,\n query: string,\n options?: { columns: false },\n): Promise<any[]>;\n\nasync function runQuery(\n db: duckdb.AsyncDuckDBConnection,\n query: string,\n options: { columns?: boolean } = {},\n) {\n query = query.replace(/\\s+/g, \" \").trim();\n try {\n const result = await db.query(query);\n if (options.columns) {\n return {\n rows: result.toArray(),\n columns: result.schema.fields.map((f) => f.name),\n dtypes: result.schema.fields.map((f) => f.type.toString()),\n };\n }\n\n return result.toArray();\n } catch (error) {\n console.error(\"Query error:\", error);\n console.error(\"Query:\", query);\n throw error;\n }\n}\n\n/**\n * An implementation of Perspective's Virtual Server for `@duckdb/duckdb-wasm`.\n */\nexport class DuckDBHandler implements perspective.VirtualServerHandler {\n private db: duckdb.AsyncDuckDBConnection;\n private sqlBuilder: perspective.GenericSQLVirtualServerModel;\n constructor(db: duckdb.AsyncDuckDBConnection, mod?: typeof perspective) {\n if (!mod) {\n if (customElements) {\n const viewer_class: any =\n customElements.get(\"perspective-viewer\");\n if (viewer_class) {\n mod = viewer_class.__wasm_module__;\n } else {\n throw new Error(\"Missing perspective-client.wasm\");\n }\n } else {\n }\n }\n\n this.db = db;\n this.sqlBuilder = new mod!.GenericSQLVirtualServerModel({\n column_separator: \"|\",\n like_escape_clause: \"\\\\\",\n regex_fn: \"regexp_matches\",\n });\n }\n\n getFeatures(): perspective.Features {\n return {\n group_by: true,\n split_by: true,\n sort: true,\n expressions: true,\n window_aggregates: {\n // `ema` is recursive and has no SQL window translation.\n integer: WINDOW_AGGREGATES,\n float: WINDOW_AGGREGATES,\n string: WINDOW_AGGREGATES_ANY,\n date: WINDOW_AGGREGATES_ANY,\n datetime: WINDOW_AGGREGATES_ANY,\n boolean: WINDOW_AGGREGATES_ANY,\n },\n group_rollup_mode: [\"rollup\", \"flat\", \"total\"],\n split_rollup_mode: [\"flat\", \"rollup\"],\n filter_ops: {\n integer: FILTER_OPS,\n float: FILTER_OPS,\n string: STRING_FILTER_OPS,\n boolean: FILTER_OPS,\n date: FILTER_OPS,\n datetime: FILTER_OPS,\n },\n aggregates: {\n integer: NUMBER_AGGS,\n float: NUMBER_AGGS,\n string: STRING_AGGS,\n boolean: STRING_AGGS,\n date: STRING_AGGS,\n datetime: STRING_AGGS,\n },\n };\n }\n\n async getHostedTables() {\n const query = this.sqlBuilder.getHostedTables();\n const results = await runQuery(this.db, query);\n return results.map((row) => {\n const json = row.toJSON();\n return `${json.database || \"memory\"}.${json.name}`;\n });\n }\n\n async tableSchema(tableId: string, config?: ViewConfig) {\n const query = this.sqlBuilder.tableSchema(tableId);\n const results = await runQuery(this.db, query);\n const schema = {} as Record<string, ColumnType>;\n for (const result of results) {\n const res = result.toJSON();\n const colName = res.column_name;\n if (!colName.startsWith(\"__\")) {\n schema[colName] = duckdbTypeToPsp(\n res.column_type,\n ) as ColumnType;\n }\n }\n\n return schema;\n }\n\n async viewColumnSize(viewId: string, config: ViewConfig) {\n const query = this.sqlBuilder.viewColumnSize(viewId);\n const results = await runQuery(this.db, query);\n const count = Number(Object.values(results[0].toJSON())[0]);\n const gs = config.group_by?.length || 0;\n const is_flat = config.group_rollup_mode === \"flat\";\n return count - (gs === 0 ? 0 : is_flat ? gs : gs + 1);\n }\n\n async tableSize(tableId: string) {\n const query = this.sqlBuilder.tableSize(tableId);\n const results = await runQuery(this.db, query);\n return Number(results[0].toJSON()[\"count_star()\"]);\n }\n\n async tableMakeView(\n tableId: string,\n viewId: string,\n config: ViewConfigUpdate,\n ) {\n const query = this.sqlBuilder.tableMakeView(tableId, viewId, config);\n await runQuery(this.db, query);\n }\n\n async tableValidateExpression(tableId: string, expression: string) {\n const query = this.sqlBuilder.tableValidateExpression(\n tableId,\n expression,\n );\n const results = await runQuery(this.db, query);\n return duckdbTypeToPsp(\n results[0].toJSON()[\"column_type\"],\n ) as ColumnType;\n }\n\n async viewDelete(viewId: string) {\n const query = this.sqlBuilder.viewDelete(viewId);\n await runQuery(this.db, query);\n }\n\n async viewGetMinMax(\n viewId: string,\n columnName: string,\n config: ViewConfig,\n ) {\n const query = this.sqlBuilder.viewGetMinMax(viewId, columnName, config);\n const results = await runQuery(this.db, query);\n const row = results[0].toJSON();\n let [min, max] = Object.values(row);\n if (typeof min === \"bigint\") min = Number(min);\n if (typeof max === \"bigint\") max = Number(max);\n return { min: (min ?? null) as Scalar, max: (max ?? null) as Scalar };\n }\n\n async viewGetData(\n viewId: string,\n config: ViewConfig,\n schema: Record<string, ColumnType>,\n viewport: ViewWindow,\n dataSlice: perspective.VirtualDataSlice,\n ) {\n const query = this.sqlBuilder.viewGetData(\n viewId,\n config,\n viewport,\n schema,\n );\n\n const ipc = await this.db.useUnsafe((bindings, conn) =>\n bindings.runQuery(conn, query),\n );\n\n dataSlice.fromArrowIpc(ipc);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAgCA,IAAMA,EAAc,CAChB,MACA,QACA,YACA,YACA,YACA,MACA,UACA,SACA,UACA,gBACA,WACA,UACA,UACA,OACA,OACA,UACA,YACA,OACA,MACA,MACA,UACA,aACA,UACJ,EAEMC,EAAc,CAChB,QACA,YACA,YACA,QACA,UACA,OACA,YACJ,EAEMC,EAAS,CAAC,OAAQ,QAAS,YAAY,EAEvCC,EAAqC,CACvC,CAAE,KAAM,MAAO,OAAQD,EAAQ,YAAa,OAAQ,EACpD,CAAE,KAAM,MAAO,OAAQA,EAAQ,YAAa,OAAQ,EACpD,CAAE,KAAM,QAAS,OAAQA,EAAQ,YAAa,OAAQ,EACtD,CAAE,KAAM,MAAO,OAAQA,CAAO,EAC9B,CAAE,KAAM,MAAO,OAAQA,CAAO,EAC9B,CAAE,KAAM,UAAW,OAAQA,EAAQ,YAAa,OAAQ,EACxD,CAAE,KAAM,SAAU,OAAQA,EAAQ,YAAa,OAAQ,EAGvD,CAAE,KAAM,cAAe,OAAQA,EAAQ,YAAa,OAAQ,EAC5D,CAAE,KAAM,aAAc,OAAQA,EAAQ,YAAa,OAAQ,EAC3D,CAAE,KAAM,WAAY,OAAQA,EAAQ,YAAa,OAAQ,EACzD,CAAE,KAAM,UAAW,OAAQA,EAAQ,YAAa,OAAQ,EAExD,CAAE,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F,CACE,IAAMX,EAAQ,KAAK,WAAW,cAAcgB,EAAQK,EAAYV,CAAM,EAEhEH,GADU,MAAMV,EAAS,KAAK,GAAIE,CAAK,GACzB,CAAC,EAAE,OAAO,EAC1B,CAACsB,EAAKC,CAAG,EAAI,OAAO,OAAOf,CAAG,EAClC,OAAI,OAAOc,GAAQ,WAAUA,EAAM,OAAOA,CAAG,GACzC,OAAOC,GAAQ,WAAUA,EAAM,OAAOA,CAAG,GACtC,CAAE,IAAMD,GAAO,KAAiB,IAAMC,GAAO,IAAgB,CACxE,CAEA,MAAM,YACFP,EACAL,EACAE,EACAW,EACAC,EACF,CACE,IAAMzB,EAAQ,KAAK,WAAW,YAC1BgB,EACAL,EACAa,EACAX,CACJ,EAEMa,EAAM,MAAM,KAAK,GAAG,UAAU,CAACC,EAAUC,IAC3CD,EAAS,SAASC,EAAM5B,CAAK,CACjC,EAEAyB,EAAU,aAAaC,CAAG,CAC9B,CACJ",
|
|
6
|
+
"names": ["NUMBER_AGGS", "STRING_AGGS", "FRAMES", "WINDOW_AGGREGATES", "WINDOW_AGGREGATES_ANY", "FILTER_OPS", "STRING_FILTER_OPS", "duckdbTypeToPsp", "name", "runQuery", "db", "query", "options", "result", "f", "error", "DuckDBHandler", "mod", "viewer_class", "row", "json", "tableId", "config", "results", "schema", "res", "colName", "viewId", "count", "gs", "is_flat", "expression", "columnName", "min", "max", "viewport", "dataSlice", "ipc", "bindings", "conn"]
|
|
7
7
|
}
|
|
@@ -104,7 +104,7 @@ export type * from "../../src/ts/ts-rs/JoinType.ts";
|
|
|
104
104
|
export type * from "../../src/ts/ts-rs/TypedArrayWindow.ts";
|
|
105
105
|
export type * from "../../src/ts/ts-rs/Features.ts";
|
|
106
106
|
export type * from "../../src/ts/ts-rs/AggSpec.ts";
|
|
107
|
-
export type * from "../../src/ts/ts-rs/
|
|
107
|
+
export type * from "../../src/ts/ts-rs/WindowAggSpec.ts";
|
|
108
108
|
|
|
109
109
|
import type {ColumnWindow} from "../../src/ts/ts-rs/ColumnWindow.d.ts";
|
|
110
110
|
import type {ColumnType} from "../../src/ts/ts-rs/ColumnType.d.ts";
|
|
@@ -964,11 +964,11 @@ export interface InitOutput {
|
|
|
964
964
|
readonly virtualdataslice_setStringCol: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
965
965
|
readonly virtualserver_handleRequest: (a: number, b: number, c: number) => number;
|
|
966
966
|
readonly virtualserver_new: (a: number, b: number) => void;
|
|
967
|
-
readonly
|
|
968
|
-
readonly
|
|
969
|
-
readonly
|
|
970
|
-
readonly
|
|
971
|
-
readonly
|
|
967
|
+
readonly __wasm_bindgen_func_elem_1146: (a: number, b: number) => void;
|
|
968
|
+
readonly __wasm_bindgen_func_elem_4239: (a: number, b: number) => void;
|
|
969
|
+
readonly __wasm_bindgen_func_elem_12398: (a: number, b: number, c: number, d: number) => void;
|
|
970
|
+
readonly __wasm_bindgen_func_elem_4256: (a: number, b: number, c: number) => void;
|
|
971
|
+
readonly __wasm_bindgen_func_elem_1860: (a: number, b: number) => number;
|
|
972
972
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
973
973
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
974
974
|
readonly __wbindgen_export3: (a: number) => void;
|
|
@@ -2016,7 +2016,7 @@ function __wbg_get_imports() {
|
|
|
2016
2016
|
const a = state0.a;
|
|
2017
2017
|
state0.a = 0;
|
|
2018
2018
|
try {
|
|
2019
|
-
return
|
|
2019
|
+
return __wasm_bindgen_func_elem_12398(a, state0.b, arg0, arg1);
|
|
2020
2020
|
} finally {
|
|
2021
2021
|
state0.a = a;
|
|
2022
2022
|
}
|
|
@@ -2175,12 +2175,12 @@ function __wbg_get_imports() {
|
|
|
2175
2175
|
},
|
|
2176
2176
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
2177
2177
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 12, function: Function { arguments: [], shim_idx: 31, ret: NamedExternref("Promise<any>"), inner_ret: Some(NamedExternref("Promise<any>")) }, mutable: false }) -> Externref`.
|
|
2178
|
-
const ret = makeClosure(arg0, arg1, wasm.
|
|
2178
|
+
const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1146, __wasm_bindgen_func_elem_1860);
|
|
2179
2179
|
return addHeapObject(ret);
|
|
2180
2180
|
},
|
|
2181
2181
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2182
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2183
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
2182
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 580, function: Function { arguments: [Externref], shim_idx: 581, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2183
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_4239, __wasm_bindgen_func_elem_4256);
|
|
2184
2184
|
return addHeapObject(ret);
|
|
2185
2185
|
},
|
|
2186
2186
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -2257,17 +2257,17 @@ function __wbg_get_imports() {
|
|
|
2257
2257
|
};
|
|
2258
2258
|
}
|
|
2259
2259
|
|
|
2260
|
-
function
|
|
2261
|
-
const ret = wasm.
|
|
2260
|
+
function __wasm_bindgen_func_elem_1860(arg0, arg1) {
|
|
2261
|
+
const ret = wasm.__wasm_bindgen_func_elem_1860(arg0, arg1);
|
|
2262
2262
|
return takeObject(ret);
|
|
2263
2263
|
}
|
|
2264
2264
|
|
|
2265
|
-
function
|
|
2266
|
-
wasm.
|
|
2265
|
+
function __wasm_bindgen_func_elem_4256(arg0, arg1, arg2) {
|
|
2266
|
+
wasm.__wasm_bindgen_func_elem_4256(arg0, arg1, addHeapObject(arg2));
|
|
2267
2267
|
}
|
|
2268
2268
|
|
|
2269
|
-
function
|
|
2270
|
-
wasm.
|
|
2269
|
+
function __wasm_bindgen_func_elem_12398(arg0, arg1, arg2, arg3) {
|
|
2270
|
+
wasm.__wasm_bindgen_func_elem_12398(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
2271
2271
|
}
|
|
2272
2272
|
|
|
2273
2273
|
const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
Binary file
|
|
@@ -93,11 +93,11 @@ export const virtualdataslice_setIntegerCol: (a: number, b: number, c: number, d
|
|
|
93
93
|
export const virtualdataslice_setStringCol: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
94
94
|
export const virtualserver_handleRequest: (a: number, b: number, c: number) => number;
|
|
95
95
|
export const virtualserver_new: (a: number, b: number) => void;
|
|
96
|
-
export const
|
|
97
|
-
export const
|
|
98
|
-
export const
|
|
99
|
-
export const
|
|
100
|
-
export const
|
|
96
|
+
export const __wasm_bindgen_func_elem_1146: (a: number, b: number) => void;
|
|
97
|
+
export const __wasm_bindgen_func_elem_4239: (a: number, b: number) => void;
|
|
98
|
+
export const __wasm_bindgen_func_elem_12398: (a: number, b: number, c: number, d: number) => void;
|
|
99
|
+
export const __wasm_bindgen_func_elem_4256: (a: number, b: number, c: number) => void;
|
|
100
|
+
export const __wasm_bindgen_func_elem_1860: (a: number, b: number) => number;
|
|
101
101
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
102
102
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
103
103
|
export const __wbindgen_export3: (a: number) => void;
|
package/package.json
CHANGED
package/src/rust/lib.rs
CHANGED
|
@@ -66,7 +66,7 @@ export type * from "../../src/ts/ts-rs/JoinType.ts";
|
|
|
66
66
|
export type * from "../../src/ts/ts-rs/TypedArrayWindow.ts";
|
|
67
67
|
export type * from "../../src/ts/ts-rs/Features.ts";
|
|
68
68
|
export type * from "../../src/ts/ts-rs/AggSpec.ts";
|
|
69
|
-
export type * from "../../src/ts/ts-rs/
|
|
69
|
+
export type * from "../../src/ts/ts-rs/WindowAggSpec.ts";
|
|
70
70
|
|
|
71
71
|
import type {ColumnWindow} from "../../src/ts/ts-rs/ColumnWindow.d.ts";
|
|
72
72
|
import type {ColumnType} from "../../src/ts/ts-rs/ColumnType.d.ts";
|