Skip to content

Bigquery import does not populate err in callback when error occurs #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jasonpolites opened this issue May 5, 2016 · 2 comments
Closed
Assignees
Labels
api: bigquery Issues related to the BigQuery API.

Comments

@jasonpolites
Copy link

In trying to track down why data was not appearing in Bigquery even though the import completed "successfully", I noted that the err argument was not populated even though an error had occurred.

code:

table.import(gcsFile, function(err, job, apiResponse) {
  if(err) {
    callback(err);
    return;
  } 

  console.log('Data import job created');
  console.log(apiResponse);
}

The err argument is undefined (or perhaps null), however the apiResponse reports (verbatim from logs):

{ kind: 'bigquery#job',
  etag: '"oGMCLvGjZO7RB3oFjn17umMEDU4/v1SSKa6IBg_jGNKysjFGzeC_xYA"',
  id: 'gcf-tests:job_19Q8iGmmqYjyV0V7rj5fiSwiQFw',
  selfLink: 'https://www.googleapis.com/bigquery/v2/projects/gcf-tests/jobs/job_19Q8iGmmqYjyV0V7rj5fiSwiQFw',
  jobReference:
   { projectId: 'gcf-tests',
     jobId: 'job_19Q8iGmmqYjyV0V7rj5fiSwiQFw' },
  configuration:
   { load:
      { sourceUris: [Object],
        destinationTable: [Object],
        sourceFormat: 'CSV' } },
  status:
   { state: 'DONE',
     errorResult:
      { reason: 'invalid',
        message: 'No schema specified on job or table.' },
     errors: [ [Object] ] },
  statistics:
   { creationTime: '1462423012789',
     startTime: '1462423012849',
     endTime: '1462423012849' },
  user_email: '[email protected]' }

It might be reasonable to have developers inspect the status/errorResult property of the apiResponse, but it seems like it would make more sense to report this as an error

@jasonpolites
Copy link
Author

Addendum.. just realizing this is an async job, so reporting the status inline is not going to be reliable. Maybe we can provide a helper function, or maybe just some docs to offer guidance as to how to check for error conditions

@stephenplusplus
Copy link
Contributor

The job argument is a Job object: https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.32.0/bigquery/job -- The docs for cancel show how you can set up a loop to get the results of the job.

We should switch to event emitters, like we use for Compute operations, so it would be something like:

table.import(gcsFile, function(err, job) {
  job.on('error', function(err) {});
  job.on('complete', function() {});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API.
Projects
None yet
Development

No branches or pull requests

3 participants