heavyai / pymapd

Python client for OmniSci GPU-accelerated SQL engine and analytics platform
https://pymapd.readthedocs.io/en/latest/
Apache License 2.0
111 stars 50 forks source link

load_table (rowwise) can be incorrect in presence of scientific notation #208

Open randyzwitch opened 5 years ago

randyzwitch commented 5 years ago

In working on #203, noticed that for bigint, if you have large enough numbers and have nulls, pandas will convert the column to float64 AND convert it to scientific notation. Loading the table rowwise into a pre-existing BIGINT column will convert the scientific notation float into a string, and OmniSci backend will truncate at the decimal point. So a gigantic number will be loaded as if it were 0-9, instead of a large number.

pseudocode:

data = np.random.randint(low=-9223372036854775807,
                                 high=9223372036854775807, size=n_samples,
                                 dtype='int64')

df = pd.DataFrame(data)

con.load_table("preexisting_int_table", df, method='rows') 
randyzwitch commented 5 years ago

Possible solution would be to explicitly format strings to some level of precision:

https://stackoverflow.com/a/33219633/2394542