如何使用Nodejs插入到BigQuery?

我想使用google-api-nodejs-client将行stream传输到Google BigQuery 。

挖掘源代码我发现我需要一个“资源”参数。 我尝试了几种组合,并去apirequest的来源,但我总是得到错误No rows present in the request.

我终于成功地与另一个npm模块一次上传一行,但是这个模块不支持tabledata.insertAll()。

你可以给一个例子,说明如何使用“资源”参数来stream插入?

 bigquery.tabledata.insertAll({ auth: oauth2Client, 'projectId': config.google.projectId, 'datasetId': config.google.datasetId, 'tableId': config.google.tableId, 'resource ': { "kind": "bigquery#tableDataInsertAllRequest", "rows": [ { "insertId": 123456, "json": '{"id": 123,"name":"test1"}' } ] } }, function(err, result) { if (err) { return console.error(err); } console.log(result); }); 

资源之后你有一个额外的空间,你试过删除?

  'resource ': { 

看起来你正在做插入行的额外编码。 他们应该作为原始的JSON发送,而不是将整行编码为string。 就是这样的:

 'rows': [ { 'insertId': 123456, 'json': {'id': 123,'name':'test1'} } ] 

(注意与上面的不同之处在于{'id': 123,'name':'test1'}行不被引用。