@@ -188,8 +188,84 @@ test_that("Error handling for unsupported expressions in join_by", {
188188 )
189189})
190190
191- # TODO: test duplicate col names
192- # TODO: casting: int and float columns?
191+ test_that(" joins with duplicate column names" , {
192+ # When column names are duplicated (not in by), suffixes are added
193+ left_dup <- tibble :: tibble(
194+ x = 1 : 5 ,
195+ y = 1 : 5 ,
196+ z = letters [1 : 5 ]
197+ )
198+ right_dup <- tibble :: tibble(
199+ x = 1 : 5 ,
200+ y = 6 : 10 ,
201+ z = LETTERS [1 : 5 ]
202+ )
203+
204+ compare_dplyr_binding(
205+ .input | >
206+ left_join(right_dup , by = " x" ) | >
207+ collect(),
208+ left_dup
209+ )
210+
211+ compare_dplyr_binding(
212+ .input | >
213+ inner_join(right_dup , by = " x" ) | >
214+ collect(),
215+ left_dup
216+ )
217+
218+ # Test with custom suffixes
219+ compare_dplyr_binding(
220+ .input | >
221+ left_join(right_dup , by = " x" , suffix = c(" _left" , " _right" )) | >
222+ collect(),
223+ left_dup
224+ )
225+ })
226+
227+ test_that(" joins with type casting between int and float" , {
228+ # Joins should work when one side has int and the other has float
229+ left_int <- tibble :: tibble(
230+ x = 1 : 5 ,
231+ value = letters [1 : 5 ]
232+ )
233+ right_float <- tibble :: tibble(
234+ x = as.numeric(1 : 5 ),
235+ info = LETTERS [1 : 5 ]
236+ )
237+
238+ compare_dplyr_binding(
239+ .input | >
240+ left_join(right_float , by = " x" ) | >
241+ collect(),
242+ left_int
243+ )
244+
245+ compare_dplyr_binding(
246+ .input | >
247+ inner_join(right_float , by = " x" ) | >
248+ collect(),
249+ left_int
250+ )
251+
252+ # Also test the reverse (float on left, int on right)
253+ left_float <- tibble :: tibble(
254+ x = as.numeric(1 : 5 ),
255+ value = letters [1 : 5 ]
256+ )
257+ right_int <- tibble :: tibble(
258+ x = 1 : 5 ,
259+ info = LETTERS [1 : 5 ]
260+ )
261+
262+ compare_dplyr_binding(
263+ .input | >
264+ left_join(right_int , by = " x" ) | >
265+ collect(),
266+ left_float
267+ )
268+ })
193269
194270test_that(" right_join" , {
195271 compare_dplyr_binding(
0 commit comments