javascript 无法写入 parquet 文件(总是 1kb)
javascript cant write to parquet file (always 1kb)
我正在尝试弄清楚如何使用 nodejs 创建数据并将数据写入 parquet 文件。我在下面创建了非常简单的代码:
var parquet = require('parquetjs');
init();
async function init(){
console.log('BEGIN DEBUG PARQUET')
var debugschema = new parquet.ParquetSchema({
name: { type: 'UTF8' },
quantity: { type: 'INT64' },
price: { type: 'DOUBLE' },
date: { type: 'TIMESTAMP_MILLIS' },
in_stock: { type: 'BOOLEAN' }
});
// create new ParquetWriter that writes to 'fruits.parquet`
var debugwriter = await parquet.ParquetWriter.openFile(debugschema, `./DEBUGPARQUET.parquet`);
// append a few rows to the file
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
console.log('END DEBUG PARQUET')
}
我 运行 在我的 windows 10 命令提示符终端中使用命令 node index.js
,文件 运行s 没有错误,现在我有一个文件 DEBUGPARQUET.parquet
大小只有 1 kb,我根本无法打开这个文件来查看 parquet 数据(我尝试安装 apache parquet view 程序并使用它,但它不起作用,我无法查看 parquet 的内容vscode 中带有 parquet 扩展名的文件,查看 parquet 文件的在线网站也无法正常工作)
我的代码中是否缺少某些内容?或者在 windows 10 上写入 parquet 文件有问题吗?
var debugwriter = await parquet.ParquetWriter.openFile(debugschema, `./DEBUGPARQUET.parquet`);
// append a few rows to the file
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.close();
console.log('END DEBUG PARQUET')
我正在尝试弄清楚如何使用 nodejs 创建数据并将数据写入 parquet 文件。我在下面创建了非常简单的代码:
var parquet = require('parquetjs');
init();
async function init(){
console.log('BEGIN DEBUG PARQUET')
var debugschema = new parquet.ParquetSchema({
name: { type: 'UTF8' },
quantity: { type: 'INT64' },
price: { type: 'DOUBLE' },
date: { type: 'TIMESTAMP_MILLIS' },
in_stock: { type: 'BOOLEAN' }
});
// create new ParquetWriter that writes to 'fruits.parquet`
var debugwriter = await parquet.ParquetWriter.openFile(debugschema, `./DEBUGPARQUET.parquet`);
// append a few rows to the file
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
console.log('END DEBUG PARQUET')
}
我 运行 在我的 windows 10 命令提示符终端中使用命令 node index.js
,文件 运行s 没有错误,现在我有一个文件 DEBUGPARQUET.parquet
大小只有 1 kb,我根本无法打开这个文件来查看 parquet 数据(我尝试安装 apache parquet view 程序并使用它,但它不起作用,我无法查看 parquet 的内容vscode 中带有 parquet 扩展名的文件,查看 parquet 文件的在线网站也无法正常工作)
我的代码中是否缺少某些内容?或者在 windows 10 上写入 parquet 文件有问题吗?
var debugwriter = await parquet.ParquetWriter.openFile(debugschema, `./DEBUGPARQUET.parquet`);
// append a few rows to the file
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.close();
console.log('END DEBUG PARQUET')