File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 40
40
np = pytest .importorskip ("numpy" )
41
41
pd = pytest .importorskip ("pandas" )
42
42
tm = pytest .importorskip ("pandas.testing" )
43
+ pa = pytest .importorskip ("pyarrow" )
43
44
44
45
NULL_BACKEND_TYPES = {
45
46
"bigquery" : "NULL" ,
@@ -2516,3 +2517,17 @@ def test_table_describe_with_multiple_decimal_columns(con):
2516
2517
expr = t .describe ()
2517
2518
result = con .to_pyarrow (expr )
2518
2519
assert len (result ) == 2
2520
+
2521
+
2522
+ @pytest .mark .parametrize (
2523
+ "input" ,
2524
+ [[], pa .table ([[]], pa .schema ({"x" : pa .int64 ()}))],
2525
+ ids = ["list" , "pyarrow-table" ],
2526
+ )
2527
+ @pytest .mark .notyet (["druid" ], raises = PyDruidProgrammingError )
2528
+ @pytest .mark .notyet (
2529
+ ["flink" ], raises = ValueError , reason = "flink doesn't support empty tables"
2530
+ )
2531
+ def test_empty_memtable (con , input ):
2532
+ t = ibis .memtable (input , schema = {"x" : "int64" })
2533
+ assert not len (con .to_pyarrow (t ))
Original file line number Diff line number Diff line change @@ -429,15 +429,24 @@ def _memtable(
429
429
schema : SchemaLike | None = None ,
430
430
name : str | None = None ,
431
431
) -> Table :
432
+ import ibis
433
+
432
434
if hasattr (data , "__arrow_c_stream__" ):
433
435
# Support objects exposing arrow's PyCapsule interface
434
436
import pyarrow as pa
435
437
436
- data = pa .table (data )
438
+ data = pa .table (
439
+ data ,
440
+ schema = ibis .schema (schema ).to_pyarrow () if schema is not None else None ,
441
+ )
437
442
else :
438
443
import pandas as pd
439
444
440
- data = pd .DataFrame (data , columns = columns )
445
+ data = pd .DataFrame (
446
+ data ,
447
+ columns = columns
448
+ or (ibis .schema (schema ).names if schema is not None else None ),
449
+ )
441
450
return _memtable (data , columns = columns , schema = schema , name = name )
442
451
443
452
You can’t perform that action at this time.
0 commit comments