Skip to content

Commit 83b0991

Browse files
sfc-gh-stakedaankit-bhatnagar167
authored andcommitted
SNOW-105364: added PYTHON_CONNECTOR_QUERY_RESULT_FORMAT
1 parent 7bcbca2 commit 83b0991

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

scripts/install.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SET SCRIPT_DIR=%~dp0
77
"%PYTHON%/python.exe" -m venv env
88
call env\Scripts\activate
99
# https://github.com/pypa/pip/issues/6566
10-
python -m pip install --upgrade pip==18.1
10+
python -m pip install --upgrade pip
1111
pip install pandas
1212
pip install numpy
1313
pip install pendulum
@@ -25,4 +25,4 @@ set /p connector_whl=<whl_name
2525
pip install %connector_whl%
2626
pip list --format=columns
2727

28-
cd %SCRIPT_DIR%/..
28+
cd %SCRIPT_DIR%/..

test/test_arrow_pandas.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
no_arrow_iterator_ext = True
2525

2626
SQL_ENABLE_ARROW = "alter session set query_result_format='ARROW_FORCE';"
27+
SQL_ENABLE_ARROW_V2 = "alter session set python_connector_query_result_format='ARROW_FORCE';"
2728

2829
EPSILON = 1e-8
2930

@@ -229,6 +230,7 @@ def test_semi_struct(conn_cnx):
229230
# fetch dataframe with new arrow support
230231
cursor_table = cnx_table.cursor()
231232
cursor_table.execute(SQL_ENABLE_ARROW)
233+
cursor_table.execute(SQL_ENABLE_ARROW_V2)
232234
cursor_table.execute(sql_text)
233235
df_new = cursor_table.fetch_pandas_all()
234236
col_new = df_new.iloc[0]
@@ -430,6 +432,7 @@ def validate_pandas(conn_cnx, sql, cases, col_count, method='one', data_type='fl
430432
# fetch dataframe with new arrow support
431433
cursor_table = cnx_table.cursor()
432434
cursor_table.execute(SQL_ENABLE_ARROW)
435+
cursor_table.execute(SQL_ENABLE_ARROW_V2)
433436
cursor_table.execute(sql)
434437

435438
# build dataframe
@@ -524,6 +527,7 @@ def test_empty(conn_cnx):
524527
with conn_cnx() as cnx:
525528
cursor = cnx.cursor()
526529
cursor.execute(SQL_ENABLE_ARROW)
530+
cursor.execute(SQL_ENABLE_ARROW_V2)
527531
cursor.execute("select seq4() from table(generator(rowcount=>1)) limit 0")
528532
assert cursor.fetch_pandas_all() is None, 'the result is not none'
529533

@@ -553,6 +557,7 @@ def fetch_pandas(conn_cnx, sql, row_count, col_count, method='one'):
553557
# fetch dataframe by fetching row by row
554558
cursor_row = cnx_row.cursor()
555559
cursor_row.execute(SQL_ENABLE_ARROW)
560+
cursor_row.execute(SQL_ENABLE_ARROW_V2)
556561
cursor_row.execute(sql)
557562

558563
# build dataframe
@@ -578,6 +583,7 @@ def fetch_pandas(conn_cnx, sql, row_count, col_count, method='one'):
578583
# fetch dataframe with new arrow support
579584
cursor_table = cnx_table.cursor()
580585
cursor_table.execute(SQL_ENABLE_ARROW)
586+
cursor_table.execute(SQL_ENABLE_ARROW_V2)
581587
cursor_table.execute(sql)
582588

583589
# build dataframe

test/test_arrow_result.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def test_select_with_empty_resultset(conn_cnx):
413413
with conn_cnx() as cnx:
414414
cursor = cnx.cursor()
415415
cursor.execute("alter session set query_result_format='ARROW_FORCE'")
416+
cursor.execute("alter session set python_connector_query_result_format='ARROW_FORCE'")
416417
cursor.execute("select seq4() from table(generator(rowcount=>100)) limit 0")
417418

418419
assert cursor.fetchone() is None
@@ -448,10 +449,12 @@ def iterate_over_test_chunk(test_name, conn_cnx, sql_text, row_count, col_count,
448449
if expected is None:
449450
cursor_json = json_cnx.cursor()
450451
cursor_json.execute("alter session set query_result_format='JSON'")
452+
cursor_json.execute("alter session set python_connector_query_result_format='JSON'")
451453
cursor_json.execute(sql_text)
452454

453455
cursor_arrow = arrow_cnx.cursor()
454456
cursor_arrow.execute("alter session set query_result_format='ARROW_FORCE'")
457+
cursor_arrow.execute("alter session set python_connector_query_result_format='ARROW_FORCE'")
455458
cursor_arrow.execute(sql_text)
456459

457460
if expected is None:

0 commit comments

Comments
 (0)