@@ -75,6 +75,35 @@ def test_bool_columns(lmdb_version_store_arrow):
75
75
assert_frame_equal_with_arrow (table , df )
76
76
77
77
78
+ def test_read_empty (lmdb_version_store_arrow ):
79
+ lib = lmdb_version_store_arrow
80
+ sym = "sym"
81
+ df = pd .DataFrame ()
82
+ lib .write (sym , df )
83
+ table = lib .read (sym ).data
84
+ expected = lib .read (sym , output_format = OutputFormat .PANDAS ).data
85
+ # During normalization when doing the write we attach an empty DateTimeIndex to the DataFrame. We correctly see it
86
+ # in arrow
87
+ assert table .column_names == ["index" ]
88
+ assert table .shape == (0 , 1 )
89
+ # arcticdb read(output_format=PANDAS) produces `pd.RangeIndex(start=0, stop=0, step=1)` column index if no columns
90
+ # pyarrow to_pandas produces `pd.Index([])` if no columns.
91
+ expected .columns = pd .Index ([])
92
+ assert_frame_equal_with_arrow (table , expected )
93
+
94
+
95
+ def test_read_empty_with_columns (lmdb_version_store_arrow ):
96
+ lib = lmdb_version_store_arrow
97
+ sym = "sym"
98
+ df = pd .DataFrame ({"col_int" : np .zeros (0 , dtype = np .int32 ), "col_float" : np .zeros (0 , dtype = np .float64 )})
99
+ lib .write (sym , df )
100
+ table = lib .read (sym ).data
101
+ expected = lib .read (sym , output_format = OutputFormat .PANDAS ).data
102
+ assert table .column_names == ["index" , "col_int" , "col_float" ]
103
+ assert table .shape == (0 , 3 )
104
+ assert_frame_equal_with_arrow (table , expected )
105
+
106
+
78
107
def test_column_filtering (lmdb_version_store_arrow ):
79
108
lib = lmdb_version_store_arrow
80
109
df = pd .DataFrame ({"x" : np .arange (10 ), "y" : np .arange (10.0 , 20.0 )})
@@ -925,3 +954,21 @@ def test_resample_row_slice_responsible_for_no_buckets(lmdb_version_store_tiny_s
925
954
table = lib .read (sym , date_range = date_range , query_builder = q ).data
926
955
expected = pd .DataFrame ({"to_sum" : [6 ]}, index = [pd .Timestamp (0 )])
927
956
assert_frame_equal_with_arrow (table , expected )
957
+
958
+
959
+ def test_symbol_concat_empty_intersection (lmdb_version_store_arrow ):
960
+ # Tests a failing subset of test_symbol_concat_empty_column_intersection
961
+ # TODO: Remove this test if we enable pipeline tests with arrow
962
+ lib = lmdb_version_store_arrow
963
+ sym_0 = "sym_0"
964
+ sym_1 = "sym_1"
965
+ df_0 = pd .DataFrame ({"col_0" : [0 ]})
966
+ df_1 = pd .DataFrame ({"col_1" : [1 ]})
967
+ lib .write (sym_0 , df_0 )
968
+ lib .write (sym_1 , df_1 )
969
+ q = QueryBuilder ().concat ("inner" )
970
+ table = lib .batch_read_and_join ([sym_0 , sym_1 ], query_builder = q ).data
971
+ assert table .column_names == []
972
+ assert table .shape == (0 , 0 )
973
+ expected = pd .DataFrame ()
974
+ assert_frame_equal_with_arrow (table , expected )
0 commit comments