Skip to content

Commit

Permalink
Merge pull request #3 from Shopify/use-time-column-once
Browse files Browse the repository at this point in the history
Check for timeColumn is partitioned column
  • Loading branch information
tanner-bruce authored Jan 21, 2021
2 parents f8a86ee + 8d6fded commit aede26a
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/bigquery_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,21 +387,25 @@ export default class BigQueryQuery {
});
if (this.target.partitioned) {
const partitionedField = this.target.partitionedField ? this.target.partitionedField : '_PARTITIONTIME';
if (this.templateSrv.timeRange && this.templateSrv.timeRange.from) {
const from = `${partitionedField} >= '${BigQueryQuery.formatDateToString(
this.templateSrv.timeRange.from._d,
'-',
true
)}'`;
conditions.push(from);
}
if (this.templateSrv.timeRange && this.templateSrv.timeRange.to) {
const to = `${partitionedField} < '${BigQueryQuery.formatDateToString(
this.templateSrv.timeRange.to._d,
'-',
true
)}'`;
conditions.push(to);
if (this.target.timeColumn !== partitionedField) {
if (this.templateSrv.timeRange && this.templateSrv.timeRange.from) {
let fromD = this.templateSrv.timeRange.from;
const from = `${partitionedField} >= '${BigQueryQuery.formatDateToString(
fromD._d,
'-',
true
)}'`;
conditions.push(from);
}
if (this.templateSrv.timeRange && this.templateSrv.timeRange.to) {
let toD = this.templateSrv.timeRange.to;
const to = `${partitionedField} < '${BigQueryQuery.formatDateToString(
toD._d,
'-',
true
)}'`;
conditions.push(to);
}
}
}
if (this.target.sharded) {
Expand Down

0 comments on commit aede26a

Please sign in to comment.