feat(tsdb): Implement delete with predicate. #20236
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This pull request implements the "delete with predicate" API that was previously disabled. It works by implementing a new
tsdb.Store.DeleteSeriesWithPredicate()
function that operates on a predicate directly instead of aninfluxql.Expr
. This PR also adds aPredicateSeriesIDIterator
that filters an underlying iterator by predicate.Note: The predicate does not currently support
OR
. That will need to be implemented separately.Closes #19635
Usage
Write two points into the
influx
bucket:Query to verify points exist.
$ influx query 'from(bucket:"influx")|>range(start:0)' Result: _result Table: keys: [_start, _stop, _field, _measurement, region] _start:time _stop:time _field:string _measurement:string region:string _time:time _value:float ------------------------------ ------------------------------ ---------------------- ---------------------- ---------------------- ------------------------------ ---------------------------- 1970-01-01T00:00:00.000000000Z 2020-12-02T17:00:07.917155000Z value cpu us-east-1 2020-12-02T17:00:03.448750000Z 1 Table: keys: [_start, _stop, _field, _measurement, region] _start:time _stop:time _field:string _measurement:string region:string _time:time _value:float ------------------------------ ------------------------------ ---------------------- ---------------------- ---------------------- ------------------------------ ---------------------------- 1970-01-01T00:00:00.000000000Z 2020-12-02T17:00:07.917155000Z value cpu us-west-1 2020-12-02T17:00:06.027808000Z 1
Delete point in
us-west-1
using predicate:$ influx delete --org influx --bucket influx --start 2020-12-01T00:00:00Z --stop 2020-12-31T00:00:00Z --predicate '_measurement="cpu" AND region="us-west-1"'
Query again to verify only one point exists:
TODO