ironSource / parquetjs

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

os.close is not a function #121

Open yaplas opened 3 years ago

yaplas commented 3 years ago

I'm using a parquet stream to track api usage, and every seems working ok except for when I try to close the stream i get an error: `os.close is not a function'. I suppose it is happening here: https://github.com/ironSource/parquetjs/blob/455ff9ffce89ac055fd667cf8d0555aec93f7c9f/lib/util.js#L122

I create the stream this way:

    const trackingStream = await parquet.ParquetWriter.openStream(
      schema,
      fileStream,
      {rowGroupSize: 2}, // batch size before flushing the output buffer
    );

where fileStream is a s3-upload-stream stream

then I append rows using appendRow, but when I try to close it I get the error.

s3-upload-stream stream does not have a close method, it has an end method, could be this the issue ? bc I suppose os is output stream. So I wondering if I need to wrap the s3-upload-stream into an object with a close method that internally call the end method ?

designreact commented 3 years ago

You've probably sorted this now but if it helps another... Inline with your closing comment, here's how I got around this same issue:

import s3UploadStream = require('s3-upload-stream');
const s3Stream = s3UploadStream(S3);

...

const upload: S3WriteParquetStream = s3Stream.upload({ Bucket, Key });
upload.close = () => upload.end();

const writer = await parquet.ParquetWriter.openStream(schema, upload);
nickjames640 commented 3 years ago

Hi @yaplas! I am running into this exact same issue using the TypeScript parquets library. Did you ever find a fix? I got it working using the parquetjs-lite library, but would prefer the TS one if possible.

pcj commented 1 year ago

@nickjames640 old comment, but for future reference you can do:

                // @ts-ignore
                parquetWritable.close = () => parquetWritable.end();