Fix AST influxql for parsing binary expressions in fields

pull/10616/head
Chris Goller 2017-05-02 12:36:56 -05:00
parent 66429dddce
commit ebe15248b0
2 changed files with 14 additions and 0 deletions

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) {