influx-cli icon indicating copy to clipboard operation
influx-cli copied to clipboard

influx write does not quote string field values in line protocol

Open sbrass opened this issue 4 years ago • 0 comments

The influx write command does not quote the field value of a string field and produces a bad request error.

Looking at Line Protocol syntax reference, the second unescaped whitespace leads to the detection of the timestamp field? So, there should be some kind of quoting happening here? Or am I doing something inherently wrong?

Edit: Influx CLI 2.2.1 (git: 31ac78361b) build_date: 2021-11-09T21:19:29Z

Command using extended CSV annotations:

   influx write dryrun --skipHeader 1 --debug --file <some.csv> --skipRowOnError --errors-file=<log-file> --header '#constant measurement,smartcontract' --header '#constant tag,frequency,1d' --header '#constant tag,integration,1d' --header '#datatype ignored,tag,field:string,field:string,field:float,dateTime:2006-01-02' --header ',address,name,symbol,score,timestamp'

Example CSV:

"","address","name","symbol","score","timestamp"
"0","0xdac17f958d2ee523a2206206994597c13d831ec7","Tether: USDT Stablecoin","USDT","0.0032937814801044284","2021-09-01"

Example Output (dryrun):

smartcontract,address=0xdac17f958d2ee523a2206206994597c13d831ec7,frequency=1d,integration=1d name=Tether: USDT Stablecoin,symbol=USDT,score=0.0032937814801044284 1630454400000000000

Output Debug and Error:

2021/12/10 10:49:00 CsvTable{ dataColumns: 6 constantColumns: 3
 measurement: &{Label:#constant measurement DataType:measurement DataFormat: LinePart:2 DefaultValue:smartcontract Index:-1 TimeZone:UTC ParseF:<nil> ComputeValue:<nil> escapedLabel:}
 tag:         &{Label:address DataType:tag DataFormat: LinePart:3 DefaultValue: Index:1 TimeZone:UTC ParseF:<nil> ComputeValue:<nil> escapedLabel:address}
 tag:         &{Label:frequency DataType:tag DataFormat: LinePart:3 DefaultValue:1d Index:-1 TimeZone:UTC ParseF:<nil> ComputeValue:<nil> escapedLabel:frequency}
 tag:         &{Label:integration DataType:tag DataFormat: LinePart:3 DefaultValue:1d Index:-1 TimeZone:UTC ParseF:<nil> ComputeValue:<nil> escapedLabel:integration}
 field:       &{Label:name DataType: DataFormat:string LinePart:4 DefaultValue: Index:2 TimeZone:UTC ParseF:<nil> ComputeValue:<nil> escapedLabel:name}
 field:       &{Label:symbol DataType: DataFormat:string LinePart:4 DefaultValue: Index:3 TimeZone:UTC ParseF:<nil> ComputeValue:<nil> escapedLabel:symbol}
 field:       &{Label:score DataType: DataFormat:float LinePart:4 DefaultValue: Index:4 TimeZone:UTC ParseF:<nil> ComputeValue:<nil> escapedLabel:score}
 time:        &{Label:timestamp DataType:dateTime DataFormat:2006-01-02 LinePart:5 DefaultValue: Index:5 TimeZone:UTC ParseF:<nil> ComputeValue:<nil> escapedLabel:}
}
Error: failed to write data: 400 Bad Request: unable to parse 'smartcontract,address=0xdac17f958d2ee523a2206206994597c13d831ec7,frequency=1d,integration=1d name=Tether: USDT Stablecoin,symbol=USDT,score=0.0032937814801044284 1630454400000000000': invalid boolean

sbrass avatar Dec 10 '21 09:12 sbrass