Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
import numpy as np
query = """
SELECT
longID
FROM teradata_table
WHERE
longID = 305184080441754059;
"""
dtype = {
"QueryID": np.uint64,
}
with teradatasql.connect(
host=HOST, user=USERNAME, password=PASSWORD, logmech="LDAP"
) as connect:
df = pd.read_sql(query, connect, dtype=dtype)
df.head()
# pandas returns longID 305184080441754048 - close but not quite 305184080441754059
Issue Description
We have trouble when pulling long longID
with 18 digits pandas are incorrectly reading the Teradata value. I also tried using cast(longID as decimal(18, 0))
to help Pandas understand the type of longID
. So far I haven't found a solution how to fix the problem - incorrect value read.
We are using teradatasql
version 20.0.0.24
we can confirm that teradatasql
is working correctly as it gives us the value below when using query specified above: Decimal('305184080441754059')
with teradatasql.connect(
host=HOST, user=USERNAME, password=PASSWORD, logmech="LDAP"
) as con:
with con.cursor() as cur:
cur.execute(query)
for row in cur:
print(f"{row}")
^ this works as expected - so we assume that Teradata SQL library is working correctly.
Expected Behavior
We expect to see 305184080441754059
as longID
in the pandas dataframe.