Merge pull request #1376 from influxdata/bugfix/influx-math-funcs

Fix AST influxql for parsing binary expressions in fields
pull/10616/head
Chris Goller 2017-05-02 13:50:58 -05:00 committed by GitHub
commit a09a5f5687
3 changed files with 15 additions and 0 deletions

View File

@ -3,6 +3,7 @@
### Bug Fixes
1. [#1364](https://github.com/influxdata/chronograf/pull/1364): Fix link to home when using the --basepath option
1. [#1370](https://github.com/influxdata/chronograf/pull/1370): Remove notification to login outside of session timeout
1. [#1376](https://github.com/influxdata/chronograf/pull/1376): Fix queries built in query builder with math functions in fields
### Features
### UI Improvements

View File

@ -102,6 +102,8 @@ func Convert(influxQL string) (chronograf.QueryConfig, error) {
fields := map[string][]string{}
for _, fld := range stmt.Fields {
switch f := fld.Expr.(type) {
default:
return raw, nil
case *influxql.Call:
// only support certain query config functions
if _, ok := supportedFuncs[f.Name]; !ok {

View File

@ -27,6 +27,18 @@ func TestConvert(t *testing.T) {
},
},
},
{
name: "Test math",
influxQL: `SELECT count("event_id")/3 as "event_count_id" from discource.autogen.discourse_events where time > now() - 7d group by time(1d), "event_type"`,
RawText: `SELECT count("event_id")/3 as "event_count_id" from discource.autogen.discourse_events where time > now() - 7d group by time(1d), "event_type"`,
want: chronograf.QueryConfig{
Fields: []chronograf.Field{},
Tags: map[string][]string{},
GroupBy: chronograf.GroupBy{
Tags: []string{},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {