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

Fix regression when math between literals is used in a field #9443

Merged
merged 1 commit into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions query/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,15 @@ func (c *compiledStatement) compileFields(stmt *influxql.SelectStatement) error

// Append this field to the list of processed fields and compile it.
field := &compiledField{
global: c,
Field: f,
global: c,
Field: &influxql.Field{
Expr: influxql.Reduce(f.Expr, nil),
Alias: f.Alias,
},
AllowWildcard: true,
}
c.Fields = append(c.Fields, field)
if err := field.compileExpr(f.Expr); err != nil {
if err := field.compileExpr(field.Field.Expr); err != nil {
return err
}
}
Expand Down
1 change: 1 addition & 0 deletions query/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestCompile_Success(t *testing.T) {
`SELECT value FROM cpu WHERE time >= '2000-01-01T00:00:00Z' AND time <= '2000-01-01T01:00:00Z'`,
`SELECT value FROM (SELECT value FROM cpu) ORDER BY time DESC`,
`SELECT count(distinct(value)), max(value) FROM cpu`,
`SELECT last(value) / (1 - 0) FROM cpu`,
} {
t.Run(tt, func(t *testing.T) {
stmt, err := influxql.ParseStatement(tt)
Expand Down