FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
databricks-sql-python/examples/query_async_execute.py at main · databricks/databricks-sql-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
databricks
/
databricks-sql-python
Public
Notifications
You must be signed in to change notification settings
Fork
147
Star
233
Code
Issues
99
Pull requests
78
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
databricks-sql-python
/
examples
/
query_async_execute.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (25 loc) · 934 Bytes
Breadcrumbs
databricks-sql-python
/
examples
/
query_async_execute.py
Copy path
File metadata and controls
32 lines (25 loc) · 934 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from
databricks
import
sql
import
os
import
time
with
sql
.
connect
(
server_hostname
=
os
.
getenv
(
"DATABRICKS_SERVER_HOSTNAME"
),
http_path
=
os
.
getenv
(
"DATABRICKS_HTTP_PATH"
),
access_token
=
os
.
getenv
(
"DATABRICKS_TOKEN"
),
)
as
connection
:
with
connection
.
cursor
()
as
cursor
:
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%'
"""
# Non-blocking call
cursor
.
execute_async
(
long_running_query
)
# Polling every 5 seconds until the query is no longer pending
while
cursor
.
is_query_pending
():
print
(
"POLLING"
)
time
.
sleep
(
5
)
# Blocking call: fetch results when execution completes
cursor
.
get_async_execution_result
()
result
=
cursor
.
fetchall
()
for
res
in
result
:
print
(
res
)
Back
|
FazBrowse Home
|
New Git URL