Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/google_cloud/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/google_cloud",
"version": "0.6.2",
"version": "0.6.3",
"description": "Pipedream Google_cloud Components",
"main": "google_cloud.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
// eslint-disable-next-line pipedream/source-name
name: "BigQuery - New Row",
description: "Emit new events when a new row is added to a table",
version: "0.1.8",
version: "0.1.9",
dedupe: "unique",
type: "source",
props: {
Expand Down Expand Up @@ -56,9 +56,6 @@ export default {
const lastResultId = await this._getIdOfLastRow();
this._setLastResultId(lastResultId);
},
deactivate() {
this._setLastResultId(null);
},
},
methods: {
...common.methods,
Expand Down Expand Up @@ -113,7 +110,15 @@ export default {
limit,
},
};
const rows = await this.getRowsForQuery(queryOpts, this.datasetId);
const client = this.googleCloud
.getBigQueryClient()
.dataset(this.datasetId);
const [
job,
] = await client.createQueryJob(queryOpts);
const [
rows,
] = await job.getQueryResults();
if (rows.length === 0) {
console.log(`
No records found in the target table, will start scanning from the beginning
Expand All @@ -126,15 +131,19 @@ export default {
},
getQueryOpts() {
const lastResultId = this._getLastResultId();
const query = `
let query = `
SELECT *
FROM \`${this.tableId}\`
WHERE \`${this.uniqueKey}\` >= @lastResultId
ORDER BY \`${this.uniqueKey}\` ASC
`;
const params = {
lastResultId,
};
if (lastResultId) {
query += ` WHERE \`${this.uniqueKey}\` >= @lastResultId`;
}
query += ` ORDER BY \`${this.uniqueKey}\` ASC`;
const params = lastResultId
? {
lastResultId,
}
: {};
return {
query,
params,
Expand Down
Loading