File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 9
9
10
10
import datafusion as df
11
11
import pyarrow as pa
12
- import pyarrow .dataset as ds
13
12
import pyarrow_hotfix # noqa: F401
14
13
import sqlglot as sg
15
14
import sqlglot .expressions as sge
@@ -418,14 +417,13 @@ def _register_failure(self):
418
417
419
418
def _register_in_memory_table (self , op : ops .InMemoryTable ) -> None :
420
419
name = op .name
421
- schema = op .schema
422
420
423
- self . con . deregister_table ( name )
424
- if batches := op . data . to_pyarrow ( schema ). to_batches ():
425
- self . con . register_record_batches ( name , [ batches ])
426
- else :
427
- empty_dataset = ds . dataset ([], schema = schema . to_pyarrow ())
428
- self .con .register_dataset ( name = name , dataset = empty_dataset )
421
+ try :
422
+ self . con . catalog (). database (). table ( name )
423
+ except Exception : # noqa: BLE001 because datafusion doesn't have anything better
424
+ # self.con.register_table is broken, so we do this roundabout thing
425
+ # of registering constructing a datafusion DataFrame
426
+ self .con .from_arrow_table ( op . data . to_pyarrow ( op . schema ), name )
429
427
430
428
def read_csv (
431
429
self , path : str | Path , table_name : str | None = None , ** kwargs : Any
You can’t perform that action at this time.
0 commit comments