Skip to content
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

Incomplete error object for streaming inserts #70

Closed
piotr-sobczyk opened this issue Mar 15, 2018 · 2 comments
Closed

Incomplete error object for streaming inserts #70

piotr-sobczyk opened this issue Mar 15, 2018 · 2 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/nodejs-bigquery API. type: question Request for information or clarification. Not an issue.

Comments

@piotr-sobczyk
Copy link

piotr-sobczyk commented Mar 15, 2018

I'm using nodejs-bigquery version 1.0.

I'm using the following code to stream records into the database:

module.exports.sendToBigQuery = (rows) => {
    bigquery
        .dataset(DATASET_NAME)
        .table(TABLE_NAME)
        .insert(rows)
        .catch(err => {
            if (err && err.name === 'PartialFailureError') {
                if (err.errors && err.errors.length > 0) {
                    console.log('Insert errors:');
                    err.errors.forEach(err => console.error(err));
                }
            } else {
                console.error('ERROR:', err);
            }
        });
};

Unfortunately, whenever my data doesn't match the schema, all I'm getting is this cryptic error object: { errors: [ { message: 'no such field.', reason: 'invalid' } ],

There is no location field that would tell me which field is missing which makes debugging this code a nightmare for more complex schemas.

Is there any way to enable debug level of errors somehow? Or it's just a bug in client implementation? Any idea how I could access this information?

@stephenplusplus
Copy link
Contributor

Unfortunately, this error is coming directly from the API. We are simply returning it. All we can do is return the invalid row itself, which is alongside the errors array, e.g.

var rowWithInvalidField = {
  property: 'a',
  extraProperty: 'b'
}

table.insert(rowWithExtraField, partialFailureError => { 
  partialFailureError.errors.forEach(console.log)
  // {
  //   row: {
  //     property: 'a',
  //     extraProperty: 'b'
  //   },
  //   errors: [
  //     {
  //       message: 'no such field.',
  //       reason: 'invalid'
  //     }
  //   ]
  // }
})

You can find the BigQuery team members from the links on the Support page, who may be able to assist further.

@stephenplusplus stephenplusplus added the type: question Request for information or clarification. Not an issue. label Mar 15, 2018
@stephenplusplus
Copy link
Contributor

Linking the report on the official issue tracker: https://issuetracker.google.com/issues/75704775

@google-cloud-label-sync google-cloud-label-sync bot added the api: bigquery Issues related to the googleapis/nodejs-bigquery API. label Jan 31, 2020
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 googleapis/nodejs-bigquery API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants