Search code examples
influxdb

Storing numbers above 2e19


I am using InfluxDB and need to store very large numbers (uint256) with full precision (no floating point).

I am currently using strings to achieve this, but I thus loose the ability to perform arithmetic operations on these numbers, which is something I need to implement.

ex.

{ _measurement=transfer, _field=amount, _value=90000000000000000000001 }
{ _measurement=transfer, _field=amount, _value=12000000000000000000000 }
from(bucket: "xxx")
  |> range(start: 0)
  |> filter(fn: (r) => r._measurement == "transfer" and r._field == "amount")
  |> toUint()
  |> sum()

I get the following error: runtime error @4:6-4:13: toInt: failed to evaluate map function: cannot convert string "90000000000000000000001" to int due to invalid syntax

Is there a built-in solution like ClickHouse's uint256, or a third-party package to achieve this?


Solution

  • Unfortunately InfluxDB doesn't support big numbers yet. It stores all integers as signed int64 data types. The minimum and maximum valid values for int64 are -9223372036854775808 and 9223372036854775807. See more info here.