Skip to content

Commit 5531b8e

Browse files
sfc-gh-mmishchenkosfc-gh-pczajka
authored andcommitted
SNOW-1977987 expectation about the default lengths of LOB fields is not valid anymore #2209
1 parent 9430ff0 commit 5531b8e

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

test/integ/test_cursor.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,31 @@ def fin():
130130
return conn_cnx
131131

132132

133+
class LobBackendParams(NamedTuple):
134+
max_lob_size_in_memory: int
135+
136+
137+
@pytest.fixture()
138+
def lob_params(conn_cnx) -> LobBackendParams:
139+
with conn_cnx() as cnx:
140+
(max_lob_size_in_memory_feat, max_lob_size_in_memory) = (
141+
(cnx.cursor().execute(f"show parameters like '{lob_param}'").fetchone())
142+
for lob_param in (
143+
"FEATURE_INCREASED_MAX_LOB_SIZE_IN_MEMORY",
144+
"MAX_LOB_SIZE_IN_MEMORY",
145+
)
146+
)
147+
max_lob_size_in_memory_feat = (
148+
max_lob_size_in_memory_feat and max_lob_size_in_memory_feat[1] == "ENABLED"
149+
)
150+
max_lob_size_in_memory = (
151+
int(max_lob_size_in_memory[1])
152+
if (max_lob_size_in_memory_feat and max_lob_size_in_memory)
153+
else 2**24
154+
)
155+
return LobBackendParams(max_lob_size_in_memory)
156+
157+
133158
def _check_results(cursor, results):
134159
assert cursor.sfqid, "Snowflake query id is None"
135160
assert cursor.rowcount == 3, "the number of records"
@@ -1564,7 +1589,9 @@ def test_resultbatch(
15641589
("arrow", "snowflake.connector.result_batch.ArrowResultBatch.create_iter"),
15651590
),
15661591
)
1567-
def test_resultbatch_lazy_fetching_and_schemas(conn_cnx, result_format, patch_path):
1592+
def test_resultbatch_lazy_fetching_and_schemas(
1593+
conn_cnx, result_format, patch_path, lob_params
1594+
):
15681595
"""Tests whether pre-fetching results chunks fetches the right amount of them."""
15691596
rowcount = 1000000 # We need at least 5 chunks for this test
15701597
with conn_cnx(
@@ -1592,7 +1619,17 @@ def test_resultbatch_lazy_fetching_and_schemas(conn_cnx, result_format, patch_pa
15921619
# all batches should have the same schema
15931620
assert schema == [
15941621
ResultMetadata("C1", 0, None, None, 10, 0, False),
1595-
ResultMetadata("C2", 2, None, 16777216, None, None, False),
1622+
ResultMetadata(
1623+
"C2",
1624+
2,
1625+
None,
1626+
schema[
1627+
1
1628+
].internal_size, # TODO: lob_params.max_lob_size_in_memory,
1629+
None,
1630+
None,
1631+
False,
1632+
),
15961633
]
15971634
assert patched_download.call_count == 0
15981635
assert len(result_batches) > 5
@@ -1613,7 +1650,7 @@ def test_resultbatch_lazy_fetching_and_schemas(conn_cnx, result_format, patch_pa
16131650

16141651
@pytest.mark.skipolddriver(reason="new feature in v2.5.0")
16151652
@pytest.mark.parametrize("result_format", ["json", "arrow"])
1616-
def test_resultbatch_schema_exists_when_zero_rows(conn_cnx, result_format):
1653+
def test_resultbatch_schema_exists_when_zero_rows(conn_cnx, result_format, lob_params):
16171654
with conn_cnx(
16181655
session_parameters={"python_connector_query_result_format": result_format}
16191656
) as con:
@@ -1629,7 +1666,15 @@ def test_resultbatch_schema_exists_when_zero_rows(conn_cnx, result_format):
16291666
schema = result_batches[0].schema
16301667
assert schema == [
16311668
ResultMetadata("C1", 0, None, None, 10, 0, False),
1632-
ResultMetadata("C2", 2, None, 16777216, None, None, False),
1669+
ResultMetadata(
1670+
"C2",
1671+
2,
1672+
None,
1673+
schema[1].internal_size, # TODO: lob_params.max_lob_size_in_memory,
1674+
None,
1675+
None,
1676+
False,
1677+
),
16331678
]
16341679

16351680

0 commit comments

Comments
 (0)