Skip to content

Conversation

@gautamvarmadatla
Copy link

@gautamvarmadatla gautamvarmadatla commented Jan 1, 2026

Hi all,

This fixes a precision issue in read_sql and read_sql_query when coerce_float=True and a DB driver returns large IDs as decimal.Decimal. Those values can get coerced to float64 and rounded once they’re above 2**53, for example 305184080441754059 becomes 305184080441754048.

The fix is limited to the SQL ingestion path. For object columns, if we see an integral Decimal that would be lossy as float, we convert it to a Python int before dtype inference. Fractional Decimal values still coerce to float as before. Added sqlite-based regression tests for both cases.

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

Successfully merging this pull request may close these issues.

BUG: pd.read_sql is incorrectly reading long int when connecting to Teradata

1 participant