@@ -9,7 +9,7 @@ export default {
99  // eslint-disable-next-line pipedream/source-name 
1010  name : "BigQuery - New Row" , 
1111  description : "Emit new events when a new row is added to a table" , 
12-   version : "0.1.8 " , 
12+   version : "0.1.9 " , 
1313  dedupe : "unique" , 
1414  type : "source" , 
1515  props : { 
@@ -56,9 +56,6 @@ export default {
5656      const  lastResultId  =  await  this . _getIdOfLastRow ( ) ; 
5757      this . _setLastResultId ( lastResultId ) ; 
5858    } , 
59-     deactivate ( )  { 
60-       this . _setLastResultId ( null ) ; 
61-     } , 
6259  } , 
6360  methods : { 
6461    ...common . methods , 
@@ -113,7 +110,15 @@ export default {
113110          limit, 
114111        } , 
115112      } ; 
116-       const  rows  =  await  this . getRowsForQuery ( queryOpts ,  this . datasetId ) ; 
113+       const  client  =  this . googleCloud 
114+         . getBigQueryClient ( ) 
115+         . dataset ( this . datasetId ) ; 
116+       const  [ 
117+         job , 
118+       ]  =  await  client . createQueryJob ( queryOpts ) ; 
119+       const  [ 
120+         rows , 
121+       ]  =  await  job . getQueryResults ( ) ; 
117122      if  ( rows . length  ===  0 )  { 
118123        console . log ( ` 
119124          No records found in the target table, will start scanning from the beginning 
@@ -126,15 +131,19 @@ export default {
126131    } , 
127132    getQueryOpts ( )  { 
128133      const  lastResultId  =  this . _getLastResultId ( ) ; 
129-       const  query  =  ` 
134+       let  query  =  ` 
130135        SELECT * 
131136        FROM \`${ this . tableId }  \` 
132-         WHERE \`${ this . uniqueKey }  \` >= @lastResultId 
133-         ORDER BY \`${ this . uniqueKey }  \` ASC 
134137      ` ; 
135-       const  params  =  { 
136-         lastResultId, 
137-       } ; 
138+       if  ( lastResultId )  { 
139+         query  +=  ` WHERE \`${ this . uniqueKey }  \` >= @lastResultId` ; 
140+       } 
141+       query  +=  ` ORDER BY \`${ this . uniqueKey }  \` ASC` ; 
142+       const  params  =  lastResultId 
143+         ? { 
144+           lastResultId, 
145+         } 
146+         : { } ; 
138147      return  { 
139148        query, 
140149        params, 
0 commit comments