|
18 | 18 | import pytest
|
19 | 19 |
|
20 | 20 | import databricks.sql as sql
|
21 |
| -from databricks.sql import STRING, BINARY, NUMBER, DATETIME, DATE, DatabaseError, Error, OperationalError |
| 21 | +from databricks.sql import STRING, BINARY, NUMBER, DATETIME, DATE, DatabaseError, Error, OperationalError, RequestError |
22 | 22 | from tests.e2e.common.predicates import pysql_has_version, pysql_supports_arrow, compare_dbr_versions, is_thrift_v5_plus
|
23 | 23 | from tests.e2e.common.core_tests import CoreTestMixin, SmokeTestMixin
|
24 | 24 | from tests.e2e.common.large_queries_mixin import LargeQueriesMixin
|
@@ -460,14 +460,25 @@ def test_temp_view_fetch(self):
|
460 | 460 | @skipIf(pysql_has_version('<', '2'), 'requires pysql v2')
|
461 | 461 | @skipIf(True, "Unclear the purpose of this test since urllib3 does not complain when timeout == 0")
|
462 | 462 | def test_socket_timeout(self):
|
463 |
| - # We we expect to see a BlockingIO error when the socket is opened |
| 463 | + # We expect to see a BlockingIO error when the socket is opened |
464 | 464 | # in non-blocking mode, since no poll is done before the read
|
465 | 465 | with self.assertRaises(OperationalError) as cm:
|
466 | 466 | with self.cursor({"_socket_timeout": 0}):
|
467 | 467 | pass
|
468 | 468 |
|
469 | 469 | self.assertIsInstance(cm.exception.args[1], io.BlockingIOError)
|
470 | 470 |
|
| 471 | + @skipIf(pysql_has_version('<', '2'), 'requires pysql v2') |
| 472 | + def test_socket_timeout_user_defined(self): |
| 473 | + # We expect to see a TimeoutError when the socket timeout is only |
| 474 | + # 1 sec for a query that takes longer than that to process |
| 475 | + with self.assertRaises(RequestError) as cm: |
| 476 | + with self.cursor({"_socket_timeout": 1}) as cursor: |
| 477 | + query = "select * from range(10000000)" |
| 478 | + cursor.execute(query) |
| 479 | + |
| 480 | + self.assertIsInstance(cm.exception.args[1], TimeoutError) |
| 481 | + |
471 | 482 | def test_ssp_passthrough(self):
|
472 | 483 | for enable_ansi in (True, False):
|
473 | 484 | with self.cursor({"session_configuration": {"ansi_mode": enable_ansi}}) as cursor:
|
|
0 commit comments