Updating the multiple fields which has different data type in influx DB

Hi,
I am trying to update the influx db by using the below query :
from(bucket: “TestBucket”)
|> range(start: -8h)
|> filter(fn: (r) => r._measurement == “Line1”)
|> filter(fn: (r) => r[“line”] == “Line1”)
|> filter(fn: (r) => r[“packer”] == “Packer”)
|> filter(fn: (r) => r[“category”] == “StopLog”)
|> filter(fn: (r) => r[“shiftEndDateTime”] == “16/11/2023 21:59:59”)
|> filter(fn: (r) => r[“shiftStartDateTime”] == “16/11/2023 14:00:00”)
|> filter(fn: (r) => r[“_field”] == “endTime” or r[“_field”] == “duration”)
|> last()
|> map(fn: (r) => ({
r with
_value: if r._field == “endTime” then “16/11/2023 16:59:44”
else if r._field == “duration” then 35.0
else r._value
}))
|> to(bucket: “TestBucket”)
But i am not able to update due to the datatypes being different can someone please help .

Hello @vidhisha,

Yes unfortunately that’s true. You’ll have to have the same datatypes. The easiest way to accommodate this would be to make everything a string. You’ll either have to make 35.0 a string and then the _value as well.

|> map(fn: (r) => ({
r with
_value: if r._field == “endTime” then “16/11/2023 16:59:44”
else if r._field == “duration” then "35.0"
else string(v: r._value)
}))