Querybuilder has a problem with strings which contain `$rate` and `From` in field names
See original GitHub issueIn Grafana I have a template variable $UserName and I put following statement into the Querybuilder
$rate(countIf(StatusCode='200') AS Success, countIf(StatusCode!='200') AS Fail) FROM $table
WHERE Direction in ($UserDirection)
$conditionalTest(AND (FromUser like '%$UserName%' or ToUser like '%$UserName%'),$UserName)
This produces following wrong query:
SELECT t, Success/runningDifference(t/1000) SuccessRate, Fail/runningDifference(t/1000) FailRate FROM ( SELECT (intDiv(toUInt32(CallTime), 1) * 1) * 1000 AS t, countIf(StatusCode = '200') AS Success, countIf(StatusCode != '200') AS Fail FromUser like '%bob%' or ToUser like '%bob%') WHERE CallTime BETWEEN toDateTime(1595870047) AND toDateTime(1595870349) GROUP BY t ORDER BY t)
If I change the conditionalTest from:
$conditionalTest(AND (FromUser like '%$UserName%' or ToUser like '%$UserName%'),$UserName)
To something like:
$conditionalTest(AND (ToUser like '%$UserName%' or ToUser like '%$UserName%'),$UserName)
Querybuilder produces the right query:
SELECT t, Success/runningDifference(t/1000) SuccessRate, Fail/runningDifference(t/1000) FailRate FROM ( SELECT (intDiv(toUInt32(CallTime), 1) * 1) * 1000 AS t, countIf(StatusCode = '200') AS Success, countIf(StatusCode != '200') AS Fail FROM cdrmon.call_log WHERE CallTime BETWEEN toDateTime(1595870018) AND toDateTime(1595870320) AND Direction in (['incoming']) AND (ToUser like '%bob%' or ToUser like '%bob%') GROUP BY t ORDER BY t)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top GitHub Comments
@negbie thanks a lot for reporting, i will fix it ASAP
@Slach works, thank you very much!