forked from isamplesorg/isamplesorg.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparquet_isamples_opencontext.qmd
More file actions
51 lines (39 loc) · 1.12 KB
/
parquet_isamples_opencontext.qmd
File metadata and controls
51 lines (39 loc) · 1.12 KB
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
---
title: "Parquet"
---
Let's query Eric's parquet file using duckdb+parquet
```{ojs}
//| code-fold: true
//
parquet_path = 'https://storage.googleapis.com/opencontext-parquet/oc_isamples_pqg.parquet';
// Create a DuckDB instance
db = {
const instance = await DuckDBClient.of();
await instance.query(`create view nodes as select * from read_parquet('${parquet_path}')`)
return instance;
}
row_count = {
const result = await db.queryRow(`select count(*) as n from nodes;`);
return result.n;
}
results = {
const data = await db.query(`SELECT COUNT(*) as count, otype FROM nodes GROUP BY otype ORDER BY count DESC`);
document.getElementById("loading_1").hidden = true;
return Inputs.table(data);
}
rows1k = {
const data = await db.query(`SELECT row_id, pid, otype, label FROM nodes limit 1000`);
document.getElementById("loading_2").hidden = true;
return Inputs.table(data);
}
md`There are ${row_count} rows in the source <code>${parquet_path}</code>.`
```
<div>
<div id="loading_1">Loading type counts...</div>
${results}
</div>
The first 1000 rows:
<div>
<div id="loading_2">Loading...</div>
${rows1k}
</div>