From b678ef583c214bfcc1560620495b500a78b2511d Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 26 Mar 2020 16:03:51 -0600 Subject: [PATCH 1/3] added linepart annotation to annotated csv doc, resolves #857 --- .../v2.0/reference/syntax/annotated-csv.md | 133 +++++++++++++----- 1 file changed, 94 insertions(+), 39 deletions(-) diff --git a/content/v2.0/reference/syntax/annotated-csv.md b/content/v2.0/reference/syntax/annotated-csv.md index 854be0c2d..4e0580d76 100644 --- a/content/v2.0/reference/syntax/annotated-csv.md +++ b/content/v2.0/reference/syntax/annotated-csv.md @@ -2,8 +2,9 @@ title: Annotated CSV syntax list_title: Annotated CSV description: > - Flux returns raw results in Annotated CSV format and also reads Annotated CSV - using the `csv.from()` function. + InfluxDB and Flux return query results in Annotated CSV format. + You can also read annotated CSV directly from Flux with the `csv.from()` function + or write data to InfluxDB using annotated CSV and the `influx write` command. weight: 103 menu: v2_0_ref: @@ -14,8 +15,9 @@ aliases: - /v2.0/reference/annotated-csv/ --- -Flux returns raw results in Annotated CSV format and also reads Annotated CSV -using the [`csv.from()` function](/v2.0/reference/flux/stdlib/csv/from/). +InfluxDB and Flux return query results in Annotated CSV format. +You can also read annotated CSV directly from Flux with the [`csv.from()` function](/v2.0/reference/flux/stdlib/csv/from/) +or write data to InfluxDB using annotated CSV and the `influx write` command. CSV tables must be encoded in UTF-8 and Unicode Normal Form C as defined in [UAX15](http://www.unicode.org/reports/tr15/). Line endings must be CRLF (Carriage Return Line Feed) as defined by the `text/csv` @@ -59,7 +61,7 @@ Encoding of a table with and without a header row. {{% /code-tabs %}} {{% code-tab-content %}} -```js +```sh result,table,_start,_stop,_time,region,host,_value my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 @@ -68,7 +70,7 @@ my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east, {{% /code-tab-content %}} {{% code-tab-content %}} -```js +```sh my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 @@ -111,7 +113,7 @@ Encoding of two tables in the same result with the same schema (header row) and {{% /code-tabs %}} {{% code-tab-content %}} -```js +```sh result,table,_start,_stop,_time,region,host,_value my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 @@ -124,7 +126,7 @@ my-result,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west, {{% /code-tab-content %}} {{% code-tab-content %}} -```js +```sh ,result,table,_start,_stop,_time,region,host,_value ,my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 ,my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 @@ -138,7 +140,7 @@ my-result,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west, {{% /code-tab-content %}} {{< /code-tabs-wrapper >}} -### Dialect options +## Dialect options Flux supports the following dialect options for `text/csv` format. @@ -150,25 +152,26 @@ Flux supports the following dialect options for `text/csv` format. | **annotations** | List of annotations to encode (datatype, group, or default). | `empty` | | **commentPrefix** | String prefix to identify a comment. Always added to annotations. | `#` | -### Annotations +## Annotations Annotation rows describe column properties, and start with `#` (or commentPrefix value). The first column in an annotation row always contains the annotation name. Subsequent columns contain annotation values as shown in the table below. -| Annotation name | Values | Description | -|:-------- |:--------- | :------- | -| **datatype** | a [valid data type](#valid-data-types) | Describes the type of data. | -| **group** | boolean flag `true` or `false` | Indicates the column is part of the group key. | -| **default** | a [valid data type](#valid-data-types) | Value to use for rows with an empty string value. | +| Annotation name | Values | Description | +|:-------- |:--------- | :------- | +| **datatype** | a [valid data type](#valid-data-types) | Describes the type of data. | +| **group** | boolean flag `true` or `false` | Indicates the column is part of the group key. | +| **default** | a [valid data type](#valid-data-types) | Value to use for rows with an empty string value. | +| **linepart** | a [valid line protocol element](#line-protocol-and-linepart-annotations) | Indicates how to parse the column into line protocol. | {{% note %}} -To encode a table with its group key, the `datatype`, `group`, and `default` annotations must be included. If a table has no rows, the `default` annotation provides the group key values. +To encode a table with its group key, the `datatype`, `group`, and `default` annotations must be included. +If a table has no rows, the `default` annotation provides the group key values. {{% /note %}} -##### Example - -Example encoding of datatype, group, and default annotations. +### Annotated CSV in a Flux query +Example encoding of datatype, group, and default annotations for using annotated CSV with Flux: ```js import "csv" @@ -177,29 +180,81 @@ csvData = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3 #group,false,false,false,false,false,false,false,false #default,,,,,,,, ,result,table,_start,_stop,_time,region,host,_value -,my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 -,my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 -,my-result,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 -,my-result,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,west,A,62.73 -,my-result,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,west,B,12.83 -,my-result,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west,C,51.62 +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,west,A,62.73 +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,west,B,12.83 +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west,C,51.62 " csv.from(csv: csvData) ``` -### Valid data types +### Annotated CSV with linepart annotations +The `linepart` annotation tells the [`influx write` command](/v2.0/reference/cli/influx/write/) +how to parse the annotated CSV into line protocol when writing to InfluxDB. -| Datatype | Flux type | Description | -| :-------- | :--------- | :---------- | -| boolean | bool | a truth value, one of "true" or "false" | -| unsignedLong | uint | an unsigned 64-bit integer | -| long | int | a signed 64-bit integer | -| double | float | an IEEE-754 64-bit floating-point number | -| string | string | a UTF-8 encoded string | -| base64Binary | bytes | a base64 encoded sequence of bytes as defined in RFC 4648 | -| dateTime | time | an instant in time, may be followed with a colon : and a description of the format | -| duration | duration | a length of time represented as an unsigned 64-bit integer number of nanoseconds | +``` +#linepart measurement,tag,tag,field,field,ignored,time +m,cpu,host,time_steal,usage_user,nothing,time +cpu,cpu1,host1,0,2.7,a,1482669077000000000 +cpu,cpu1,host2,0,2.2,b,1482669087000000000 +``` + +#### Line protocol and linepart annotations +| Linepart key | Description | +|:------------ |:----------- | +| `measurement` | column value parsed as the measurement | +| `field` (default) | column header parsed as field key, column value parsed as field value | +| `tag` | column header parsed as tag key, column value parsed as tag value | +| `time` | column value parsed as timestamp | +| `ignore` or`ignored` | column is not included in line protocol | + +##### Example linepart annotations +``` +#linepart measurement,tag,tag,field,field,ignored,time +m,cpu,host,time_steal,usage_user,nothing,time +cpu,cpu1,host1,0,2.7,a,1482669077000000000 +cpu,cpu1,host2,0,2.2,b,1482669087000000000 +``` + +Resulting line protocol: + +``` +cpu,cpu=cpu1,host=host1 time_steal=0,usage_user=2.7 1482669077000000000 +cpu,cpu=cpu1,host=host1 time_steal=0,usage_user=2.2 1482669087000000000 +``` + +##### Example linepart, datatype, and default annotations +``` +#datatype ,,string,double,boolean,long,unsignedLong,duration, +#linepart measurement,tag,,,,,,,time +#default test,annotatedDatatypes,,,,,, +m,name,s,d,b,l,ul,dur,time +,,str1,1.0,true,1,1,1ms,1 +,,str2,2.0,false,2,2,2us,2020-01-11T10:10:10Z +``` + +Resulting line protocol: + +``` +test,name=annotatedDatatypes s="str1",d=1,b=true,l=1i,ul=1u,dur=1000000i 1 +test,name=annotatedDatatypes s="str2",d=2,b=false,l=2i,ul=2u,dur=2000i 1578737410000000000 +``` + +## Valid data types + +| Datatype | Flux type | Description | +| :-------- | :--------- | :---------- | +| boolean | bool | a truth value, one of "true" or "false" | +| unsignedLong | uint | an unsigned 64-bit integer | +| long | int | a signed 64-bit integer | +| double | float | an IEEE-754 64-bit floating-point number | +| string | string | a UTF-8 encoded string | +| base64Binary | bytes | a base64 encoded sequence of bytes as defined in RFC 4648 | +| dateTime | time | an instant in time, may be followed with a colon : and a description of the format (RFC3339, RFC3339Nano) | +| duration | duration | a length of time represented as an unsigned 64-bit integer number of nanoseconds | ## Errors @@ -218,7 +273,7 @@ If an error occurs: Encoding for an error with the datatype annotation: -```csv +``` #datatype,string,long ,error,reference ,Failed to parse query,897 @@ -226,7 +281,7 @@ Encoding for an error with the datatype annotation: Encoding for an error that occurs after a valid table has been encoded: -```csv +``` #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double ,result,table,_start,_stop,_time,region,host,_value ,my-result,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,west,A,62.73 @@ -234,7 +289,7 @@ Encoding for an error that occurs after a valid table has been encoded: ,my-result,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west,C,51.62 ``` -```csv +``` #datatype,string,long ,error,reference,query terminated: reached maximum allowed memory limits,576 ``` From 8701bf77598d044863fcb41af955977d22645227 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 27 Mar 2020 10:08:34 -0600 Subject: [PATCH 2/3] updated annotated CSV doc to address PR feedback --- .../v2.0/reference/syntax/annotated-csv.md | 168 ++++++++++-------- 1 file changed, 92 insertions(+), 76 deletions(-) diff --git a/content/v2.0/reference/syntax/annotated-csv.md b/content/v2.0/reference/syntax/annotated-csv.md index 4e0580d76..5dad32a11 100644 --- a/content/v2.0/reference/syntax/annotated-csv.md +++ b/content/v2.0/reference/syntax/annotated-csv.md @@ -2,7 +2,7 @@ title: Annotated CSV syntax list_title: Annotated CSV description: > - InfluxDB and Flux return query results in Annotated CSV format. + InfluxDB and Flux return query results in annotated CSV format. You can also read annotated CSV directly from Flux with the `csv.from()` function or write data to InfluxDB using annotated CSV and the `influx write` command. weight: 103 @@ -15,13 +15,12 @@ aliases: - /v2.0/reference/annotated-csv/ --- -InfluxDB and Flux return query results in Annotated CSV format. +InfluxDB and Flux return query results in annotated CSV format. You can also read annotated CSV directly from Flux with the [`csv.from()` function](/v2.0/reference/flux/stdlib/csv/from/) or write data to InfluxDB using annotated CSV and the `influx write` command. CSV tables must be encoded in UTF-8 and Unicode Normal Form C as defined in [UAX15](http://www.unicode.org/reports/tr15/). -Line endings must be CRLF (Carriage Return Line Feed) as defined by the `text/csv` -MIME type in [RFC 4180](https://tools.ietf.org/html/rfc4180). +InfluxDB removes carriage returns before newline characters. ## Examples @@ -158,20 +157,97 @@ Annotation rows describe column properties, and start with `#` (or commentPrefix The first column in an annotation row always contains the annotation name. Subsequent columns contain annotation values as shown in the table below. -| Annotation name | Values | Description | -|:-------- |:--------- | :------- | -| **datatype** | a [valid data type](#valid-data-types) | Describes the type of data. | -| **group** | boolean flag `true` or `false` | Indicates the column is part of the group key. | -| **default** | a [valid data type](#valid-data-types) | Value to use for rows with an empty string value. | -| **linepart** | a [valid line protocol element](#line-protocol-and-linepart-annotations) | Indicates how to parse the column into line protocol. | +| Annotation name | Values | Description | +|:-------- |:--------- | :------- | +| **datatype** | a [data type](#data-types) or [line protocol element](#line-protocol-elements) | Describes the type of data or which line protocol element the column represents. | +| **group** | boolean flag `true` or `false` | Indicates the column is part of the group key. | +| **default** | a value representing the appropriate [data type](#data-types) | Value to use for rows with an empty value. | + {{% note %}} To encode a table with its group key, the `datatype`, `group`, and `default` annotations must be included. If a table has no rows, the `default` annotation provides the group key values. {{% /note %}} -### Annotated CSV in a Flux query -Example encoding of datatype, group, and default annotations for using annotated CSV with Flux: +## Data types + +| Datatype | Flux type | Description | +| :-------- | :--------- | :---------- | +| boolean | bool | "true" or "false" | +| unsignedLong | uint | unsigned 64-bit integer | +| long | int | signed 64-bit integer | +| double | float | IEEE-754 64-bit floating-point number | +| string | string | UTF-8 encoded string | +| base64Binary | bytes | base64 encoded sequence of bytes as defined in RFC 4648 | +| dateTime | time | instant in time, may be followed with a colon : and a description of the format (number, RFC3339, RFC3339Nano) | +| duration | duration | length of time represented as an unsigned 64-bit integer number of nanoseconds | + + +## Line protocol elements +The `datatype` annotation also accepts line protocol elements. +The [`influx write` command](/v2.0/reference/cli/influx/write/) uses the line protocol +element to convert annotated CSV into line protocol when writing to InfluxDB. + +| Line protocol element | Description | +|:--------------------- |:----------- | +| `measurement` | column value is the measurement | +| `field` _(default)_ | column header is the field key, column value is the field value | +| `tag` | column header is the tag key, column value is the tag value | +| `time` | column value is the timestamp _(alias for `dateTime`)_ | +| `ignore` or`ignored` | column is ignored and not included in line protocol | + +### Mixing data types and line protocol elements +Columns with [data types](#data-types) (other than `dataTime`) in the +`#datatype` annotation are treated as **fields** when converted to line protocol. +Columns without a specified data type default to `field` when converted to line protocol +and **column values are left unmodified**. +_See [line protocol data types and format](/v2.0/reference/syntax/line-protocol/#data-types-and-format)._ + +### Time columns +A column with `time` or `dateTime` `#datatype` annotations are used as the timestamp +when converted to line protocol. +If there are multiple `time` or `dateTime` columns, the last (from left to right) +is used as the timestamp in line protocol. +Other time columns are ignored and `influx write` command outputs a warning. + +Time column values should be **Unix timestamps** (in an [accepted precision](/v2.0/write-data/#timestamp-precision)), +**RFC3339 timestamps**, or **RFC3339Nano timestamps**. + +##### Example line protocol elements in datatype annotation +``` +#datatype measurement,tag,tag,field,field,ignored,time +m,cpu,host,time_steal,usage_user,nothing,time +cpu,cpu1,host1,0,2.7,a,1482669077000000000 +cpu,cpu1,host2,0,2.2,b,1482669087000000000 +``` + +Resulting line protocol: + +``` +cpu,cpu=cpu1,host=host1 time_steal=0,usage_user=2.7 1482669077000000000 +cpu,cpu=cpu1,host=host2 time_steal=0,usage_user=2.2 1482669087000000000 +``` + +##### Example of mixing data types line protocol elements +``` +#datatype measurement,tag,string,double,boolean,long,unsignedLong,duration,dateTime +#default test,annotatedDatatypes,,,,,, +m,name,s,d,b,l,ul,dur,time +,,str1,1.0,true,1,1,1ms,1 +,,str2,2.0,false,2,2,2us,2020-01-11T10:10:10Z +``` + +Resulting line protocol: + +``` +test,name=annotatedDatatypes s="str1",d=1,b=true,l=1i,ul=1u,dur=1000000i 1 +test,name=annotatedDatatypes s="str2",d=2,b=false,l=2i,ul=2u,dur=2000i 1578737410000000000 +``` + +## Annotated CSV in Flux +Flux requires all annotation and header rows in annotated CSV. +The example below illustrates how to use the [`csv.from()` function](/v2.0/reference/flux/stdlib/csv/from/) +to read annotated CSV in Flux: ```js import "csv" @@ -191,70 +267,10 @@ csvData = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3 csv.from(csv: csvData) ``` -### Annotated CSV with linepart annotations -The `linepart` annotation tells the [`influx write` command](/v2.0/reference/cli/influx/write/) -how to parse the annotated CSV into line protocol when writing to InfluxDB. - -``` -#linepart measurement,tag,tag,field,field,ignored,time -m,cpu,host,time_steal,usage_user,nothing,time -cpu,cpu1,host1,0,2.7,a,1482669077000000000 -cpu,cpu1,host2,0,2.2,b,1482669087000000000 -``` - -#### Line protocol and linepart annotations -| Linepart key | Description | -|:------------ |:----------- | -| `measurement` | column value parsed as the measurement | -| `field` (default) | column header parsed as field key, column value parsed as field value | -| `tag` | column header parsed as tag key, column value parsed as tag value | -| `time` | column value parsed as timestamp | -| `ignore` or`ignored` | column is not included in line protocol | - -##### Example linepart annotations -``` -#linepart measurement,tag,tag,field,field,ignored,time -m,cpu,host,time_steal,usage_user,nothing,time -cpu,cpu1,host1,0,2.7,a,1482669077000000000 -cpu,cpu1,host2,0,2.2,b,1482669087000000000 -``` - -Resulting line protocol: - -``` -cpu,cpu=cpu1,host=host1 time_steal=0,usage_user=2.7 1482669077000000000 -cpu,cpu=cpu1,host=host1 time_steal=0,usage_user=2.2 1482669087000000000 -``` - -##### Example linepart, datatype, and default annotations -``` -#datatype ,,string,double,boolean,long,unsignedLong,duration, -#linepart measurement,tag,,,,,,,time -#default test,annotatedDatatypes,,,,,, -m,name,s,d,b,l,ul,dur,time -,,str1,1.0,true,1,1,1ms,1 -,,str2,2.0,false,2,2,2us,2020-01-11T10:10:10Z -``` - -Resulting line protocol: - -``` -test,name=annotatedDatatypes s="str1",d=1,b=true,l=1i,ul=1u,dur=1000000i 1 -test,name=annotatedDatatypes s="str2",d=2,b=false,l=2i,ul=2u,dur=2000i 1578737410000000000 -``` - -## Valid data types - -| Datatype | Flux type | Description | -| :-------- | :--------- | :---------- | -| boolean | bool | a truth value, one of "true" or "false" | -| unsignedLong | uint | an unsigned 64-bit integer | -| long | int | a signed 64-bit integer | -| double | float | an IEEE-754 64-bit floating-point number | -| string | string | a UTF-8 encoded string | -| base64Binary | bytes | a base64 encoded sequence of bytes as defined in RFC 4648 | -| dateTime | time | an instant in time, may be followed with a colon : and a description of the format (RFC3339, RFC3339Nano) | -| duration | duration | a length of time represented as an unsigned 64-bit integer number of nanoseconds | +{{% warn %}} +Flux only supports [data types](#data-types) in the `#datatype` annotation. +It does **does not** support [line protocol elements](#line-protocol-elements). +{{% /warn %}} ## Errors From feb3b3568bc1dbebd0f86bd8d3261563f0637d1d Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 27 Mar 2020 13:30:17 -0600 Subject: [PATCH 3/3] updated annotated CSV to address PR feedback --- .../v2.0/reference/syntax/annotated-csv.md | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/content/v2.0/reference/syntax/annotated-csv.md b/content/v2.0/reference/syntax/annotated-csv.md index 5dad32a11..9b1a8db49 100644 --- a/content/v2.0/reference/syntax/annotated-csv.md +++ b/content/v2.0/reference/syntax/annotated-csv.md @@ -161,11 +161,12 @@ Subsequent columns contain annotation values as shown in the table below. |:-------- |:--------- | :------- | | **datatype** | a [data type](#data-types) or [line protocol element](#line-protocol-elements) | Describes the type of data or which line protocol element the column represents. | | **group** | boolean flag `true` or `false` | Indicates the column is part of the group key. | -| **default** | a value representing the appropriate [data type](#data-types) | Value to use for rows with an empty value. | +| **default** | a value of the column's data type | Value to use for rows with an empty value. | {{% note %}} -To encode a table with its group key, the `datatype`, `group`, and `default` annotations must be included. +To encode a table with its [group key](/v2.0/reference/glossary/#group-key), +the `datatype`, `group`, and `default` annotations must be included. If a table has no rows, the `default` annotation provides the group key values. {{% /note %}} @@ -184,9 +185,9 @@ If a table has no rows, the `default` annotation provides the group key values. ## Line protocol elements -The `datatype` annotation also accepts line protocol elements. -The [`influx write` command](/v2.0/reference/cli/influx/write/) uses the line protocol -element to convert annotated CSV into line protocol when writing to InfluxDB. +The `datatype` annotation accepts accepts [data types](#data-types) and **line protocol elements**. +Line protocol elements identify how columns are converted into line protocol when using the +[`influx write` command](/v2.0/reference/cli/influx/write/) to write annotated CSV to InfluxDB. | Line protocol element | Description | |:--------------------- |:----------- | @@ -197,21 +198,22 @@ element to convert annotated CSV into line protocol when writing to InfluxDB. | `ignore` or`ignored` | column is ignored and not included in line protocol | ### Mixing data types and line protocol elements -Columns with [data types](#data-types) (other than `dataTime`) in the +Columns with [data types](#data-types) (other than `dateTime`) in the `#datatype` annotation are treated as **fields** when converted to line protocol. Columns without a specified data type default to `field` when converted to line protocol -and **column values are left unmodified**. -_See [line protocol data types and format](/v2.0/reference/syntax/line-protocol/#data-types-and-format)._ +and **column values are left unmodified** in line protocol. +_See an example [below](#example-of-mixing-data-types-line-protocol-elements) and +[line protocol data types and format](/v2.0/reference/syntax/line-protocol/#data-types-and-format)._ ### Time columns A column with `time` or `dateTime` `#datatype` annotations are used as the timestamp when converted to line protocol. -If there are multiple `time` or `dateTime` columns, the last (from left to right) +If there are multiple `time` or `dateTime` columns, the last column (on the right) is used as the timestamp in line protocol. -Other time columns are ignored and `influx write` command outputs a warning. +Other time columns are ignored and the `influx write` command outputs a warning. -Time column values should be **Unix timestamps** (in an [accepted precision](/v2.0/write-data/#timestamp-precision)), -**RFC3339 timestamps**, or **RFC3339Nano timestamps**. +Time column values should be **Unix timestamps** (in an [accepted timestamp precision](/v2.0/write-data/#timestamp-precision)), +**RFC3339**, or **RFC3339Nano**. ##### Example line protocol elements in datatype annotation ```