@@ -169,6 +169,17 @@ def test_sort(df):
169169    assert  table .to_pydict () ==  expected 
170170
171171
172+ def  test_drop (df ):
173+     df  =  df .drop ("c" )
174+ 
175+     # execute and collect the first (and only) batch 
176+     result  =  df .collect ()[0 ]
177+ 
178+     assert  df .schema ().names  ==  ["a" , "b" ]
179+     assert  result .column (0 ) ==  pa .array ([1 , 2 , 3 ])
180+     assert  result .column (1 ) ==  pa .array ([4 , 5 , 6 ])
181+ 
182+ 
172183def  test_limit (df ):
173184    df  =  df .limit (1 )
174185
@@ -290,6 +301,42 @@ def test_join():
290301    assert  table .to_pydict () ==  expected 
291302
292303
304+ def  test_join_on ():
305+     ctx  =  SessionContext ()
306+ 
307+     batch  =  pa .RecordBatch .from_arrays (
308+         [pa .array ([1 , 2 , 3 ]), pa .array ([4 , 5 , 6 ])],
309+         names = ["a" , "b" ],
310+     )
311+     df  =  ctx .create_dataframe ([[batch ]], "l" )
312+ 
313+     batch  =  pa .RecordBatch .from_arrays (
314+         [pa .array ([1 , 2 ]), pa .array ([- 8 , 10 ])],
315+         names = ["a" , "c" ],
316+     )
317+     df1  =  ctx .create_dataframe ([[batch ]], "r" )
318+ 
319+     df2  =  df .join_on (df1 , column ("l.a" ).__eq__ (column ("r.a" )), how = "inner" )
320+     df2 .show ()
321+     df2  =  df2 .sort (column ("l.a" ))
322+     table  =  pa .Table .from_batches (df2 .collect ())
323+ 
324+     expected  =  {"a" : [1 , 2 ], "c" : [- 8 , 10 ], "b" : [4 , 5 ]}
325+     assert  table .to_pydict () ==  expected 
326+ 
327+     df3  =  df .join_on (
328+         df1 ,
329+         column ("l.a" ).__eq__ (column ("r.a" )),
330+         column ("l.a" ).__lt__ (column ("r.c" )),
331+         how = "inner" ,
332+     )
333+     df3 .show ()
334+     df3  =  df3 .sort (column ("l.a" ))
335+     table  =  pa .Table .from_batches (df3 .collect ())
336+     expected  =  {"a" : [2 ], "c" : [10 ], "b" : [5 ]}
337+     assert  table .to_pydict () ==  expected 
338+ 
339+ 
293340def  test_distinct ():
294341    ctx  =  SessionContext ()
295342
0 commit comments