Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b51b4e

Browse files
committed
Added unit tests
1 parented0f73b commit3b51b4e

File tree

2 files changed

+64
-10
lines changed

2 files changed

+64
-10
lines changed

‎src/databricks/sql/thrift_backend.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,9 +899,11 @@ def execute_command(
899899
statement=operation,
900900
runAsync=True,
901901
# For async operation we don't want the direct results
902-
getDirectResults=ttypes.TSparkGetDirectResults(
903-
maxRows=0ifasync_opelsemax_rows,
904-
maxBytes=0ifasync_opelsemax_bytes,
902+
getDirectResults=None
903+
ifasync_op
904+
elsettypes.TSparkGetDirectResults(
905+
maxRows=max_rows,
906+
maxBytes=max_bytes,
905907
),
906908
canReadArrowResult=TrueifpyarrowelseFalse,
907909
canDecompressLZ4Result=lz4_compression,

‎tests/e2e/test_driver.py‎

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,22 @@ def test_cloud_fetch(self):
177177
foriinrange(len(cf_result)):
178178
assertcf_result[i]==noop_result[i]
179179

180-
deftest_execute_async(self):
181-
defisExecuting(operation_state):
182-
returnnotoperation_stateoroperation_statein [
183-
ttypes.TOperationState.RUNNING_STATE,
184-
ttypes.TOperationState.PENDING_STATE,
185-
]
180+
181+
classTestPySQLAsyncQueriesSuite(PySQLPytestTestCase):
182+
defisExecuting(self,operation_state):
183+
returnnotoperation_stateoroperation_statein [
184+
ttypes.TOperationState.RUNNING_STATE,
185+
ttypes.TOperationState.PENDING_STATE,
186+
]
187+
188+
deftest_execute_async__long_running(self):
186189

187190
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%'"
188191
withself.cursor()ascursor:
189192
cursor.execute_async(long_running_query)
190193

191194
## Polling after every POLLING_INTERVAL seconds
192-
whileisExecuting(cursor.get_query_state()):
195+
whileself.isExecuting(cursor.get_query_state()):
193196
time.sleep(self.POLLING_INTERVAL)
194197
log.info("Polling the status in test_execute_async")
195198

@@ -198,6 +201,55 @@ def isExecuting(operation_state):
198201

199202
assertresult[0].asDict()== {"count(1)":0}
200203

204+
deftest_execute_async__small_result(self):
205+
small_result_query="SELECT 1"
206+
207+
withself.cursor()ascursor:
208+
cursor.execute_async(small_result_query)
209+
210+
## Fake sleep for 5 secs
211+
time.sleep(5)
212+
213+
## Polling after every POLLING_INTERVAL seconds
214+
whileself.isExecuting(cursor.get_query_state()):
215+
time.sleep(self.POLLING_INTERVAL)
216+
log.info("Polling the status in test_execute_async")
217+
218+
cursor.get_async_execution_result()
219+
result=cursor.fetchall()
220+
221+
assertresult[0].asDict()== {"1":1}
222+
223+
deftest_execute_async__large_result(self):
224+
x_dimension=1000
225+
y_dimension=1000
226+
large_result_query=f"""
227+
SELECT
228+
x.id AS x_id,
229+
y.id AS y_id,
230+
FROM_UNIXTIME(x.id * y.id, 'yyyy-MM-dd') AS date
231+
FROM
232+
RANGE({x_dimension}) x
233+
JOIN
234+
RANGE({y_dimension}) y
235+
"""
236+
237+
withself.cursor()ascursor:
238+
cursor.execute_async(large_result_query)
239+
240+
## Fake sleep for 5 secs
241+
time.sleep(5)
242+
243+
## Polling after every POLLING_INTERVAL seconds
244+
whileself.isExecuting(cursor.get_query_state()):
245+
time.sleep(self.POLLING_INTERVAL)
246+
log.info("Polling the status in test_execute_async")
247+
248+
cursor.get_async_execution_result()
249+
result=cursor.fetchall()
250+
251+
assertlen(result)==x_dimension*y_dimension
252+
201253

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp