@@ -343,7 +343,7 @@ def test_merge_left_on_right_on(scalars_dfs, merge_how):
343
343
assert_pandas_df_equal (bf_result , pd_result , ignore_order = True )
344
344
345
345
346
- def test_pd_merge_cross (scalars_dfs ):
346
+ def test_merge_cross (scalars_dfs ):
347
347
scalars_df , scalars_pandas_df = scalars_dfs
348
348
left_columns = ["int64_col" , "float64_col" , "int64_too" ]
349
349
right_columns = ["int64_col" , "bool_col" , "string_col" , "rowindex_2" ]
@@ -398,6 +398,61 @@ def test_merge_series(scalars_dfs, merge_how):
398
398
assert_pandas_df_equal (bf_result , pd_result , ignore_order = True )
399
399
400
400
401
+ def test_merge_w_common_columns (scalars_dfs ):
402
+ scalars_df , scalars_pandas_df = scalars_dfs
403
+ left_columns = ["int64_col" , "int64_too" ]
404
+ right_columns = ["int64_col" , "bool_col" ]
405
+
406
+ df = bpd .merge (
407
+ scalars_df [left_columns ], scalars_df [right_columns ], "inner" , sort = True
408
+ )
409
+
410
+ pd_result = pd .merge (
411
+ scalars_pandas_df [left_columns ],
412
+ scalars_pandas_df [right_columns ],
413
+ "inner" ,
414
+ sort = True ,
415
+ )
416
+ assert_pandas_df_equal (df .to_pandas (), pd_result , ignore_order = True )
417
+
418
+
419
+ def test_merge_raises_error_when_no_common_columns (scalars_dfs ):
420
+ scalars_df , _ = scalars_dfs
421
+ left_columns = ["float64_col" , "int64_too" ]
422
+ right_columns = ["int64_col" , "bool_col" ]
423
+
424
+ left = scalars_df [left_columns ]
425
+ right = scalars_df [right_columns ]
426
+
427
+ with pytest .raises (
428
+ ValueError ,
429
+ match = "No common columns to perform merge on." ,
430
+ ):
431
+ bpd .merge (left , right , "inner" )
432
+
433
+
434
+ def test_merge_raises_error_when_left_right_on_set (scalars_dfs ):
435
+ scalars_df , _ = scalars_dfs
436
+ left_columns = ["int64_col" , "int64_too" ]
437
+ right_columns = ["int64_col" , "bool_col" ]
438
+
439
+ left = scalars_df [left_columns ]
440
+ right = scalars_df [right_columns ]
441
+
442
+ with pytest .raises (
443
+ ValueError ,
444
+ match = "Can not pass both `on` and `left_on` + `right_on` params." ,
445
+ ):
446
+ bpd .merge (
447
+ left ,
448
+ right ,
449
+ "inner" ,
450
+ left_on = "int64_too" ,
451
+ right_on = "int64_col" ,
452
+ on = "int64_col" ,
453
+ )
454
+
455
+
401
456
def _convert_pandas_category (pd_s : pd .Series ):
402
457
"""
403
458
Transforms a pandas Series with Categorical dtype into a bigframes-compatible
0 commit comments