File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -479,6 +479,29 @@ def test_case(df):
479
479
assert result .column (2 ) == pa .array (["Hola" , "Mundo" , None ])
480
480
481
481
482
+ def test_first_last_value (df ):
483
+ df = df .aggregate (
484
+ [],
485
+ [
486
+ f .first_value (column ("a" )),
487
+ f .first_value (column ("b" )),
488
+ f .first_value (column ("d" )),
489
+ f .last_value (column ("a" )),
490
+ f .last_value (column ("b" )),
491
+ f .last_value (column ("d" )),
492
+ ],
493
+ )
494
+
495
+ result = df .collect ()
496
+ result = result [0 ]
497
+ assert result .column (0 ) == pa .array (["Hello" ])
498
+ assert result .column (1 ) == pa .array ([4 ])
499
+ assert result .column (2 ) == pa .array ([datetime (2022 , 12 , 31 )])
500
+ assert result .column (3 ) == pa .array (["!" ])
501
+ assert result .column (4 ) == pa .array ([6 ])
502
+ assert result .column (5 ) == pa .array ([datetime (2020 , 7 , 2 )])
503
+
504
+
482
505
def test_binary_string_functions (df ):
483
506
df = df .select (
484
507
f .encode (column ("a" ), literal ("base64" )),
Original file line number Diff line number Diff line change @@ -362,6 +362,8 @@ aggregate_function!(stddev_samp, Stddev);
362
362
aggregate_function ! ( var, Variance ) ;
363
363
aggregate_function ! ( var_pop, VariancePop ) ;
364
364
aggregate_function ! ( var_samp, Variance ) ;
365
+ aggregate_function ! ( first_value, FirstValue ) ;
366
+ aggregate_function ! ( last_value, LastValue ) ;
365
367
aggregate_function ! ( bit_and, BitAnd ) ;
366
368
aggregate_function ! ( bit_or, BitOr ) ;
367
369
aggregate_function ! ( bit_xor, BitXor ) ;
@@ -494,6 +496,8 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
494
496
m. add_wrapped ( wrap_pyfunction ! ( var_pop) ) ?;
495
497
m. add_wrapped ( wrap_pyfunction ! ( var_samp) ) ?;
496
498
m. add_wrapped ( wrap_pyfunction ! ( window) ) ?;
499
+ m. add_wrapped ( wrap_pyfunction ! ( first_value) ) ?;
500
+ m. add_wrapped ( wrap_pyfunction ! ( last_value) ) ?;
497
501
m. add_wrapped ( wrap_pyfunction ! ( bit_and) ) ?;
498
502
m. add_wrapped ( wrap_pyfunction ! ( bit_or) ) ?;
499
503
m. add_wrapped ( wrap_pyfunction ! ( bit_xor) ) ?;
You can’t perform that action at this time.
0 commit comments