kbajalc / parquets

MIT License
44 stars 21 forks source link

Error while reading file: cursor.buffer.readUInt32LE is not a function #43

Open plotka opened 2 years ago

plotka commented 2 years ago

I am trying to read a parquet file buffer from a React application, using this code:

      const fileDataBuffer = Buffer.from(fileData);
      let reader = await ParquetReader.openBuffer(fileDataBuffer);

      // create a new cursor
      let cursor = reader.getCursor();

      // read all records from the file and print them
      let record = null;
      while (record = await cursor.next()) {
        console.log(record);
      }

However, when the code is executing this: record = await cursor.next(), I am getting the following error:

TypeError: cursor.buffer.readUInt32LE is not a function
    decodeValues_BYTE_ARRAY plain.ts:191
    decodeValues plain.ts:43
    decodeValues reader.ts:354
    decodeDataPage reader.ts:496
    decodeDataPages reader.ts:385
    readColumnChunk reader.ts:321
    readRowGroup reader.ts:295
    next reader.ts:63
    processFile index.tsx:169
    onSuccess index.tsx:215
    NotifyManager notifyManager.js:62
    notifyFn notifyManager.js:10
    flush notifyManager.js:77
    flush notifyManager.js:76
    batchedUpdates$1 React
    flush notifyManager.js:75
    promise callback*scheduleMicrotask utils.js:322
    flush notifyManager.js:74
    batch notifyManager.js:30
    dispatch query.js:390
    setData query.js:83
    onSuccess query.js:334
    resolve retryer.js:58
    promise callback*run retryer.js:116
    Retryer retryer.js:156
    fetch query.js:330
    executeFetch queryObserver.js:199
    setOptions queryObserver.js:85
    useBaseQuery useBaseQuery.js:78
    React 5
    unstable_runWithPriority scheduler.development.js:468
    React 4
    unstable_runWithPriority scheduler.development.js:468
    React 5
    onSuccess useClientInputDatasets.tsx:55
    notify queryObserver.js:497
    batch notifyManager.js:25
    notify queryObserver.js:494
    updateResult queryObserver.js:454
    onQueryUpdate queryObserver.js:484

Could someone help me understand the issue here and how can I fix it? Appreciate it.