From 4c2e10f1ed9f5cc3234ebd5a7c40a63569889a8c Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Fri, 26 Dec 2025 12:38:35 +0900 Subject: [PATCH] [R] Add test for slice_sample with prop = 1 edge case --- r/tests/testthat/test-dplyr-slice.R | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/r/tests/testthat/test-dplyr-slice.R b/r/tests/testthat/test-dplyr-slice.R index ebedc7026e6..76586f80cc1 100644 --- a/r/tests/testthat/test-dplyr-slice.R +++ b/r/tests/testthat/test-dplyr-slice.R @@ -218,4 +218,12 @@ test_that("n <-> prop conversion when nrow is not known", { ) }) -# TODO: handle edge case where prop = 1, do nothing? +test_that("slice_sample with prop = 1 returns all data", { + # When prop = 1, no filtering should occur and all data should be returned + tab <- arrow_table(tbl) + result <- tab |> + slice_sample(prop = 1) |> + collect() + expect_equal(nrow(result), nrow(tbl)) + expect_setequal(result$int, tbl$int) +})