I am trying to store multiple sources into the same table, with a column that is a text field.
When i try to insert a float into a text field, i get an error message saying that its a text field!
I would like to know:
when will the ::string cast feature be added to influxdb? This way i can cast the float before inserting into a text field.
why not just insert to float into the text field, without giving an error?
How are you writing the points? If you’re using line protocol directly, then instead of foo x=3.14 surround the value with double quotes, i.e. foo x="3.14".
We’ve chosen to prefer type safety over implicit type coercion. There are some functions that work on floats and integers but not strings (e.g. mean, sum). Rather than silently coercing your float data to a string field just to find that you later can’t perform the mathematical operations that you need, we decided to reject the write.
I have broken down the commands we use to fill the data:
INFLUXDB_URL=http://influxdb/write?db=database"
metric1="table1,mytag=tagname mystringvalue=string"
echo metric1 | curl -s -m 10 -i -XPOST $INFLUXDB_URL --data-binary @-
metric2="table2,mytag=tagname myfloatvalue=1024"
echo metric2 | curl -s -m 10 -i -XPOST $INFLUXDB_URL --data-binary @-
Continuous queries:
CREATE CONTINUOUS QUERY cq_metric1 ON database BEGIN
SELECT mytag AS mytag,
mystringvalue AS myvalue
FROM database."default".table1
INTO database."default".finaltable
GROUP BY time(1d)
END
CREATE CONTINUOUS QUERY cq_metric2 ON database BEGIN
SELECT mytag AS mytag,
myfloatvalue AS myvalue
FROM database."default".table2
INTO database."default".finaltable
GROUP BY time(1d)
END
And the problem is with the seconds continuous query with inserting myfloatvalue
But if i understand you correctly, i have to do this:
That’s right. If you want to use a CQ to insert a float value into a string field, you’ll need to store the original value as a string in the first place.
I briefly looked for open issues about casting value to string and I didn’t see one.
It might be possible to cast a float to a string in Kapacitor, but I’m not sure.