Open
Description
-
What versions are you using?
3.2 -
Is it an error or a hang or a crash?
Just incorrect value (number is truncated as consequence of wrong data type) -
What error(s) or behavior you are seeing?
Doubles are being casted as int, losing decimal part -
Does your application call init_oracle_client()?
No but wrong value occurs regardless -
Include a runnable Python script that shows the problem.
import oracledb
import pyarrow as pa
# oracledb.init_oracle_client()
conn = oracledb.connect("...")
with conn.cursor() as cursor:
try:
cursor.execute("drop table t_random")
except:
pass
cursor.execute("create table t_random as select 1 n1 from dual")
print("Plain select from table")
odf = conn.fetch_df_all("select n1 from t_random")
print(odf.column_arrays())
print(pa.Table.from_arrays(arrays=odf.column_arrays(), names=odf.column_names()))
print("\nDivided by a decimal, OracleArrays is int64 (wrong)")
odf = conn.fetch_df_all("select n1/sqrt(252) n from t_random")
print(odf.column_arrays())
print(pa.Table.from_arrays(arrays=odf.column_arrays(), names=odf.column_names()))
print("\nForce casting to double")
odf = conn.fetch_df_all("select TO_BINARY_DOUBLE(n1/sqrt(252)) n from t_random")
print(odf.column_arrays())
print(pa.Table.from_arrays(arrays=odf.column_arrays(), names=odf.column_names()))
print("\nPlain old DB API")
with conn.cursor() as cursor:
cursor.execute("select n1/sqrt(252) n from t_random")
print(cursor.fetchone())
And output looks like
Plain select from table
[OracleArrowArray(name=N1, len=1, type=double)]
pyarrow.Table
N1: double
----
N1: [[1]]
Divided by a decimal, OracleArrays is int64 (wrong)
[OracleArrowArray(name=N, len=1, type=int64)] <------ THIS IS INCORRECT, SHOULD BE DOUBLE
pyarrow.Table
N: int64
----
N: [[0]]
Force casting to double
[OracleArrowArray(name=N, len=1, type=double)]
pyarrow.Table
N: double
----
N: [[0.06299407883487121]]
Plain old DB API
(0.06299407883487121,)