-
-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
BUG: Lost precision of NUMBER in read_sql_table(). #34988
Comments
Hello This bug has been reproduced in: INSTALLED VERSIONScommit : None pandas : 1.0.4 df3 have the correct dtype. |
I also ran into this problem with an Oracle column defined as Lines 1241 to 1255 in 66e3805
As a work-around I patched the if isinstance(sqltype, sqlalchemy.types.Numeric):
return sqltype.python_type |
take |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Problem description
When using
pd.read_sql_table()
with Oracle DB precision of data typesqlalchemy.dialects.oracle.NUMBER
is lost.Expected Output
Precision should not be lost as this datatype can be either integer or float.
The problem
Looks like the root cause for this is in
_harmonize_columns()
, particularly in_get_dtype()
that is used there. The SQLAlchemy typesqlalchemy.dialects.oracle.NUMBER
is based on bothsqlalchemy.types.Numeric
andsqlalchemy.types.Integer
. As there is no support for SQLAlchemy Numeric type in_get_dtype()
this Oracle type is being treated as integer and precision is dropped when usingastype()
in_harmonize_columns()
itself.The text was updated successfully, but these errors were encountered: