#NEWLINE# @ SkipTest #NEWLINE# def test_merge_to_nary_join( self ) : #NEWLINE# #INDENT# ' Test the rule merging binary join to nary join.\n        ' #NEWLINE# def in_cond_idx( position , conditions ) : #NEWLINE# #INDENT# for ( i , cond ) in enumerate ( conditions ) : #NEWLINE# #INDENT# if ( position in cond ) : #NEWLINE# #INDENT# return i #NEWLINE# #UNINDENT# #UNINDENT# raise Exception ( 'Cannot find attribute in join conditions' ) #NEWLINE# #UNINDENT# triangle_join = testNaryJoin . get_phys_plan_root ( 'A(x,y,z):-R(x,y),S(y,z),T(z,x)' , 64 ) #NEWLINE# self . assertIsInstance ( triangle_join , algebra . NaryJoin ) #NEWLINE# self . assertEqual ( len ( triangle_join . conditions ) , 3 ) #NEWLINE# conds = [ ] #NEWLINE# for cond in triangle_join . conditions : #NEWLINE# #INDENT# conds . append ( [ attribute . position for attribute in cond ] ) #NEWLINE# #UNINDENT# self . assertEqual ( in_cond_idx ( 0 , conds ) , in_cond_idx ( 5 , conds ) ) #NEWLINE# self . assertEqual ( in_cond_idx ( 1 , conds ) , in_cond_idx ( 2 , conds ) ) #NEWLINE# self . assertEqual ( in_cond_idx ( 3 , conds ) , in_cond_idx ( 4 , conds ) ) #NEWLINE# star_join = testNaryJoin . get_phys_plan_root ( 'A(x,y,z,p):-R(x,y),S(x,z),T(x,p)' , 64 ) #NEWLINE# self . assertIsInstance ( star_join , algebra . NaryJoin ) #NEWLINE# self . assertEqual ( len ( star_join . conditions ) , 1 ) #NEWLINE# conds = [ ] #NEWLINE# for cond in star_join . conditions : #NEWLINE# #INDENT# conds . append ( [ attribute . position for attribute in cond ] ) #NEWLINE# #UNINDENT# self . assertEqual ( in_cond_idx ( 0 , conds ) , in_cond_idx ( 2 , conds ) ) #NEWLINE# self . assertEqual ( in_cond_idx ( 2 , conds ) , in_cond_idx ( 4 , conds ) )