Skip to content

Commit 702fe31

Browse files
authored
fix: Remove flaky timing test (#4371)
* fix: Remove flaky timing test * Revert back to warning
1 parent a71cee4 commit 702fe31

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/test_parser.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)