Unable to use type float?[Solved]

The documentation indicates Float is a supported type: Line Protocol Reference | InfluxDB OSS 1.3 Documentation

but I get errors trying to use a POJO with a field with type float. I have tried the primitive float and Object Float:
org.influxdb.InfluxDBMapperException: Class ‘xxx.dao.influx.DBIdleNoiseAggrTimeSeries’ field ‘average’ is from an unsupported type ‘float’

org.influxdb.InfluxDBMapperException: Class ‘xxx.dao.influx.DBIdleNoiseAggrTimeSeries’ field ‘average’ is from an unsupported type ‘java.lang.Float’

Answered: looks like it is a 32 bit/ 64 bit definition thing - Double works great.

2 Likes

Sorry you had to answer your own question, but you are exactly right. InfluxDB uses float64 as the data type, so it is expecting a 64-bit value for float. Depending on what you’re using to send the data, you may have to use double, float64, etc.

dg

@davidgs, and @ kquinn I am working on writing data-frame to Influx-db where the values of each item is float. I tried converting the datatype of data-point to be float/double/np.float64 but every-time, the points are being stored as string & not double. I am using InfluxDB 2.1.1.

A bit about what & how it is being stored:
‘’’
p10 = pd.DataFrame(np.exp(p10)).astype(np.float64)
p10.columns = [“lower”]

p50 = pd.DataFrame(np.exp(p50)).astype(np.float64)
p50.columns = [“pred”]

p90 = pd.DataFrame(np.exp(p90)).astype(np.float64) // “double”
p90.columns = [“upper”]
‘’’

print("data : ", type(data[“lower-bps”].values[1])) // always return data : <class ‘float’>
_logger.info(“Writing forecasted data to InfluxDB bucket %s”, bucket)
with self._influxdb_client.write_api() as w_client:
w_client.write(
bucket=bucket,
record=data,
data_frame_measurement_name=measurement,
data_frame_tag_columns=tags,
)

However, in the DB, the output is STRING type. Though not missing any value here. But appreciate if the reason can be explained. Explored a lot but could not find any answer.