Skip to content

Commit 04d3819

Browse files
SNOW-1977987 expectation about the default lengths of LOB fields is not valid anymore #2209
1 parent 44eb130 commit 04d3819

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"
@@ -1608,7 +1633,9 @@ def test_resultbatch(
16081633
("arrow", "snowflake.connector.result_batch.ArrowResultBatch.create_iter"),
16091634
),
16101635
)
1611-
def test_resultbatch_lazy_fetching_and_schemas(conn_cnx, result_format, patch_path):
1636+
def test_resultbatch_lazy_fetching_and_schemas(
1637+
conn_cnx, result_format, patch_path, lob_params
1638+
):
16121639
"""Tests whether pre-fetching results chunks fetches the right amount of them."""
16131640
rowcount = 1000000 # We need at least 5 chunks for this test
16141641
with conn_cnx(
@@ -1636,7 +1663,17 @@ def test_resultbatch_lazy_fetching_and_schemas(conn_cnx, result_format, patch_pa
16361663
# all batches should have the same schema
16371664
assert schema == [
16381665
ResultMetadata("C1", 0, None, None, 10, 0, False),
1639-
ResultMetadata("C2", 2, None, 16777216, None, None, False),
1666+
ResultMetadata(
1667+
"C2",
1668+
2,
1669+
None,
1670+
schema[
1671+
1
1672+
].internal_size, # TODO: lob_params.max_lob_size_in_memory,
1673+
None,
1674+
None,
1675+
False,
1676+
),
16401677
]
16411678
assert patched_download.call_count == 0
16421679
assert len(result_batches) > 5
@@ -1657,7 +1694,7 @@ def test_resultbatch_lazy_fetching_and_schemas(conn_cnx, result_format, patch_pa
16571694

16581695
@pytest.mark.skipolddriver(reason="new feature in v2.5.0")
16591696
@pytest.mark.parametrize("result_format", ["json", "arrow"])
1660-
def test_resultbatch_schema_exists_when_zero_rows(conn_cnx, result_format):
1697+
def test_resultbatch_schema_exists_when_zero_rows(conn_cnx, result_format, lob_params):
16611698
with conn_cnx(
16621699
session_parameters={"python_connector_query_result_format": result_format}
16631700
) as con:
@@ -1673,7 +1710,15 @@ def test_resultbatch_schema_exists_when_zero_rows(conn_cnx, result_format):
16731710
schema = result_batches[0].schema
16741711
assert schema == [
16751712
ResultMetadata("C1", 0, None, None, 10, 0, False),
1676-
ResultMetadata("C2", 2, None, 16777216, None, None, False),
1713+
ResultMetadata(
1714+
"C2",
1715+
2,
1716+
None,
1717+
schema[1].internal_size, # TODO: lob_params.max_lob_size_in_memory,
1718+
None,
1719+
None,
1720+
False,
1721+
),
16771722
]
16781723

16791724

0 commit comments

Comments
 (0)