parquet-wasm: Example doesnt work

I’m following the steps from README.md and getting this error

file:///Users/seva/seva/node_modules/parquet-wasm/esm/parquet_wasm.js:3695
            wasm.__wbindgen_add_to_stack_pointer(16);
                 ^

TypeError: Cannot read properties of undefined (reading '__wbindgen_add_to_stack_pointer')
    at Table.fromIPCStream (file:///Users/seva/seva/node_modules/parquet-wasm/esm/parquet_wasm.js:3695:18)
    at file:///Users/seva/seva/boosters/check.js:23:33
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:120:12)

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

import * as arrow from "apache-arrow";
import init, * as parquet from "parquet-wasm";

await init();

// Create Arrow Table in JS
const LENGTH = 2000;
const rainAmounts = Float32Array.from({ length: LENGTH }, () =>
  Number((Math.random() * 20).toFixed(1))
);

const rainDates = Array.from(
  { length: LENGTH },
  (_, i) => new Date(Date.now() - 1000 * 60 * 60 * 24 * i)
);

const rainfall = arrow.tableFromArrays({
  precipitation: rainAmounts,
  date: rainDates,
});

// Write Arrow Table to Parquet

// wasmTable is an Arrow table in WebAssembly memory
const wasmTable = parquet.Table.fromIPCStream(arrow.tableToIPC(rainfall, "stream"));
const writerProperties = new parquet.WriterPropertiesBuilder()
  .setCompression(parquet.Compression.ZSTD)
  .build();
const parquetUint8Array = parquet.writeParquet(wasmTable, writerProperties);

// Read Parquet buffer back to Arrow Table
// arrowWasmTable is an Arrow table in WebAssembly memory
const arrowWasmTable = parquet.readParquet(parquetUint8Array);

// table is now an Arrow table in JS memory
const table = arrow.tableFromIPC(arrowWasmTable.intoIPCStream());
console.log(table.schema.toString());
// Schema<{ 0: precipitation: Float32, 1: date: Date64<MILLISECOND> }>
node:internal/deps/undici/undici:12442
    Error.captureStackTrace(err, this);
          ^

TypeError: fetch failed
    at node:internal/deps/undici/undici:12442:11
    at async __wbg_init (file:///Users/seva/seva/node_modules/parquet-wasm/esm/parquet_wasm.js:5238:51)
    at async file:///Users/seva/seva/boosters/check.js:4:1 {
  cause: Error: not implemented... yet...
      at makeNetworkError (node:internal/deps/undici/undici:5675:35)
      at schemeFetch (node:internal/deps/undici/undici:10563:34)
      at node:internal/deps/undici/undici:10440:26
      at mainFetch (node:internal/deps/undici/undici:10459:11)
      at fetching (node:internal/deps/undici/undici:10407:7)
      at fetch (node:internal/deps/undici/undici:10271:20)
      at Object.fetch (node:internal/deps/undici/undici:12441:10)
      at fetch (node:internal/process/pre_execution:336:27)
      at __wbg_init (file:///Users/seva/seva/node_modules/parquet-wasm/esm/parquet_wasm.js:5233:17)
      at file:///Users/seva/seva/boosters/check.js:4:7
}

Node.js v21.5.0

This is just terrible