【问题标题】:Apache Avro library failed to parse file nodejsApache Avro 库无法解析文件 nodejs
【发布时间】:2016-06-13 13:14:31
【问题描述】:

我正在尝试使用 nodejs 将 Avro 文件从 google staorage 上传到 google big query

var gcloud = require('gcloud')({
  keyFilename: '../config/keyfile.json',
  projectId: 'my-project-id'
});

var request = require('request');

var bigquery = gcloud.bigquery();


var dataset = bigquery.dataset('my-data-set');
var table = dataset.table('my-table');



  var metadata = {

   sourceFormat: 'AVRO'
  };

   var url = 'https://storage.googleapis.com/' + 'my-bucket' + '/' + 'yob1900.avro';

    request.get(url)
      .pipe(table.createWriteStream(metadata))
      .on('complete', function (job) {
        // Wait up to 60 seconds for job to complete
        pollJobUntilDone(job, 60000, 0, function (err, metadata) {
          if (err) {

            return callback(err);
          }
          console.log('job completed', metadata);

        });
      });

function pollJobUntilDone (job, timeout, timeWaited, callback) {
  job.getMetadata(function (err, metadata) {
    if (err) {
      return callback(err);
    }
    if (timeWaited > timeout) {
      return callback(new Error('Timed out waiting for job to complete'));
    }
    if (metadata.status && (metadata.status.state === 'RUNNING' ||
      metadata.status.state === 'PENDING')) {
      setTimeout(function () {
        console.log('working...');
        pollJobUntilDone(job, timeout, timeWaited + 5000, callback);
      }, 5000);
    } else {
      callback(null, metadata);
    }
  });
}

我收到此错误

'The Apache Avro library failed to parse file file-00000000.' 

(“yob1900”文件是从 bigquery 文档https://cloud.google.com/bigquery/loading-data#loading_json_files 下载的) 当我尝试通过 webUI 执行此操作时,我成功了。 有什么建议吗?

【问题讨论】:

  • 我不知道 nodejs,但似乎 avro 文件没有直接传递给 BigQuery。错误消息显示文件名“file-00000000”而不是“yob1900.avro”。某种转换是由nodejs完成的。

标签: node.js google-bigquery avro


【解决方案1】:

gcloud 不支持 Avro 格式。 问题已修复“gcloud”:“^0.36.0”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-23
    • 2018-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多