Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #310 from Shopify/use-time-column-once
Browse files Browse the repository at this point in the history
Check for timeColumn matches partitioned column
  • Loading branch information
ofir5300 authored Apr 1, 2021
2 parents 15b7820 + 8d6fded commit f8cd9ce
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 @@ -390,21 +390,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 f8cd9ce

Please sign in to comment.