@@ -221,6 +221,38 @@ def test_select(df):
221221 assert result .column (1 ) == pa .array ([1 , 2 , 3 ])
222222
223223
224+ def test_select_exprs (df ):
225+ df_1 = df .select_exprs (
226+ "a + b" ,
227+ "a - b" ,
228+ )
229+
230+ # execute and collect the first (and only) batch
231+ result = df_1 .collect ()[0 ]
232+
233+ assert result .column (0 ) == pa .array ([5 , 7 , 9 ])
234+ assert result .column (1 ) == pa .array ([- 3 , - 3 , - 3 ])
235+
236+ df_2 = df .select_exprs ("b" , "a" )
237+
238+ # execute and collect the first (and only) batch
239+ result = df_2 .collect ()[0 ]
240+
241+ assert result .column (0 ) == pa .array ([4 , 5 , 6 ])
242+ assert result .column (1 ) == pa .array ([1 , 2 , 3 ])
243+
244+ df_3 = df .select_exprs (
245+ "abs(a + b)" ,
246+ "abs(a - b)" ,
247+ )
248+
249+ # execute and collect the first (and only) batch
250+ result = df_3 .collect ()[0 ]
251+
252+ assert result .column (0 ) == pa .array ([5 , 7 , 9 ])
253+ assert result .column (1 ) == pa .array ([3 , 3 , 3 ])
254+
255+
224256def test_drop_quoted_columns ():
225257 ctx = SessionContext ()
226258 batch = pa .RecordBatch .from_arrays ([pa .array ([1 , 2 , 3 ])], names = ["ID_For_Students" ])
0 commit comments