【问题标题】:Node.JS how to create parquet file and save to MinioNode.JS 如何创建 parquet 文件并保存到 Minio
【发布时间】:2019-11-15 14:30:35
【问题描述】:

以 NPM 文档 (https://www.npmjs.com/package/parquets) 中的以下示例为例,我将如何将生成的 parquet 文件直接写入 minio。我想避免将 parquet 文件写入磁盘,然后进行第二次操作将文件移动到 minio。

以下示例在调用 close() 后立即将文件写入磁盘。

// advanced fruits table
let schema = new ParquetSchema({
  name: { type: 'UTF8' },
  colours: { type: 'UTF8', repeated: true },
  stock: {
    repeated: true,
    fields: {
      price: { type: 'DOUBLE' },
      quantity: { type: 'INT64' },
    }
  }
});

// the above schema allows us to store the following rows:
let writer = await ParquetWriter.openFile(schema, 'fruits.parquet');

await writer.appendRow({
  name: 'banana',
  colours: ['yellow'],
  stock: [
    { price: 2.45, quantity: 16 },
    { price: 2.60, quantity: 420 }
  ]
});

await writer.appendRow({
  name: 'apple',
  colours: ['red', 'green'],
  stock: [
    { price: 1.20, quantity: 42 },
    { price: 1.30, quantity: 230 }
  ]
});

await writer.close();

【问题讨论】:

    标签: node.js parquet minio


    【解决方案1】:

    使用/tmp 编写parquet 文件,然后使用minio 的sdk 上传该文件。

    为确保它正确缩放,只需在您将其存储在 tmp 中的文件名中包含一个随机字符串或UUID

    不幸的是,我在库中找不到任何流选项,因此除非有人知道如何从该库返回 Stream 对象,否则您无法完全按照您的要求进行操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多