duckdb / duckdb-wasm

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

The issue with the query functionality in DuckDB-Wasm. #1641

Closed Lichong1104 closed 4 months ago

Lichong1104 commented 4 months ago

What happens?

The problem of failing to convert the ArrowTable format to JSON when using the query functionality.

To Reproduce

In the process of using DuckDB-Wasm, after connecting to the database using the official example code, when utilizing the Query functionality to retrieve the content of a Parquet file, I encountered an issue.

Official Example Code:

const conn = await db.connect();

const arrowResult = await conn.query<{ v: arrow.Int }>(SELECT * FROM generate_series(1, 100) t(v));

const result = arrowResult.toArray().map((row) => row.toJSON());

await conn.close();

The problem is that for some files, the second line of code successfully retrieves the Arrow Table formatted data from the Parquet file. However, when attempting to convert it to JSON using the toArray function in the third line of code, the data is transformed into an empty array. Interestingly, the issue occurs inconsistently; for some files, multiple accesses work fine, while for others, the problem as described arises. Moreover, in cases where the issue occurs, re-accessing the file after some time allows successful conversion to JSON, but only once.

Browser/Environment:

Chrome 121.0.6167.161

Device:

Desktop computers

DuckDB-Wasm Version:

0.10.0

DuckDB-Wasm Deployment:

shell.duckdb.org

Full Name:

lichong

Affiliation:

cl544348@gmail.com