@@ -113,3 +113,58 @@ def test_distribution_records_reject_ambiguous_shapes() -> None:
113113 names = ["id" , "extra" ],
114114 ),
115115 )
116+
117+
118+ @pytest .mark .parametrize (
119+ ("points" , "direction" , "null_order" ),
120+ [
121+ ([20 , 10 ], OrderByDirection .ASC , OrderByNullOrder .NULLS_LAST ),
122+ ([10 , 20 ], OrderByDirection .DESC , OrderByNullOrder .NULLS_LAST ),
123+ ([10 , 10 ], OrderByDirection .ASC , OrderByNullOrder .NULLS_LAST ),
124+ ([None , 10 ], OrderByDirection .ASC , OrderByNullOrder .NULLS_LAST ),
125+ ([10 , None ], OrderByDirection .ASC , OrderByNullOrder .NULLS_FIRST ),
126+ ],
127+ )
128+ def test_range_split_points_must_be_strictly_ordered (
129+ points : list [int | None ],
130+ direction : OrderByDirection ,
131+ null_order : OrderByNullOrder ,
132+ ) -> None :
133+ """Duplicate, reversed, and incorrectly null-ordered boundaries fail closed."""
134+ key = RangeKey (
135+ transform = encoded (identity ("id" )),
136+ direction = direction ,
137+ null_order = null_order ,
138+ )
139+ with pytest .raises (ValueError , match = "strictly ordered" ):
140+ RangePartitioning (
141+ keys = [encoded (key )],
142+ split_points = pa .record_batch ([pa .array (points , type = pa .int64 ())], names = ["id" ]),
143+ )
144+
145+
146+ def test_range_split_points_accept_lexicographic_descending_and_null_order () -> None :
147+ """The validator applies every key's direction and null placement lexicographically."""
148+ first = RangeKey (
149+ transform = encoded (identity ("group" )),
150+ direction = OrderByDirection .ASC ,
151+ null_order = OrderByNullOrder .NULLS_FIRST ,
152+ )
153+ second = RangeKey (
154+ transform = encoded (identity ("value" )),
155+ direction = OrderByDirection .DESC ,
156+ null_order = OrderByNullOrder .NULLS_LAST ,
157+ )
158+
159+ ranges = RangePartitioning (
160+ keys = [encoded (first ), encoded (second )],
161+ split_points = pa .record_batch (
162+ [
163+ pa .array ([None , 1 , 1 , 2 ], type = pa .int64 ()),
164+ pa .array ([None , 20 , 10 , 99 ], type = pa .int64 ()),
165+ ],
166+ names = ["group" , "value" ],
167+ ),
168+ )
169+
170+ assert ranges .split_points .num_rows == 4
0 commit comments