Browse Source

SQL: support Grafana aggregation macros ($__timeGroup and $__timeGroupAlias)

pull/13/head
rozetko 2 years ago
parent
commit
7a01a86ddb
  1. 6
      src/connectors/utils.ts

6
src/connectors/utils.ts

@ -8,6 +8,12 @@ export function processSQLLimitOffset(sql: string, limit: number, offset: number
} }
sql = splits[0]; // removes ";" from EOL sql = splits[0]; // removes ";" from EOL
const reAggregation = /\$__timeGroup(?:Alias)?\(\s*([^,]+)\s*,\s*\$__interval[^\)]*\)/igm;
const occurence = reAggregation.exec(sql);
if(occurence) {
sql = sql.replace(reAggregation, occurence[1]);
}
let relim = /limit [0-9]+/ig; let relim = /limit [0-9]+/ig;
let reoff = /offset [0-9]+/ig; let reoff = /offset [0-9]+/ig;

Loading…
Cancel
Save