Skip to content

Commit beffa2f

Browse files
committed
Added integration tests for execute_async
1 parent 756ac17 commit beffa2f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/e2e/test_driver.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
compare_dbr_versions,
3737
is_thrift_v5_plus,
3838
)
39+
from databricks.sql.thrift_api.TCLIService import ttypes
3940
from tests.e2e.common.core_tests import CoreTestMixin, SmokeTestMixin
4041
from tests.e2e.common.large_queries_mixin import LargeQueriesMixin
4142
from tests.e2e.common.timestamp_tests import TimestampTestsMixin
@@ -175,6 +176,26 @@ def test_cloud_fetch(self):
175176
for i in range(len(cf_result)):
176177
assert cf_result[i] == noop_result[i]
177178

179+
def test_execute_async(self):
180+
def isExecuting(operation_state):
181+
return not operation_state or operation_state in [
182+
ttypes.TOperationState.RUNNING_STATE,
183+
ttypes.TOperationState.PENDING_STATE,
184+
]
185+
186+
long_running_query = "SELECT COUNT(*) FROM RANGE(10000 * 16) x JOIN RANGE(10000) y ON FROM_UNIXTIME(x.id * y.id, 'yyyy-MM-dd') LIKE '%not%a%date%'"
187+
with self.cursor() as cursor:
188+
cursor.execute_async(long_running_query)
189+
190+
## Polling
191+
while isExecuting(cursor.get_query_state()):
192+
log.info("Polling the status in test_execute_async")
193+
194+
cursor.get_execution_result()
195+
result = cursor.fetchall()
196+
197+
assert result[0].asDict() == {"count(1)": 0}
198+
178199

179200
# Exclude Retry tests because they require specific setups, and LargeQueries too slow for core
180201
# tests

0 commit comments

Comments
 (0)