Skip to content

Commit

Permalink
Require calculations w/ a group by clause.
Browse files Browse the repository at this point in the history
  • Loading branch information
notbdu committed Feb 11, 2019
1 parent e0d1341 commit 8e7c96a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions query/unparsed_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
errTimeGranularityWithCalculations = errors.New("both time granularity and calculation clauses are specified in the query")
errTimeGranularityWithOrderBy = errors.New("both time granularity and order by clauses are specified in the query")
errCalculationsWithNoGroups = errors.New("calculations provided with no groups")
errGroupByWithNoCalculations = errors.New("group by provided with no calculations")
)

// UnparsedQuery represents an unparsed document query useful for serializing/deserializing in JSON.
Expand Down Expand Up @@ -318,6 +319,9 @@ func (q *UnparsedQuery) validateGroupBy() error {
if q.TimeGranularity != nil {
return errTimeGranularityWithGroupBy
}
if len(q.Calculations) == 0 {
return errGroupByWithNoCalculations
}
return nil
}

Expand Down

0 comments on commit 8e7c96a

Please sign in to comment.