27
27
from ibis .backends .base .sqlglot import C , F
28
28
from ibis .backends .duckdb .compiler import DuckDBSQLCompiler
29
29
from ibis .backends .duckdb .datatypes import DuckDBType
30
- from ibis .expr .operations .relations import PandasDataFrameProxy
31
30
from ibis .expr .operations .udf import InputType
32
31
from ibis .formats .pandas import PandasData
33
32
@@ -1171,10 +1170,6 @@ def _metadata(self, query: str) -> Iterator[tuple[str, dt.DataType]]:
1171
1170
yield name , ibis_type
1172
1171
1173
1172
def _register_in_memory_table (self , op : ops .InMemoryTable ) -> None :
1174
- # in theory we could use pandas dataframes, but when using dataframes
1175
- # with pyarrow datatypes later reads of this data segfault
1176
- import pandas as pd
1177
-
1178
1173
schema = op .schema
1179
1174
if null_columns := [col for col , dtype in schema .items () if dtype .is_null ()]:
1180
1175
raise exc .IbisTypeError (
@@ -1184,32 +1179,15 @@ def _register_in_memory_table(self, op: ops.InMemoryTable) -> None:
1184
1179
1185
1180
# only register if we haven't already done so
1186
1181
if (name := op .name ) not in self .list_tables ():
1187
- if isinstance (data := op .data , PandasDataFrameProxy ):
1188
- table = data .to_frame ()
1189
-
1190
- # convert to object string dtypes because duckdb is either
1191
- # 1. extremely slow to register DataFrames with not-pyarrow
1192
- # string dtypes
1193
- # 2. broken for string[pyarrow] dtypes (segfault)
1194
- if conversions := {
1195
- colname : "str"
1196
- for colname , col in table .items ()
1197
- if isinstance (col .dtype , pd .StringDtype )
1198
- }:
1199
- table = table .astype (conversions )
1200
- else :
1201
- table = data .to_pyarrow (schema )
1182
+ table = op .data .to_pyarrow (schema )
1202
1183
1203
1184
# register creates a transaction, and we can't nest transactions so
1204
1185
# we create a function to encapsulate the whole shebang
1205
1186
def _register (name , table ):
1206
1187
with self .begin () as con :
1207
1188
con .connection .register (name , table )
1208
1189
1209
- try :
1210
- _register (name , table )
1211
- except duckdb .NotImplementedException :
1212
- _register (name , data .to_pyarrow (schema ))
1190
+ _register (name , table )
1213
1191
1214
1192
def _get_temp_view_definition (
1215
1193
self , name : str , definition : sa .sql .compiler .Compiled
0 commit comments