Cannot insert new value to BigQuery table after updating with new column using streaming API

前端 未结 2 1282
别跟我提以往
别跟我提以往 2021-02-15 14:45

I\'m seeing some strange behaviour with my bigquery table, I\'ve just created added a new column to a table, it looks good on the interface and getting the schema via the api.

2条回答
  •  天命终不由人
    2021-02-15 15:24

    I was running into this error. It turned out that I was building the insert object like i was in "raw" mode but had forgotten to set the flag raw: true. This caused bigQuery to take my insert data and nest it again under a json: {} node.

    In otherwords, I was doing this:

    table.insert({
        insertId: 123,
        json: {
            col1: '1',
            col2: '2',
        }
    });
    

    when I should have been doing this:

    table.insert({
        insertId: 123,
        json: {
            col1: '1',
            col2: '2',
        }
    }, {raw: true});
    

    the node bigquery library didn't realize that it was already in raw mode and was then trying to insert this:

    {
        insertId: '',
        json: {
            insertId: 123,
            json: {
                col1: '1',
                col2: '2',
         }
    }
    

    So in my case the errors were referring to the fact that the insert was expecting my schema to have 2 columns in it (insertId and json).

提交回复
热议问题