#NEWLINE# def _case_filter_self_join_analysis_bug( self ) : #NEWLINE# #INDENT# purchases = ibis . table ( [ ( 'region' , 'string' ) , ( 'kind' , 'string' ) , ( 'user' , 'int64' ) , ( 'amount' , 'double' ) ] , 'purchases' ) #NEWLINE# metric = purchases . amount . sum ( ) . name ( 'total' ) #NEWLINE# agged = purchases . group_by ( [ 'region' , 'kind' ] ) . aggregate ( metric ) #NEWLINE# left = agged [ ( agged . kind == 'foo' ) ] #NEWLINE# right = agged [ ( agged . kind == 'bar' ) ] #NEWLINE# joined = left . join ( right , ( left . region == right . region ) ) #NEWLINE# result = joined [ ( left . region , ( left . total - right . total ) . name ( 'diff' ) ) ] #NEWLINE# return ( result , purchases )