-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Add fields to frame if it does not already exist when grouping by multiple terms #392
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -999,7 +999,11 @@ func (rp *responseParser) processAggregationDocs(esAgg *simplejson.Json, aggDef | |
frames := data.Frames{} | ||
var fields []*data.Field | ||
|
||
if queryResult.Frames == nil { | ||
if queryResult.Frames != nil && len(queryResult.Frames) != 0 { | ||
for _, frame := range queryResult.Frames { | ||
fields = append(fields, frame.Fields...) | ||
} | ||
} else { | ||
for _, propKey := range propKeys { | ||
fields = append(fields, data.NewField(propKey, nil, []*string{})) | ||
} | ||
|
@@ -1012,7 +1016,8 @@ func (rp *responseParser) processAggregationDocs(esAgg *simplejson.Json, aggDef | |
for _, e := range fields { | ||
for _, propKey := range propKeys { | ||
if e.Name == propKey { | ||
e.Append(props[propKey]) | ||
value := props[propKey] | ||
e.Append(&value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious - did something in the sdk or elsewhere change, or did this code path never get executed before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this bit of the code used to build the results the same way as the frontend flow (building a table), but was refactored to use data frames instead. that refactoring was done by following elasticsearch's pr (which had the same bug that this PR is addressing). so it probably wasn't being executed from that point onwards. but we didn't notice because the backend flow would've only been run for alerts or in explore and it would've only been an issue if someone was using multiple group by terms.
kevinwcyu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
if e.Name == aggDef.Field { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: you can just write
if len(queryResult.Frames) != 0
here - you'd only need the nil check ifqueryResult.Frames
was a pointer.