ironSource / parquetjs

fully asynchronous, pure JavaScript implementation of the Parquet file format
MIT License
351 stars 174 forks source link

Cannot execute the demo code for writing a parquet file. #66

Closed dogenius01 closed 6 years ago

dogenius01 commented 6 years ago

I tried the code below....


var parquet = require('parquetjs');

// declare a schema for the fruits table var schema = new parquet.ParquetSchema({ name: { type: 'UTF8' }, quantity: { type: 'INT64' }, price: { type: 'DOUBLE' }, in_stock: { type: 'BOOLEAN' } });

// create new ParquetWriter that writes to 'fruits.parquet` var writer = new parquet.ParquetFileWriter(schema, 'fruits.parquet');

This gives me an error.


1<process.argv.length?process.argv[1].replace(/\\/g,"/"):"unknown-program");b.arguments=process.argv.slice(2);"undefined"!==typeof module&&(module.exports=b);process.on("uncaughtException",function(a){if(!(a instanceof y))throw a;});b.inspect=function(){return"[Emscripten Module object]"}}else if(x)b.print||(b.print=print),"undefined"!=typeof printErr&&(b.printErr=printErr),b.read="undefined"!=typeof read?read:function(){throw"no read() available (jsc?)";},b.readBinary=function(a){if("function"===
                                                                                                                                                                                                                              ^

TypeError: parquet.ParquetFileWriter is not a constructor
    at Object.<anonymous> (/usr/local/globalcdn/playground/parquet/index.js:14:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
---------------------------------------------------------------------------------------------

**The parquetjs is installed with this message.**
---------------------------------------------------------------------------------------------
$ npm install --save parquetjs

> ws@0.4.32 install /usr/local/globalcdn/playground/parquet/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

make: Entering directory `/usr/local/globalcdn/playground/parquet/node_modules/ws/build'
  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
make: Leaving directory `/usr/local/globalcdn/playground/parquet/node_modules/ws/build'

> lzo@0.4.3 install /usr/local/globalcdn/playground/parquet/node_modules/lzo
> node-gyp rebuild

make: Entering directory `/usr/local/globalcdn/playground/parquet/node_modules/lzo/build'
  CC(target) Release/obj.target/node_lzo/lib/minilzo209/minilzo.o
  CXX(target) Release/obj.target/node_lzo/lib/lzo.o
  SOLINK_MODULE(target) Release/obj.target/node_lzo.node
  COPY Release/node_lzo.node
make: Leaving directory `/usr/local/globalcdn/playground/parquet/node_modules/lzo/build'
npm WARN parquet@1.0.0 No description
npm WARN parquet@1.0.0 No repository field.

+ parquetjs@0.7.0
added 17 packages in 4.499s
---------------------------------------------------------------------------------------------

**Environment Info.**
---------------------------------------------------------------------------------------------
 Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-74-generic x86_64)
---------------------------------------------------------------------------------------------
ZJONSSON commented 6 years ago

There is no such thing as parquet.ParquetFileWriter. The prevailing pattern is to execute parquet.ParquetWriter.openFile(schema,path,options) which returns a promise to the writer. You can either execute within an async function and await on the writer:

let writer = await parquet.ParquetWriter.openFile(schema, 'fruits.parquet');

or use the writer within a .then

await parquet.ParquetWriter.openFile(schema, 'fruits.parquet')
  .then(writer = {
      // write stuff
   });

See example in the integration tests: https://github.com/ironSource/parquetjs/blob/master/test/integration.js#L99-L113

dogenius01 commented 6 years ago

@ZJONSSON Thank you! But the code above is copied from https://www.npmjs.com/package/parquetjs. And it gives me an error, when i try >> writer.appendRow... >> SyntaxError: Unexpected token .