duckdb / duckdb-wasm

WebAssembly version of DuckDB
https://shell.duckdb.org
MIT License
1.14k stars 120 forks source link

histogram causes crash #448

Closed stratospark closed 2 months ago

stratospark commented 2 years ago

The following currently breaks on https://shell.duckdb.org/. It works fine on my CLI.

DuckDB Web Shell
Database: v0.3.1-dev535
Package:  @duckdb/duckdb-wasm@1.11.1-dev64.0

Connected to a transient in-memory database.
Enter .help for usage hints.

duckdb> create table t1 (i integer);
┌┐
└┘

duckdb> insert into t1 values (1),(2),(1);
┌───────┐
│ Count │
╞═══════╡
│     3 │
└───────┘

duckdb> select * from t1;
┌───┐
│ i │
╞═══╡
│ 1 │
│ 2 │
│ 1 │
└───┘

duckdb> select histogram(i) from t1;

error in browser console:

f272ce859168ca188950.wasm:0x1b25e3 Uncaught (in promise) RuntimeError: unreachable
    at f272ce859168ca188950.wasm:0x1b25e3
    at f272ce859168ca188950.wasm:0x1b8514
    at f272ce859168ca188950.wasm:0x1bc638
    at f272ce859168ca188950.wasm:0x1bc0b6
    at f272ce859168ca188950.wasm:0x1bc66e
    at f272ce859168ca188950.wasm:0xda902
    at f272ce859168ca188950.wasm:0x1411a2
    at f272ce859168ca188950.wasm:0x1402ea
    at f272ce859168ca188950.wasm:0xcc214
    at f272ce859168ca188950.wasm:0x1bd805

expected result

D .version
SQLite v0.3.1 88aa81c6b
msvc-1929

D select histogram(i) from t1;
┌──────────────┐
│ histogram(i) │
├──────────────┤
│ {1=2, 2=1}   │
└──────────────┘
ankoh commented 2 years ago

Thanks for reporting this. That's a bug in the shell. DuckDB-Wasm itself will return an arrow.Map_.

https://github.com/duckdb/duckdb-wasm/blob/ffa9210415e394fa84f0c769a54ef86b169bc2ab/packages/duckdb-wasm/test/regression/github_448.test.ts#L18-L33

sgilligan commented 2 years ago

@ankoh will the shell display the result? When I try (@duckdb/duckdb-wasm@1.16.1-dev58.0), the shell shows an elapsed time count but nothing else. I must admit I'm having trouble retrieving histogram results. I get an undefined length from the result (vs the test above) eg: in console output here: https://codesandbox.io/s/confident-chaplygin-owxqh3?file=/src/DuckDb.js

[Edit] ignore me .. I see it is .getChildAt(0) for the histogram output (I've updated the sandbox with that)