From a4eb9757de2ae4e9a1e203811ff727081a466ce7 Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Tue, 23 Dec 2025 15:04:00 +0900 Subject: [PATCH] [R] Add test coverage for joins with duplicate columns and type casting --- r/tests/testthat/test-dplyr-join.R | 37 ++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/r/tests/testthat/test-dplyr-join.R b/r/tests/testthat/test-dplyr-join.R index 51ca528a644..b64f093cd95 100644 --- a/r/tests/testthat/test-dplyr-join.R +++ b/r/tests/testthat/test-dplyr-join.R @@ -188,8 +188,41 @@ test_that("Error handling for unsupported expressions in join_by", { ) }) -# TODO: test duplicate col names -# TODO: casting: int and float columns? +test_that("joins with duplicate column names", { + # When column names are duplicated (not in by), suffixes are added + left_dup <- tibble::tibble( + x = 1:5, + y = 1:5, + z = letters[1:5] + ) + right_dup <- tibble::tibble( + x = 1:5, + y = 6:10, + z = LETTERS[1:5] + ) + + compare_dplyr_binding( + .input |> + left_join(right_dup, by = "x") |> + collect(), + left_dup + ) + + compare_dplyr_binding( + .input |> + inner_join(right_dup, by = "x") |> + collect(), + left_dup + ) + + # Test with custom suffixes + compare_dplyr_binding( + .input |> + left_join(right_dup, by = "x", suffix = c("_left", "_right")) |> + collect(), + left_dup + ) +}) test_that("right_join", { compare_dplyr_binding(