File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -974,10 +974,15 @@ def insert_data(self) -> tuple[list[str], list[np.ndarray]]:
974
974
for i , (_ , ser ) in enumerate (temp .items ()):
975
975
if ser .dtype .kind == "M" :
976
976
if isinstance (ser ._values , ArrowExtensionArray ):
977
- with warnings .catch_warnings ():
978
- warnings .filterwarnings ("ignore" , category = FutureWarning )
979
- # GH#52459 to_pydatetime will return Index[object]
980
- d = np .asarray (ser .dt .to_pydatetime (), dtype = object )
977
+ import pyarrow as pa
978
+ if pa .types .is_date (ser .dtype .pyarrow_dtype ):
979
+ # GH#53854 to_pydatetime is not supported for pyarrow date dtypes
980
+ d = ser ._values .astype (object )
981
+ else :
982
+ with warnings .catch_warnings ():
983
+ warnings .filterwarnings ("ignore" , category = FutureWarning )
984
+ # GH#52459 to_pydatetime will return Index[object]
985
+ d = np .asarray (ser .dt .to_pydatetime (), dtype = object )
981
986
else :
982
987
d = ser ._values .to_pydatetime ()
983
988
elif ser .dtype .kind == "m" :
Original file line number Diff line number Diff line change @@ -561,6 +561,9 @@ def test_dataframe_to_sql_arrow_dtypes(conn, request):
561
561
"datetime" : pd .array (
562
562
[datetime (2023 , 1 , 1 )], dtype = "timestamp[ns][pyarrow]"
563
563
),
564
+ "date" : pd .array (
565
+ [date (2023 , 1 , 1 )], dtype = "date32[day][pyarrow]"
566
+ ),
564
567
"timedelta" : pd .array ([timedelta (1 )], dtype = "duration[ns][pyarrow]" ),
565
568
"string" : pd .array (["a" ], dtype = "string[pyarrow]" ),
566
569
}
You can’t perform that action at this time.
0 commit comments