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

Commit 0ffac21

Browse files
authored
Merge pull request #43 from doitintl/avivl/issue-39
Fixes #39
2 parents 57d3f72 + d152239 commit 0ffac21

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

dist/module.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33655,11 +33655,13 @@ function () {
3365533655
};
3365633656

3365733657
BigQueryQuery._getInterval = function (q, alias) {
33658-
if (alias) {
33659-
return q.match(/(?<=.*\$__timeGroupAlias\(([\w_]+,)).*?(?=\))/g);
33660-
} else {
33661-
return q.match(/(?<=.*\$__timeGroup\(([\w_]+,)).*?(?=\))/g);
33658+
var res = alias ? q.match(/(.*\$__timeGroupAlias\(([\w_]+,)).*?(?=\))/g) : q.match(/(.*\$__timeGroup\(([\w_]+,)).*?(?=\))/g);
33659+
33660+
if (res) {
33661+
res = res[0].substr(1 + res[0].lastIndexOf(","));
3366233662
}
33663+
33664+
return res;
3366333665
};
3366433666

3366533667
BigQueryQuery._getIntervalStr = function (interval, timeColumn) {
@@ -33994,6 +33996,8 @@ function () {
3399433996
};
3399533997

3399633998
BigQueryQuery.prototype.expend_macros = function (options) {
33999+
console.log(this.target.rawSql);
34000+
3399734001
if (this.target.rawSql) {
3399834002
var q = this.target.rawSql;
3399934003
q = this.replaceTimeFilters(q, options);
@@ -34030,7 +34034,7 @@ function () {
3403034034
return q;
3403134035
}
3403234036

34033-
var intervalStr = BigQueryQuery._getIntervalStr(interval[0], this.target.timeColumn);
34037+
var intervalStr = BigQueryQuery._getIntervalStr(interval, this.target.timeColumn);
3403434038

3403534039
if (alias) {
3403634040
return q.replace(/\$__timeGroupAlias\(([\w_]+,+[\w_]+\))/g, intervalStr);
@@ -34836,7 +34840,9 @@ function () {
3483634840

3483734841
case 3:
3483834842
queryResults = _a.sent();
34839-
data = data.concat(queryResults.data.projects);
34843+
dataList.forEach(function (element) {
34844+
data = data.concat(queryResults.data[element]);
34845+
});
3484034846
return [3
3484134847
/*break*/
3484234848
, 2];
@@ -36154,7 +36160,7 @@ function () {
3615436160
t.text = t.text.substring(0, partitioned);
3615536161
}
3615636162

36157-
if (!t.value.match(/_(?<!\d)(?:(?:20\d{2})(?:(?:(?:0[13578]|1[02])31)|(?:(?:0[1,3-9]|1[0-2])(?:29|30)))|(?:(?:20(?:0[48]|[2468][048]|[13579][26]))0229)|(?:20\d{2})(?:(?:0?[1-9])|(?:1[0-2]))(?:0?[1-9]|1\d|2[0-8]))(?!\d)$/g)) {
36163+
if (!t.value.match(/_(?:(?:20\d{2})(?:(?:(?:0[13578]|1[02])31)|(?:(?:0[1,3-9]|1[0-2])(?:29|30)))|(?:(?:20(?:0[48]|[2468][048]|[13579][26]))0229)|(?:20\d{2})(?:(?:0?[1-9])|(?:1[0-2]))(?:0?[1-9]|1\d|2[0-8]))(?!\d)$/g)) {
3615836164
sorted = sorted.set(t.value, t.text);
3615936165
} else {
3616036166
sorted.set(t.text.substring(0, t.text.length - 8) + "YYYYMMDD", t.text.substring(0, t.text.length - 8) + "YYYYMMDD");

dist/module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bigquery_query.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ export default class BigQueryQuery {
2626
}
2727

2828
public static _getInterval(q, alias: boolean) {
29-
if (alias) {
30-
return q.match(/(?<=.*\$__timeGroupAlias\(([\w_]+,)).*?(?=\))/g);
31-
} else {
32-
return q.match(/(?<=.*\$__timeGroup\(([\w_]+,)).*?(?=\))/g);
29+
let res = alias
30+
? q.match(/(.*\$__timeGroupAlias\(([\w_]+,)).*?(?=\))/g)
31+
: q.match(/(.*\$__timeGroup\(([\w_]+,)).*?(?=\))/g);
32+
if (res) {
33+
res = res[0].substr(1 + res[0].lastIndexOf(","));
3334
}
35+
return res;
3436
}
3537

3638
public static _getIntervalStr(interval: string, timeColumn: string) {
@@ -432,6 +434,7 @@ export default class BigQueryQuery {
432434
}
433435

434436
public expend_macros(options) {
437+
console.log(this.target.rawSql)
435438
if (this.target.rawSql) {
436439
let q = this.target.rawSql;
437440
q = this.replaceTimeFilters(q, options);
@@ -494,7 +497,7 @@ export default class BigQueryQuery {
494497
}
495498

496499
const intervalStr = BigQueryQuery._getIntervalStr(
497-
interval[0],
500+
interval,
498501
this.target.timeColumn
499502
);
500503
if (alias) {

src/datasource.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,9 @@ export class BigQueryDatasource {
392392
"?pageToken=" +
393393
queryResults.data.nextPageToken
394394
);
395-
data = data.concat(queryResults.data.projects);
395+
dataList.forEach(element => {
396+
data = data.concat(queryResults.data[element]);
397+
});
396398
}
397399
return data;
398400
}

src/response_parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export default class ResponseParser {
284284
}
285285
if (
286286
!t.value.match(
287-
/_(?<!\d)(?:(?:20\d{2})(?:(?:(?:0[13578]|1[02])31)|(?:(?:0[1,3-9]|1[0-2])(?:29|30)))|(?:(?:20(?:0[48]|[2468][048]|[13579][26]))0229)|(?:20\d{2})(?:(?:0?[1-9])|(?:1[0-2]))(?:0?[1-9]|1\d|2[0-8]))(?!\d)$/g
287+
/_(?:(?:20\d{2})(?:(?:(?:0[13578]|1[02])31)|(?:(?:0[1,3-9]|1[0-2])(?:29|30)))|(?:(?:20(?:0[48]|[2468][048]|[13579][26]))0229)|(?:20\d{2})(?:(?:0?[1-9])|(?:1[0-2]))(?:0?[1-9]|1\d|2[0-8]))(?!\d)$/g
288288
)
289289
) {
290290
sorted = sorted.set(t.value, t.text);

0 commit comments

Comments
 (0)