@@ -2399,3 +2399,24 @@ SELECT width_bucket(5, ARRAY[3, 4, NULL]);
2399
2399
ERROR: thresholds array must not contain NULLs
2400
2400
SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]);
2401
2401
ERROR: thresholds must be one-dimensional array
2402
+ -- trim_array
2403
+ SELECT arr, trim_array(arr, 2)
2404
+ FROM
2405
+ (VALUES ('{1,2,3,4,5,6}'::bigint[]),
2406
+ ('{1,2}'),
2407
+ ('[10:16]={1,2,3,4,5,6,7}'),
2408
+ ('[-15:-10]={1,2,3,4,5,6}'),
2409
+ ('{{1,10},{2,20},{3,30},{4,40}}')) v(arr);
2410
+ arr | trim_array
2411
+ -------------------------------+-----------------
2412
+ {1,2,3,4,5,6} | {1,2,3,4}
2413
+ {1,2} | {}
2414
+ [10:16]={1,2,3,4,5,6,7} | {1,2,3,4,5}
2415
+ [-15:-10]={1,2,3,4,5,6} | {1,2,3,4}
2416
+ {{1,10},{2,20},{3,30},{4,40}} | {{1,10},{2,20}}
2417
+ (5 rows)
2418
+
2419
+ SELECT trim_array(ARRAY[1, 2, 3], -1); -- fail
2420
+ ERROR: number of elements to trim must be between 0 and 3
2421
+ SELECT trim_array(ARRAY[1, 2, 3], 10); -- fail
2422
+ ERROR: number of elements to trim must be between 0 and 3
0 commit comments