Skip to content

Commit

Permalink
Added integration tests for execute_async
Browse files Browse the repository at this point in the history
  • Loading branch information
jprakash-db committed Nov 4, 2024
1 parent 756ac17 commit beffa2f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/e2e/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
compare_dbr_versions,
is_thrift_v5_plus,
)
from databricks.sql.thrift_api.TCLIService import ttypes
from tests.e2e.common.core_tests import CoreTestMixin, SmokeTestMixin
from tests.e2e.common.large_queries_mixin import LargeQueriesMixin
from tests.e2e.common.timestamp_tests import TimestampTestsMixin
Expand Down Expand Up @@ -175,6 +176,26 @@ def test_cloud_fetch(self):
for i in range(len(cf_result)):
assert cf_result[i] == noop_result[i]

def test_execute_async(self):
def isExecuting(operation_state):
return not operation_state or operation_state in [
ttypes.TOperationState.RUNNING_STATE,
ttypes.TOperationState.PENDING_STATE,
]

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%'"
with self.cursor() as cursor:
cursor.execute_async(long_running_query)

## Polling
while isExecuting(cursor.get_query_state()):
log.info("Polling the status in test_execute_async")

cursor.get_execution_result()
result = cursor.fetchall()

assert result[0].asDict() == {"count(1)": 0}


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

0 comments on commit beffa2f

Please sign in to comment.