GithubHelp home page GithubHelp logo

Comments (6)

goccy avatar goccy commented on May 21, 2024

It's difficult to investigate with this information, so please provide a repro code

from bigquery-emulator.

goccy avatar goccy commented on May 21, 2024

Closed due to no response

from bigquery-emulator.

DavitSo avatar DavitSo commented on May 21, 2024

Sorry for the late response, here is the example of SQL script. I just run the bigquery.dataset(datasetId).query(query)

query = MERGE testDataset.testTable
USING UNNEST([struct<orderUuid STRING, userId INTEGER> ('260e3d0e-0a29-40a2-02ab-111111110a19', 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;

I just run the above query
bigquery.dataset(datasetId).query(query)

from bigquery-emulator.

DavitSo avatar DavitSo commented on May 21, 2024

After renaming INTEGER to INT64 in the schema I'm getting the following error
MERGE expression is supported equal expression only
for the same script

from bigquery-emulator.

DavitSo avatar DavitSo commented on May 21, 2024

Hi @goccy any idea ?
Thanks

from bigquery-emulator.

DavitSo avatar DavitSo commented on May 21, 2024

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

from bigquery-emulator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.