cube
cube copied to clipboard
Cast all numerical values as strings
Is your feature request related to a problem? Please describe.
Cube.js can somewhat inconsistently cast numerical values as strings. This behaviour necessitates validation/conversion code on the client-side.
Describe the solution you'd like
The Cube.js API should cast all numerical values as strings (since JSON does not support BigInt) and the Cube.js Client should convert values back to Number/BigInt
Related issues https://github.com/cube-js/cube.js/issues/1849 https://github.com/cube-js/cube.js/issues/1835 https://github.com/cube-js/cube.js/issues/349
Hey cube team, I'm facing this problem currently!
On the front end, resultSet.chartPivot() works as expected and returns numbers for number types, but upon inspecting resultSet.rawData() and resultSet.tablePivot(), the number types are returned as strings.
Db: Postgres 11.8
@cubejs-backend/postgres-driver": "^0.26.10 @cubejs-backend/server-core": "^0.26.10
@cubejs-client/core": "^0.26.0 @cubejs-client/react": "^0.26.7
+1 on this. I actually assume it's numbers and add them together downstream of cube -- Imagine my surprise when I saw a "number" like
"12.5530566.1943.11.753.29"
i found that cubejs cast NULL timestamp to 1970-01-01T00:00:00.000 when using rollup. it return null correctly without rolllup
haha, just ran into this and yeah if I want to use preAgg the measures are converted to a string and it breaks all of our charts since calculations need to be done. Only way around it is to parse everything to a number in the UI.
haha, just ran into this and yeah if I want to use preAgg the measures are converted to a string and it breaks all of our charts since calculations need to be done. Only way around it is to parse everything to a number in the UI.
We just had the opposite here whereby if we query a cube and a preaggregation is hit, the numbers are numbers but if it hits Athena instead of a preaggregation it comes back as a string.
Just ran into this where a measure is a number when it results from a direct query and a string when it is calculated from a pre-aggregation. I guess the solution for now is to apply "parseInt" in our UI to every number returned by Cube.
+1 3 years later, still running into this bug when transitioning from direct queries to pre-aggregations. The lost development time is frustrating, tracking down a known issue. Any update?
Hi @shawno and everyone —
Sorry this wasn't mentioned in this issue but we've released a relevant feature some time ago. So, now there's the castNumerics option in front-end SDKs that would do the conversion for you: https://cube.dev/blog/cube-core-v0-34-34-python-and-powerful-updates#castnumerics-in-front-end-sdks
I hope it helps.