File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -712,20 +712,20 @@ def test_pivot_columns(self):
712712 self .assertEqual (expected_columns , [col .sql (dialect = dialect ) for col in columns ])
713713
714714 def test_parse_nested (self ):
715- now = time . time ()
716- query = parse_one ( "SELECT * FROM a " + ( "LEFT JOIN b ON a.id = b.id " * 38 ) )
717- self . assertIsNotNone (query )
718- self . assertLessEqual ( time .time () - now , 0.1 )
719-
720- now = time . time ( )
721- query = parse_one ( "SELECT * FROM a " + ( "LEFT JOIN UNNEST(ARRAY[]) " * 15 ))
722- self . assertIsNotNone ( query )
723- self . assertLessEqual ( time . time () - now , 0.1 )
724-
725- now = time . time ()
726- query = parse_one ("SELECT * FROM a " + ("OUTER APPLY (SELECT * FROM b) " * 30 ))
727- self . assertIsNotNone ( query )
728- self . assertLessEqual ( time . time () - now , 0.1 )
715+ def warn_over_threshold ( query : str , max_threshold : float = 0.2 ):
716+ now = time . time ( )
717+ ast = parse_one (query )
718+ end = time .time () - now
719+
720+ self . assertIsNotNone ( ast )
721+ if end >= max_threshold :
722+ parser_logger . warning (
723+ f"Query { query [: 100 ] } ... surpassed the time threshold of { max_threshold } seconds"
724+ )
725+
726+ warn_over_threshold ("SELECT * FROM a " + ("LEFT JOIN b ON a.id = b.id " * 38 ))
727+ warn_over_threshold ( "SELECT * FROM a " + ( "LEFT JOIN UNNEST(ARRAY[]) " * 15 ) )
728+ warn_over_threshold ( "SELECT * FROM a " + ( "OUTER APPLY (SELECT * FROM b) " * 30 ) )
729729
730730 def test_parse_properties (self ):
731731 self .assertEqual (
You can’t perform that action at this time.
0 commit comments