Yield not pausing generator using co in nodejs with bigquery jobs

50 views Asked by At
co(const levelOneQueries = function*(){
    try{
        var data = yield getResults(queries.sqlQuery1,queries.dest_sqlQ1);
        console.log("Level One Query Output",data);
    } catch(err){
        console.log('Error gettinng results',err);
        throw err;
    }
    return data;
})

const getResults = function* (sqlQuery,destTable){
    console.log('Inside From getResults');
    bigquery.startQuery({
        destination: bigquery.dataset('topshowanalysis').table(destTable),
        writeDisposition: 'WRITE_TRUNCATE',
        allowLargeResults: 'TRUE',
        query: sqlQuery
    }, (err, job) => {
        job.getQueryResults((err, rows) => {
            result = rows;
            console.log("Rows",rows);
            return result;  
        })
    })
};

I'm Using co library for pausing this function/generator getResults. Which is not working currently please help me with this also getResults function call bigQuery Query to calculate results and save it in destination table. I wanted to wait until job is done and destination table is created.

Currently bigQuerie's startQuery just give me jobId and we need to ping it to check if job is completed and destination table is created or not.

0

There are 0 answers