Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast all numerical values as strings #1879

Closed
hassankhan opened this issue Jan 25, 2021 · 8 comments
Closed

Cast all numerical values as strings #1879

hassankhan opened this issue Jan 25, 2021 · 8 comments
Assignees
Labels
enhancement New feature proposal

Comments

@hassankhan
Copy link
Contributor

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
#1849
#1835
#349

@hassankhan hassankhan added the enhancement New feature proposal label Jan 25, 2021
@paveltiunov paveltiunov assigned ovr and unassigned paveltiunov Jan 29, 2021
@paveltiunov paveltiunov added the Roadmap: 2021 Q1 Cube.js team roadmap for Q1 of 2021. label Jan 29, 2021
@zameschua
Copy link

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

@joshk0
Copy link

joshk0 commented Apr 8, 2021

+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"

@HJ29
Copy link
Contributor

HJ29 commented Jul 9, 2021

i found that cubejs cast NULL timestamp to 1970-01-01T00:00:00.000 when using rollup.
it return null correctly without rolllup

@robert-lara
Copy link

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.

@benswinburne
Copy link

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.

@TomMarquardt1
Copy link

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.

@shawno
Copy link

shawno commented Feb 14, 2024

+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?

@igorlukanin
Copy link
Member

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.

@igorlukanin igorlukanin removed the Roadmap: 2021 Q1 Cube.js team roadmap for Q1 of 2021. label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature proposal
Projects
None yet
Development

No branches or pull requests