Pass binary expressions to the underlying query
Binary math inside of a where condition was previously disallowed. Now, these types of queries are just passed verbatim down to the underlying query engine which can handle it. We may want to revisit this when it comes to tags at some point as it prevents the more efficient filtering of tags that a simple expression allows, but it allows a query like this to be done: SELECT * FROM cpu WHERE value + 2 < 5 So while it can be better, this is a good initial implementation to provide this functionality. There are very rare situations where a tag may be used appropriately in one of these circumstances. Fixes #3558.pull/6411/head
parent
5070f69bb2
commit
d26e4e3650
|
@ -15,6 +15,7 @@
|
|||
- [#1856](https://github.com/influxdata/influxdb/issues/1856): Add `elapsed` function that returns the time delta between subsequent points.
|
||||
- [#5502](https://github.com/influxdata/influxdb/issues/5502): Add checksum verification to TSM inspect tool
|
||||
- [#6444](https://github.com/influxdata/influxdb/pull/6444): Allow setting the config path through an environment variable and default config path.
|
||||
- [#3558](https://github.com/influxdata/influxdb/issues/3558): Support field math inside a WHERE clause.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
|
|
|
@ -747,6 +747,15 @@ func mergeSeriesFilters(op influxql.Token, ids SeriesIDs, lfilters, rfilters Fil
|
|||
// idsForExpr will return a collection of series ids and a filter expression that should
|
||||
// be used to filter points from those series.
|
||||
func (m *Measurement) idsForExpr(n *influxql.BinaryExpr) (SeriesIDs, influxql.Expr, error) {
|
||||
// If this binary expression has another binary expression, then this
|
||||
// is some expression math and we should just pass it to the underlying query.
|
||||
if _, ok := n.LHS.(*influxql.BinaryExpr); ok {
|
||||
return m.seriesIDs, n, nil
|
||||
} else if _, ok := n.RHS.(*influxql.BinaryExpr); ok {
|
||||
return m.seriesIDs, n, nil
|
||||
}
|
||||
|
||||
// Retrieve the variable reference from the correct side of the expression.
|
||||
name, ok := n.LHS.(*influxql.VarRef)
|
||||
value := n.RHS
|
||||
if !ok {
|
||||
|
|
Loading…
Reference in New Issue