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

[sqllab] query result is not accurate #3188

Closed
3 tasks done
luciuschina opened this issue Jul 27, 2017 · 18 comments
Closed
3 tasks done

[sqllab] query result is not accurate #3188

luciuschina opened this issue Jul 27, 2017 · 18 comments

Comments

@luciuschina
Copy link

luciuschina commented Jul 27, 2017

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.18.5
0.17.6

Python version

2.7

Expected results

return the accurate bigint field

Actual results

the last two bits in the bigint is wrong

Steps to reproduce

I use sqllab to query mysql tables. My sql statement is :
select * from ec_order_main where main_order_no = 401501121320267725.
"main_order_no" is the primary key of ec_order_main table,its data type is BIGINT.

Sqllab can find the record,but the 'main_order_no' is 401501121320267700. I expected the "main_order_no" should be "401501121320267725" instead of "401501121320267700".
Am I missing something and how can I address this issue?
1

@xrmx
Copy link
Contributor

xrmx commented Jul 27, 2017

Which database is this? Have you tried doing the same query with the database cli?

@luciuschina
Copy link
Author

luciuschina commented Jul 27, 2017

@xrmx This is mysql, and I use other clients, it is OK!
1

@xrmx
Copy link
Contributor

xrmx commented Jul 27, 2017

Next step is to try the query in pandas, if it's still wrong here then the issue is in pandas.

@luciuschina
Copy link
Author

OK , I am not very familiar with python and pandas, but I will have a try.

@xrmx
Copy link
Contributor

xrmx commented Jul 27, 2017

This looks like a good start https://stackoverflow.com/a/25030617/4470501

@luciuschina
Copy link
Author

luciuschina commented Jul 27, 2017

A colleague of mine is familiar with python and pandas,he tested this query in pandas:
111
So it seemed that the pandas has no problems。

@xrmx
Copy link
Contributor

xrmx commented Jul 27, 2017

Thanks for checking! Maybe is this just javascript? On my browser console Number.MAX_SAFE_INTEGER < 401501121320267725 returns true and Number.isSafeInteger(401501121320267725) false.

Reference https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

@luciuschina
Copy link
Author

So is this a bug ?

@mistercrunch
Copy link
Member

That is a weird bug. :/

@xrmx
Copy link
Contributor

xrmx commented Jul 29, 2017

If it's only a visualization bug the sql lab api can cast everything to string?

@mistercrunch
Copy link
Member

Is the value ok in the json ?

@luciuschina
Copy link
Author

luciuschina commented Jul 31, 2017

@mistercrunch I use fiddler to get the result json。It seems the value in json is OK。

1

123232

Although,I set the type of main_order_no filed as VARCHAR in superset, it still doesn't work ! But when I change the field type from BIGINT to VARCHAR in mysql, It can be displayed correctly.

1

@mistercrunch
Copy link
Member

@rumbin
Copy link
Contributor

rumbin commented Jul 31, 2017

Most simple way to reproduce:

SELECT 401501121320267725 as test

in SQLLab

@dmigo
Copy link
Contributor

dmigo commented Jul 31, 2017

here it states that any number longer than 15 digits is going to be imprecise in javascript.
You can try in console:

let b = 123456789012345
b // 123456789012345
b = 12345678901234567
b // 12345678901234568

12345678901234567 is "corrected" to 12345678901234568

@jargnar
Copy link

jargnar commented Jul 31, 2017

@mistercrunch true, also probably much more fundamental

JS stores numbers as double precision 64 bit format IEEE 754 values. (http://www.ecma-international.org/ecma-262/5.1/#sec-8.5)

I'm guessing this needs to be wrapped in some kind of string format.

@mistercrunch
Copy link
Member

Seems like this is what this does:
https://www.npmjs.com/package/json-bigint-string

@mistercrunch
Copy link
Member

Notice: this issue has been closed because it has been inactive for 264 days. Feel free to comment and request for this issue to be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants