Skip to content

Commit

Permalink
segmentMetadata debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jbguerraz committed Nov 29, 2020
1 parent ed3ecd1 commit cfa48fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 9 additions & 6 deletions builder/query/segment_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,25 @@ func (s *SegmentMetadata) SetLenientAggregatorMerge(lenientAggregatorMerge bool)
}

func (s *SegmentMetadata) UnmarshalJSON(data []byte) error {
var err error
var tmp struct {
Base
ToInclude json.RawMessage `json:"toInclude,omitempty"`
Merge bool `json:"merge,omitempty"`
AnalysisTypes []AnalysisType `json:"analysisTypes,omitempty"`
UsingDefaultInterval bool `json:"usingDefaultInterval,omitempty"`
LenientAggregatorMerge bool `json:"lenientAggregatorMerge,omitempty"`
}
if err := json.Unmarshal(data, &tmp); err != nil {
if err = json.Unmarshal(data, &tmp); err != nil {
return err
}
t, err := toinclude.Load(tmp.ToInclude)
if err != nil {
return err
var t builder.ToInclude
if tmp.ToInclude != nil {
t, err = toinclude.Load(tmp.ToInclude)
if err != nil {
return err
}
}
s.Base = tmp.Base
s.Base.UnmarshalJSON(data)
s.ToInclude = t
s.Merge = tmp.Merge
s.AnalysisTypes = tmp.AnalysisTypes
Expand Down
5 changes: 5 additions & 0 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,9 @@ func main() {
spew.Dump(q, err)
d.Query().Execute(q, &results)
spew.Dump(results)

q, err = d.Query().Load([]byte("{\"context\":{\"a\":\"a\"},\"dataSource\":{\"name\":\"wikipedia\",\"type\":\"table\"},\"intervals\":[],\"queryType\":\"segmentMetadata\"}"))
spew.Dump(q, err)
d.Query().Execute(q, &results)
spew.Dump(results)
}

0 comments on commit cfa48fb

Please sign in to comment.