@@ -1109,6 +1109,65 @@ def test_first_last(backend):
11091109 backend .assert_frame_equal (result , expected )
11101110
11111111
1112+ @pytest .mark .notimpl (
1113+ [
1114+ "risingwave" ,
1115+ "clickhouse" ,
1116+ "bigquery" ,
1117+ "oracle" ,
1118+ "snowflake" ,
1119+ "databricks" ,
1120+ "pyspark" ,
1121+ ],
1122+ raises = AssertionError ,
1123+ )
1124+ @pytest .mark .notyet (
1125+ ["polars" ],
1126+ raises = com .OperationNotDefinedError ,
1127+ )
1128+ @pytest .mark .notyet (
1129+ ["flink" ],
1130+ raises = NotImplementedError ,
1131+ )
1132+ @pytest .mark .notyet (
1133+ [
1134+ "mysql" ,
1135+ "sqlite" ,
1136+ "postgres" ,
1137+ "datafusion" ,
1138+ "druid" ,
1139+ "athena" ,
1140+ "impala" ,
1141+ "mssql" ,
1142+ "trino" ,
1143+ "exasol" ,
1144+ ],
1145+ raises = Exception ,
1146+ )
1147+ def test_first_last_include_nulls (backend ):
1148+ t = ibis .memtable ({"a" : (2 , 2 , 1 , 1 ), "b" : (None , 3 , 5 , None ), "c" : list (range (4 ))})
1149+ w = ibis .window (group_by = t .a , order_by = t .c )
1150+ expr = t .select (
1151+ "a" ,
1152+ b_first_null = t .b .first (include_null = True ).over (w ),
1153+ b_last_null = t .b .last (include_null = True ).over (w ),
1154+ b_first = t .b .first (include_null = False ).over (w ),
1155+ b_last = t .b .last (include_null = False ).over (w ),
1156+ )
1157+ con = backend .connection
1158+ # execute the expr, and ensure the columns are sorted by column "a"
1159+ result = con .execute (expr ).sort_values ("a" ).set_index ("a" ).reset_index (drop = True )
1160+ expected = pd .DataFrame (
1161+ {
1162+ "b_first_null" : [5 , 5 , None , None ],
1163+ "b_last_null" : [None , None , 3 , 3 ],
1164+ "b_first" : [5 , 5 , 3 , 3 ],
1165+ "b_last" : [5 , 5 , 3 , 3 ],
1166+ }
1167+ )
1168+ backend .assert_frame_equal (result , expected , check_dtype = False )
1169+
1170+
11121171@pytest .mark .notyet (
11131172 ["bigquery" ], raises = GoogleBadRequest , reason = "not supported by BigQuery"
11141173)
0 commit comments