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

Commit f8cd9ce

Browse files
authored
Merge pull request #310 from Shopify/use-time-column-once
Check for timeColumn matches partitioned column
2 parents 15b7820 + 8d6fded commit f8cd9ce

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/bigquery_query.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -390,21 +390,25 @@ export default class BigQueryQuery {
390390
});
391391
if (this.target.partitioned) {
392392
const partitionedField = this.target.partitionedField ? this.target.partitionedField : '_PARTITIONTIME';
393-
if (this.templateSrv.timeRange && this.templateSrv.timeRange.from) {
394-
const from = `${partitionedField} >= '${BigQueryQuery.formatDateToString(
395-
this.templateSrv.timeRange.from._d,
396-
'-',
397-
true
398-
)}'`;
399-
conditions.push(from);
400-
}
401-
if (this.templateSrv.timeRange && this.templateSrv.timeRange.to) {
402-
const to = `${partitionedField} < '${BigQueryQuery.formatDateToString(
403-
this.templateSrv.timeRange.to._d,
404-
'-',
405-
true
406-
)}'`;
407-
conditions.push(to);
393+
if (this.target.timeColumn !== partitionedField) {
394+
if (this.templateSrv.timeRange && this.templateSrv.timeRange.from) {
395+
let fromD = this.templateSrv.timeRange.from;
396+
const from = `${partitionedField} >= '${BigQueryQuery.formatDateToString(
397+
fromD._d,
398+
'-',
399+
true
400+
)}'`;
401+
conditions.push(from);
402+
}
403+
if (this.templateSrv.timeRange && this.templateSrv.timeRange.to) {
404+
let toD = this.templateSrv.timeRange.to;
405+
const to = `${partitionedField} < '${BigQueryQuery.formatDateToString(
406+
toD._d,
407+
'-',
408+
true
409+
)}'`;
410+
conditions.push(to);
411+
}
408412
}
409413
}
410414
if (this.target.sharded) {

0 commit comments

Comments
 (0)