From 73c83be7ae42a2ebeb226fb2a6edb3733fb52c63 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 30 Oct 2019 15:54:11 -0600 Subject: [PATCH] added predicate delete syntax doc, resolves #565 --- .../reference/cli/influx/delete/_index.md | 20 ++--- .../v2.0/reference/syntax/annotated-csv.md | 2 +- .../v2.0/reference/syntax/delete-predicate.md | 82 +++++++++++++++++++ 3 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 content/v2.0/reference/syntax/delete-predicate.md diff --git a/content/v2.0/reference/cli/influx/delete/_index.md b/content/v2.0/reference/cli/influx/delete/_index.md index f73c0e73a..ebb55aa53 100644 --- a/content/v2.0/reference/cli/influx/delete/_index.md +++ b/content/v2.0/reference/cli/influx/delete/_index.md @@ -23,16 +23,16 @@ timestamps between the specified `--start` and `--stop` times in the specified b {{% /warn %}} ## Flags -| Flag | Description | Input type | -|:---- |:----------- |:----------:| -| `-b`, `--bucket` | The name of bucket to remove data from | string | -| `--bucket-id` | The ID of the bucket to remove data from | string | -| `-h`, `--help` | Help for the `delete` command | | -| `-o`, `--org` | The name of the organization that owns the bucket | string | -| `--org-id` | The ID of the organization that owns the bucket | string | -| `-p`, `--predicate` | SQL-like predicate string (i.e. `tag1="v1" and tag2=123`) | string | -| `--start` | The start time in RFC3339 format (i.e. `2009-01-02T23:00:00Z`) | string | -| `--stop` | The stop time in RFC3339 format (i.e. `2009-01-02T23:00:00Z`) | string | +| Flag | Description | Input type | +|:---- |:----------- |:----------:| +| `-b`, `--bucket` | The name of bucket to remove data from | string | +| `--bucket-id` | The ID of the bucket to remove data from | string | +| `-h`, `--help` | Help for the `delete` command | | +| `-o`, `--org` | The name of the organization that owns the bucket | string | +| `--org-id` | The ID of the organization that owns the bucket | string | +| `-p`, `--predicate` | SQL-like predicate string (see [Delete predicate](/v2.0/reference/syntax/delete-predicate)) | string | +| `--start` | The start time in RFC3339 format (i.e. `2009-01-02T23:00:00Z`) | string | +| `--stop` | The stop time in RFC3339 format (i.e. `2009-01-02T23:00:00Z`) | string | ## Global flags | Global flag | Description | Input type | diff --git a/content/v2.0/reference/syntax/annotated-csv.md b/content/v2.0/reference/syntax/annotated-csv.md index aa505df2e..7b90dfbfc 100644 --- a/content/v2.0/reference/syntax/annotated-csv.md +++ b/content/v2.0/reference/syntax/annotated-csv.md @@ -4,7 +4,7 @@ list_title: Annotated CSV description: > Flux returns raw results in Annotated CSV format and also reads Annotated CSV using the `csv.from()` function. -weight: 106 +weight: 103 menu: v2_0_ref: parent: Syntax diff --git a/content/v2.0/reference/syntax/delete-predicate.md b/content/v2.0/reference/syntax/delete-predicate.md new file mode 100644 index 000000000..d132a14b2 --- /dev/null +++ b/content/v2.0/reference/syntax/delete-predicate.md @@ -0,0 +1,82 @@ +--- +title: Delete predicate syntax +list_title: Delete predicate +description: > + The InfluxDB `/delete` endpoint uses a SQL-like predicate syntax to determine + what data points to delete. +menu: + v2_0_ref: + parent: Syntax + name: Delete predicate +weight: 104 +v2.0/tags: [syntax, delete] +related: + - /v2.0/reference/cli/influx/delete/ +--- + +The InfluxDB `/delete` endpoint uses a SQL-like predicate syntax to determine +what data [points](/v2.0/reference/glossary/#point) to delete. +InfluxDB uses the delete predicate to evaluate each point in the time range +specified in the delete request. +Points that evaluate to `true` are deleted. +Points that evaluate to `false` are preserved. + +A delete predicate is comprised of one or more [predicate expressions](/v2.0/reference/glossary/#predicate-expression). +The left operand of the predicate expression is the column name. +The right operand is the column value. +Operands are compared using [comparison operators](#comparison-operators). +Use [logical operators](#logical-operators) to combine two or more predicate expressions. + +##### Example delete predicate +```sql +key1="value1" AND key2="value" +``` +{{% note %}} +Predicate expressions can use any column or tag except `_time` or `_value`. +{{% /note %}} + +## Logical operators +Logical operators join two or more predicate expressions. + +| Operator | Description | +|:-------- |:----------- | +| `AND` | Both left and right operands must be `true` for the expression to be `true`. | + +## Comparison operators +Comparison operators compare left and right operands and return `true` or `false`. + +| Operator | Description | Example | Result | +|:-------- |:----------- |:-------: |:------:| +| `=` | Equal to | `"abc"="abc"` | `true` | +| `!=` | Not equal to | `"abc"!="def"` | `true` | + + +## Delete predicate examples + +### Delete a measurement +The following will delete points in the `sensorData` measurement: + +```sql +_measurement="sensorData" +``` + +### Delete a field +The following will delete points with the `temperature` field: + +```sql +_field="temperature" +``` + +### Delete points with a specific tag set +The following will delete points from the `prod-1.4` host in the `us-west` region: + +```sql +host="prod-1.4" AND region="us-west" +``` + +## Limitations +The delete predicate syntax has the following limitations. + +- Delete predicates do not support regular expressions. +- Delete predicates do not support the `OR` logical operator. +- Delete predicates can use any column or tag except `_time` or `_value`.