parquetjs icon indicating copy to clipboard operation
parquetjs copied to clipboard

Client side version

Open vasner opened this issue 5 years ago • 14 comments

Hi All, Is it possible to build parquetjs as client side (browser) js library?

vasner avatar Aug 29 '19 13:08 vasner

I think for compression it does depend on some other modules that are not available in the browser, though for uncompressed data it might work. Have you tried it?

dobesv avatar Dec 09 '19 23:12 dobesv

I've never tried.

vasner avatar Dec 10 '19 07:12 vasner

brotli has an issue with encoding on browsers (https://github.com/foliojs/brotli.js/issues/20) and suggests to import only 'brotli/decompress' in the browser as a workaround. suppose I want only to read files - can I just import ParquetReader?

import ParquetReader from 'parquetjs/lib/reader';

I'm still getting the following error from brotli.

ReferenceError: Browser is not defined
node_modules/brotli/build/encode.js:49

aviillouz avatar Apr 13 '20 21:04 aviillouz

I also got an error - same as aviillouz - when running Jest test, but I don't get that when I run same file on production...

sota1235 avatar Jul 15 '20 12:07 sota1235

I ran into the same error. This package isn't intended to run in the browser, Jest by default tests in a browser environment. Set the testEnvironment to node in your package.json, and the error will go away when using parquetjs.

"jest": {
    "testEnvironment": "node"
  },

https://jestjs.io/docs/en/configuration#testenvironment-string

danb235 avatar Nov 21 '20 19:11 danb235

I have been using a derived package, parquets in the browser, and it works.

dobesv avatar Nov 22 '20 00:11 dobesv

Thanks @dobesv! Link for everyone: https://github.com/kbajalc/parquets.

eatonphil avatar Jun 21 '21 18:06 eatonphil

Hmm after trying it myself kbajalc/parquets does not work in the browser either. Maybe I'm doing it wrong but it fails while importing thrift.

eatonphil avatar Jun 21 '21 21:06 eatonphil

Make sure you're using thrift 0.14.0, I believe 0.13.0 was a broken build.

dobesv avatar Jun 21 '21 21:06 dobesv

A problem is that thrift includes a lot of nodejs-only libraries:

 > node_modules/parquets/lib/compression.js:4:21: error: Could not resolve "zlib" (use "--platform=node" when building for node)
    4 │ const zlib = require("zlib");
      ╵                      ~~~~~~

 > node_modules/thrift/lib/nodejs/lib/thrift/log.js:20:19: error: Could not resolve "util" (use "--platform=node" when building for node)
    20 │ var util = require('util');
       ╵                    ~~~~~~

 > node_modules/thrift/lib/nodejs/lib/thrift/thrift.js:19:19: error: Could not resolve "util" (use "--platform=node" when building for node)
    19 │ var util = require('util');
       ╵                    ~~~~~~

 > node_modules/thrift/lib/nodejs/lib/thrift/ws_connection.js:19:19: error: Could not resolve "util" (use "--platform=node" when building for node)
    19 │ var util = require('util');
       ╵                    ~~~~~~

 > node_modules/thrift/lib/nodejs/lib/thrift/ws_connection.js:21:27: error: Could not resolve "events" (use "--platform=node" when building for node)
    21 │ var EventEmitter = require("events").EventEmitter;

So it doesn't help me out trying to run parquets in the browser :/

eatonphil avatar Jun 21 '21 21:06 eatonphil

Maybe these webpack settings will help:

resolve: {
    extensions,
    fallback: {
      assert: require.resolve('assert/'),
      console: require.resolve('console-browserify'),
      crypto: require.resolve('crypto-browserify'),
      domain: require.resolve('domain-browser'),
      events: require.resolve('events'),
      path: require.resolve('path-browserify'),
      stream: require.resolve('stream-browserify'),
      string_decoder: require.resolve('string_decoder/'),
      util: require.resolve('util/util.js'),
      vm: require.resolve('vm-browserify'),
      zlib: require.resolve('browserify-zlib'),
    },
    mainFields: ['browser', 'main', 'module'],
    modules: modulesSearchPath,
    alias: enableHotReload ? { 'react-dom': '@hot-loader/react-dom' } : {},
  },

dobesv avatar Jun 21 '21 21:06 dobesv

Maybe relevant to people in this thread: I have a basic but functional WebAssembly Parquet reader/writer here: https://github.com/kylebarron/parquet-wasm, compiled from Rust.

kylebarron avatar Mar 06 '22 22:03 kylebarron

There also seems to be a fork with browser support (and Typescript types) at https://github.com/LibertyDSNP/parquetjs - which is also available on NPM.

jonnor avatar Jun 06 '22 12:06 jonnor

I have been using a derived package, parquets in the browser, and it works.

@dobesv Would you mind sharing an example implementation? I am struggling to make it work in the browser.

plotka avatar Jun 15 '22 15:06 plotka