@@ -2322,8 +2322,66 @@ def test_root_to_string(root: RelationalRoot, output: str):
23222322 assert root .to_string () == output
23232323
23242324
2325- # def test_root_equals(first_root: RelationalRoot, second_root: Relational, output: bool):
2326- # assert first_root.equals(second_root) == output
2325+ @pytest .mark .parametrize (
2326+ "first_root, second_root, output" ,
2327+ [
2328+ pytest .param (
2329+ RelationalRoot (build_simple_scan (), [make_column ("a" ), make_column ("b" )]),
2330+ RelationalRoot (build_simple_scan (), [make_column ("a" ), make_column ("b" )]),
2331+ True ,
2332+ id = "matching_columns_no_orderings" ,
2333+ ),
2334+ pytest .param (
2335+ RelationalRoot (build_simple_scan (), [make_column ("a" ), make_column ("b" )]),
2336+ RelationalRoot (build_simple_scan (), [make_column ("b" ), make_column ("c" )]),
2337+ False ,
2338+ id = "different_columns_no_orderings" ,
2339+ ),
2340+ pytest .param (
2341+ RelationalRoot (
2342+ build_simple_scan (),
2343+ [make_column ("a" ), make_column ("b" )],
2344+ [make_simple_column_reference ("a" )],
2345+ ),
2346+ RelationalRoot (
2347+ build_simple_scan (),
2348+ [make_column ("a" ), make_column ("b" )],
2349+ [make_simple_column_reference ("a" )],
2350+ ),
2351+ True ,
2352+ id = "matching_columns_with_orderings" ,
2353+ ),
2354+ pytest .param (
2355+ RelationalRoot (
2356+ build_simple_scan (),
2357+ [make_column ("a" ), make_column ("b" )],
2358+ [make_simple_column_reference ("a" )],
2359+ ),
2360+ RelationalRoot (
2361+ build_simple_scan (),
2362+ [make_column ("a" ), make_column ("b" )],
2363+ [make_simple_column_reference ("b" )],
2364+ ),
2365+ False ,
2366+ id = "different_orderings" ,
2367+ ),
2368+ pytest .param (
2369+ RelationalRoot (build_simple_scan (), [make_column ("a" ), make_column ("b" )]),
2370+ RelationalRoot (Scan ("table2" , []), [make_column ("a" ), make_column ("b" )]),
2371+ False ,
2372+ id = "different_inputs" ,
2373+ ),
2374+ pytest .param (
2375+ RelationalRoot (build_simple_scan (), [make_column ("a" ), make_column ("b" )]),
2376+ Scan ("table2" , [make_column ("a" ), make_column ("b" )]),
2377+ False ,
2378+ id = "different_nodes" ,
2379+ ),
2380+ ],
2381+ )
2382+ def test_root_equals (first_root : RelationalRoot , second_root : Relational , output : bool ):
2383+ assert first_root .equals (second_root ) == output
2384+
23272385
23282386# def test_root_can_merge(first_root: RelationalRoot, second_root: RelationalRoot):
23292387# assert not first_root.can_merge(second_root)
0 commit comments