-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes for cloud fetch - part un (#356)
* fixes for cloud fetch Signed-off-by: Andre Furlan <[email protected]> --------- Signed-off-by: Andre Furlan <[email protected]> Co-authored-by: Raymond Cypher <[email protected]>
- Loading branch information
1 parent
a737ef3
commit 6a348ec
Showing
9 changed files
with
229 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from databricks import sql | ||
import os | ||
import logging | ||
|
||
|
||
logger = logging.getLogger("databricks.sql") | ||
logger.setLevel(logging.DEBUG) | ||
fh = logging.FileHandler("pysqllogs.log") | ||
fh.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(process)d %(thread)d %(message)s")) | ||
fh.setLevel(logging.DEBUG) | ||
logger.addHandler(fh) | ||
|
||
with sql.connect( | ||
server_hostname=os.getenv("DATABRICKS_SERVER_HOSTNAME"), | ||
http_path=os.getenv("DATABRICKS_HTTP_PATH"), | ||
access_token=os.getenv("DATABRICKS_TOKEN"), | ||
use_cloud_fetch=True, | ||
max_download_threads = 2 | ||
) as connection: | ||
|
||
with connection.cursor(arraysize=1000, buffer_size_bytes=54857600) as cursor: | ||
print( | ||
"executing query: SELECT * FROM range(0, 20000000) AS t1 LEFT JOIN (SELECT 1) AS t2" | ||
) | ||
cursor.execute("SELECT * FROM range(0, 20000000) AS t1 LEFT JOIN (SELECT 1) AS t2") | ||
try: | ||
while True: | ||
row = cursor.fetchone() | ||
if row is None: | ||
break | ||
print(f"row: {row}") | ||
except sql.exc.ResultSetDownloadError as e: | ||
print(f"error: {e}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.