bigquery-emulator icon indicating copy to clipboard operation
bigquery-emulator copied to clipboard

Error in merge statement

Open DavitSo opened this issue 3 years ago • 6 comments

Getting the following error ApiError: unexpected MERGE expression. expected column reference but got *resolved_ast.GetStructFieldNode

here is code for reprodusing const {BigQuery} = require('@google-cloud/bigquery'); const orderSchemaForEmulator = [ {name: 'orderUuid', type: 'STRING', mode: 'REQUIRED'}, {name: 'userId', type: 'INT64', mode: 'REQUIRED'}, ];

const bigQueryConfig = { projectId: 'test', datasetId: 'testDataset', orderTableId: 'testTable', };

const bigquery = new BigQuery({projectId: bigQueryConfig.projectId, apiEndpoint: 'http://localhost:9050'}); const dataset = bigquery.dataset(bigQueryConfig.datasetId);

let query = MERGE ${bigQueryConfig.datasetId}.${bigQueryConfig.orderTableId} ; query += USING UNNEST([struct<; query += orderUuid STRING, userId INT64> ( + '260e3d0e-0a29-40a2-02ab-111111020a19', 10)]) TempTable ON testTable .orderUuid = TempTable.orderUuid + WHEN NOT MATCHED THEN INSERT (orderUuid,userId) VALUES (TempTable.orderUuid, TempTable.userId) WHEN MATCHED + THEN UPDATE SET testTable.orderUuid = TempTable.orderUuid, testTable .userId = TempTable.userId;

/** *

@return {Promise} */ async function test() { try { await dataset.table(bigQueryConfig.orderTableId).delete(); } catch (error) { console.log(Error: ${error.message}); } await dataset.createTable(bigQueryConfig.orderTableId, {schema: orderSchemaForEmulator}); await dataset.query(query); } test(); node version - 16 emulator version is 0.2.10

DavitSo avatar Jan 11 '23 12:01 DavitSo

Hi @goccy , any update on this?

DavitSo avatar Jan 16 '23 08:01 DavitSo

It would be nice if you could add appropriate indent using code block etc. to make it easier to see. I'll take a look later

goccy avatar Jan 17 '23 11:01 goccy

Thanks @goccy

DavitSo avatar Jan 17 '23 16:01 DavitSo

Hi @goccy , sorry for pushing :). Is there any update

DavitSo avatar Jan 19 '23 15:01 DavitSo

Hi @goccy any update?

DavitSo avatar Mar 01 '23 04:03 DavitSo