@perspective-dev/client 4.2.0 → 4.3.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 +3 -3
- 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 +3 -3
- package/dist/esm/perspective.node.js +9 -9
- package/dist/esm/perspective.node.js.map +2 -2
- package/dist/esm/ts-rs/GroupRollupMode.d.ts +1 -0
- package/dist/esm/ts-rs/ViewConfig.d.ts +2 -0
- package/dist/esm/ts-rs/ViewConfigUpdate.d.ts +2 -0
- package/dist/esm/ts-rs/ViewWindow.d.ts +0 -1
- 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.d.ts +1 -0
- 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 +5 -5
- package/dist/wasm/perspective-js.js +11 -11
- 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/utils/futures.rs +1 -6
- package/src/ts/ts-rs/GroupRollupMode.ts +3 -0
- package/src/ts/ts-rs/ViewConfig.ts +2 -1
- package/src/ts/ts-rs/ViewConfigUpdate.ts +2 -1
- package/src/ts/ts-rs/ViewWindow.ts +1 -1
- package/src/ts/virtual_servers/clickhouse.ts +1 -0
- package/src/ts/virtual_servers/duckdb.ts +40 -24
- package/tsconfig.json +1 -0
|
@@ -76,41 +76,47 @@ const FILTER_OPS = [
|
|
|
76
76
|
];
|
|
77
77
|
|
|
78
78
|
function duckdbTypeToPsp(name: string): ColumnType {
|
|
79
|
-
|
|
79
|
+
name = name.toLowerCase();
|
|
80
|
+
if (name === "varchar" || name == "utf8") {
|
|
80
81
|
return "string";
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
if (
|
|
84
|
-
name === "
|
|
85
|
-
name === "
|
|
86
|
-
name === "
|
|
87
|
-
name === "
|
|
88
|
-
name.startsWith("
|
|
85
|
+
name === "double" ||
|
|
86
|
+
name === "bigint" ||
|
|
87
|
+
name === "hugeint" ||
|
|
88
|
+
name === "float64" ||
|
|
89
|
+
name.startsWith("decimal")
|
|
89
90
|
) {
|
|
90
91
|
return "float";
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
if (name.startsWith("
|
|
94
|
+
if (name.startsWith("int")) {
|
|
94
95
|
return "integer";
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
if (name
|
|
98
|
-
return "integer";
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (name === "DATE" || name.startsWith("Date")) {
|
|
98
|
+
if (name.startsWith("date")) {
|
|
102
99
|
return "date";
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
if (name
|
|
102
|
+
if (name.startsWith("bool")) {
|
|
106
103
|
return "boolean";
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
if (name
|
|
106
|
+
if (name.startsWith("timestamp")) {
|
|
110
107
|
return "datetime";
|
|
111
108
|
}
|
|
112
109
|
|
|
113
|
-
|
|
110
|
+
if (name.startsWith("json")) {
|
|
111
|
+
return "string";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (name.startsWith("struct")) {
|
|
115
|
+
return "string";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
console.warn(`Unknown type '${name}'`);
|
|
119
|
+
return "string";
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
function convertDecimalToNumber(value: any, dtypeString: string) {
|
|
@@ -202,6 +208,7 @@ export class DuckDBHandler implements perspective.VirtualServerHandler {
|
|
|
202
208
|
split_by: true,
|
|
203
209
|
sort: true,
|
|
204
210
|
expressions: true,
|
|
211
|
+
group_rollup_mode: ["rollup", "flat", "total"],
|
|
205
212
|
filter_ops: {
|
|
206
213
|
integer: FILTER_OPS,
|
|
207
214
|
float: FILTER_OPS,
|
|
@@ -250,12 +257,10 @@ export class DuckDBHandler implements perspective.VirtualServerHandler {
|
|
|
250
257
|
async viewColumnSize(viewId: string, config: ViewConfig) {
|
|
251
258
|
const query = this.sqlBuilder.viewColumnSize(viewId);
|
|
252
259
|
const results = await runQuery(this.db, query);
|
|
253
|
-
const gs = config.group_by?.length || 0;
|
|
254
260
|
const count = Number(Object.values(results[0].toJSON())[0]);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
);
|
|
261
|
+
const gs = config.group_by?.length || 0;
|
|
262
|
+
const is_flat = config.group_rollup_mode === "flat";
|
|
263
|
+
return count - (gs === 0 ? 0 : is_flat ? gs : gs + 1);
|
|
259
264
|
}
|
|
260
265
|
|
|
261
266
|
async tableSize(tableId: string) {
|
|
@@ -294,6 +299,8 @@ export class DuckDBHandler implements perspective.VirtualServerHandler {
|
|
|
294
299
|
) {
|
|
295
300
|
const is_group_by = config.group_by?.length > 0;
|
|
296
301
|
const is_split_by = config.split_by?.length > 0;
|
|
302
|
+
const is_flat = config.group_rollup_mode === "flat";
|
|
303
|
+
const has_grouping_id = is_group_by && !is_flat;
|
|
297
304
|
const query = this.sqlBuilder.viewGetData(
|
|
298
305
|
viewId,
|
|
299
306
|
config,
|
|
@@ -306,22 +313,23 @@ export class DuckDBHandler implements perspective.VirtualServerHandler {
|
|
|
306
313
|
});
|
|
307
314
|
|
|
308
315
|
for (let cidx = 0; cidx < columns.length; cidx++) {
|
|
309
|
-
if (cidx === 0 &&
|
|
316
|
+
if (cidx === 0 && has_grouping_id) {
|
|
310
317
|
// This is the grouping_id column, skip it
|
|
311
318
|
continue;
|
|
312
319
|
}
|
|
313
320
|
|
|
314
321
|
let col = columns[cidx];
|
|
315
|
-
if (is_split_by && !col.startsWith("
|
|
322
|
+
if (is_split_by && !col.startsWith("__")) {
|
|
316
323
|
col = col.replaceAll("_", "|");
|
|
317
324
|
}
|
|
318
325
|
|
|
319
326
|
const dtype = duckdbTypeToPsp(dtypes[cidx]) as ColumnType;
|
|
320
|
-
|
|
321
327
|
const isDecimal = dtypes[cidx].startsWith("Decimal");
|
|
322
328
|
for (let ridx = 0; ridx < rows.length; ridx++) {
|
|
323
329
|
const rowArray = rows[ridx].toArray();
|
|
324
|
-
const grouping_id =
|
|
330
|
+
const grouping_id = has_grouping_id
|
|
331
|
+
? Number(rowArray[0])
|
|
332
|
+
: undefined;
|
|
325
333
|
let value = rowArray[cidx];
|
|
326
334
|
if (isDecimal) {
|
|
327
335
|
value = convertDecimalToNumber(value, dtypes[cidx]);
|
|
@@ -331,6 +339,14 @@ export class DuckDBHandler implements perspective.VirtualServerHandler {
|
|
|
331
339
|
value = Number(value);
|
|
332
340
|
}
|
|
333
341
|
|
|
342
|
+
if (typeof value !== "string" && dtype === "string") {
|
|
343
|
+
try {
|
|
344
|
+
value = JSON.stringify(value);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
value = `${value}`;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
334
350
|
dataSlice.setCol(dtype, col, ridx, value, grouping_id);
|
|
335
351
|
}
|
|
336
352
|
}
|