#NEWLINE# def test_bug_duplicated_where( self ) : #NEWLINE# #INDENT# table = self . con . table ( 'airlines' ) #NEWLINE# t = table [ ( 'arrdelay' , 'dest' ) ] #NEWLINE# expr = t . group_by ( 'dest' ) . mutate ( dest_avg = t . arrdelay . mean ( ) , dev = ( t . arrdelay - t . arrdelay . mean ( ) ) ) #NEWLINE# tmp1 = expr [ expr . dev . notnull ( ) ] #NEWLINE# tmp2 = tmp1 . sort_by ( ibis . desc ( 'dev' ) ) #NEWLINE# worst = tmp2 . limit ( 10 ) #NEWLINE# result = to_sql ( worst ) #NEWLINE# expected = 'SELECT *\nFROM (\n  SELECT `arrdelay`, `dest`,\n         avg(`arrdelay`) OVER (PARTITION BY `dest`) AS `dest_avg`,\n         `arrdelay` - avg(`arrdelay`) OVER (PARTITION BY `dest`) AS `dev`\n  FROM airlines\n) t0\nWHERE `dev` IS NOT NULL\nORDER BY `dev` DESC\nLIMIT 10' #NEWLINE# assert ( result == expected )