|
|
|
@ -162,6 +162,63 @@ describe('Test sql processing', function() {
|
|
|
|
|
check(original, expected); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('sql with $__timeGroup aggregation', function () { |
|
|
|
|
const original = `SELECT
|
|
|
|
|
$__timeGroup("time", $__interval, NULL), |
|
|
|
|
avg("metric") AS "Réseau" |
|
|
|
|
FROM metric_values |
|
|
|
|
WHERE $__timeFilter("time") |
|
|
|
|
GROUP BY 1 |
|
|
|
|
ORDER BY 1`;
|
|
|
|
|
const expected = `SELECT
|
|
|
|
|
"time", |
|
|
|
|
avg("metric") AS "Réseau" |
|
|
|
|
FROM metric_values |
|
|
|
|
WHERE $__timeFilter("time") |
|
|
|
|
GROUP BY 1 |
|
|
|
|
ORDER BY 1 LIMIT ${limit} OFFSET ${offset}`;
|
|
|
|
|
check(original, expected); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('sql with $__timeGroupAlias aggregation', function () { |
|
|
|
|
const original = `SELECT
|
|
|
|
|
$__timeGroupAlias("time", $__interval), |
|
|
|
|
avg("metric") AS "Réseau" |
|
|
|
|
FROM metric_values |
|
|
|
|
WHERE $__timeFilter("time") |
|
|
|
|
GROUP BY 1 |
|
|
|
|
ORDER BY 1`;
|
|
|
|
|
const expected = `SELECT
|
|
|
|
|
"time", |
|
|
|
|
avg("metric") AS "Réseau" |
|
|
|
|
FROM metric_values |
|
|
|
|
WHERE $__timeFilter("time") |
|
|
|
|
GROUP BY 1 |
|
|
|
|
ORDER BY 1 LIMIT ${limit} OFFSET ${offset}`;
|
|
|
|
|
check(original, expected); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('sql with $__timeGroupAlias aggregation and linebreaks', function () { |
|
|
|
|
const original = `SELECT
|
|
|
|
|
$__timeGroupAlias( |
|
|
|
|
any_field, |
|
|
|
|
$__interval |
|
|
|
|
), |
|
|
|
|
avg("metric") AS "Réseau" |
|
|
|
|
FROM metric_values |
|
|
|
|
WHERE $__timeFilter(any_field) |
|
|
|
|
GROUP BY 1 |
|
|
|
|
ORDER BY 1`;
|
|
|
|
|
const expected = `SELECT
|
|
|
|
|
any_field, |
|
|
|
|
avg("metric") AS "Réseau" |
|
|
|
|
FROM metric_values |
|
|
|
|
WHERE $__timeFilter(any_field) |
|
|
|
|
GROUP BY 1 |
|
|
|
|
ORDER BY 1 LIMIT ${limit} OFFSET ${offset}`;
|
|
|
|
|
check(original, expected); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('complex sql with one select', function() { |
|
|
|
|
let original = `SELECT
|
|
|
|
|
statistics.created_at as time, |
|
|
|
|