Skip to content
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

Group by should require an aggregate #2034

Merged
merged 5 commits into from
Mar 20, 2015
Merged

Conversation

influxdb-denver-pair
Copy link

fixes #2017

@@ -217,7 +217,7 @@ type Batch struct {
// Return all the measurements from the given DB
func (h *Handler) showMeasurements(db string, user *influxdb.User) ([]string, error) {
var measurements []string
results := h.server.ExecuteQuery(&influxql.Query{[]influxql.Statement{&influxql.ShowMeasurementsStatement{}}}, db, user)
results := h.server.ExecuteQuery(&influxql.Query{Statements: []influxql.Statement{&influxql.ShowMeasurementsStatement{}}}, db, user)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was failing a vet check from a previous commit.

@influxdb-denver-pair
Copy link
Author

Several tests were not valid due to not having an aggregate specified. They have been updated as part of this PR.

@@ -585,6 +585,10 @@ func (p *Parser) parseSelectStatement(tr targetRequirement) (*SelectStatement, e
}
})

if d, _ := stmt.GroupByInterval(); stmt.IsRawQuery && d > 0 {
return nil, fmt.Errorf("group by needs at least one aggregate function")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to a better error message if someone has ideas.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps capitalize it, to make it clear it's influxql, and I think "requires" reads better. I.e. "GROUP BY requires at least one aggregate function"

@otoolep
Copy link
Contributor

otoolep commented Mar 20, 2015

I have some minor feedback, which I think would improve the code. +1 on a green build.

@corylanou corylanou force-pushed the groupby-requires-aggregate branch from bc056d2 to dd6bb91 Compare March 20, 2015 22:54
corylanou added a commit that referenced this pull request Mar 20, 2015
@corylanou corylanou merged commit 5acea92 into master Mar 20, 2015
@corylanou corylanou deleted the groupby-requires-aggregate branch March 20, 2015 22:57
mark-rushakoff pushed a commit that referenced this pull request Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parser should return error if no aggregate with group by time
3 participants