Monday, 10 June 2019

How to Patch a BigQuery View using Node.js

I have a Cloud Function written in the Node.js v8 that uses the @google-cloud/bigquery v1.3.0 library.

I like it, I'm able to perform BigQuery changes such as creating a view using the very simple code below without worry about promises and it's synchronous.

const bigquery = new BigQuery({projectId: 'my-project'});

const options = {
    view: {
        query: 'SELECT * FROM `my-project.my-datatset.my-table`',
        useLegacySql: false
    }
};

results = await bigquery
 .dataset('my-datatset')
 .createTable('my-view', options);

But I've been unable to work out how this code can be modified to perform a patch operations. I would expect a very similar syntax to be available but I can't find it. E.g. none of the examples below work:

//bigquery.dataset(datasetId).patchTable(viewId,options);
//bigquery.dataset(datasetId).table(viewId).patch(options);
//bigquery.dataset(datasetId).tables(viewId).patch(options);

I'm able to do the patch operation I want using the rest API through Googles reference documents. But I just can't find a code solution that's consistent with the approach above.

Any ideas?



from How to Patch a BigQuery View using Node.js

No comments:

Post a Comment