@@ -40,23 +40,26 @@ def get_connection(coordinator):
4040
4141 # The table tpch.sf100.customer has 15 million rows but Python consumes
4242 # too much memory to retrieve all of them at once.
43- # Fetching them one by one is too slow, so we fetch only 10k rows which seems to be enough
43+ # Fetching them one by one is too slow, so we fetch enough rows
4444 # for Trino to use the spooling protocol.
45- # Fetching less rows is too risky IMO as Trino might decide to not use spooling.
45+ # Fetching too few rows is risky as Trino might decide to not use spooling.
4646
4747 print ("🚜 fetching many rows from Trino to trigger spooling..." )
4848
49- cursor .execute ("SELECT * FROM tpch.sf100.customer" )
5049 customer_count = 0
51- batch = 10
52- while batch > 0 :
53- print (f"⏳ fetching batch { batch } of 1000 rows..." )
54- cursor .fetchmany (1_000 )
55- customer_count += 1_000
56- batch = batch - 1
57-
58- assert customer_count == 10_000 , (
59- f"💀 crap! expected 10_000 customers, got { customer_count } "
50+ batch_count = 50
51+ batch_size = 1_000
52+ expected_customers = batch_count * 1_000
53+
54+ cursor .execute ("SELECT * FROM tpch.sf100.customer" )
55+ while batch_count > 0 :
56+ print (f"⏳ fetching batch { batch_count } of { batch_size } rows..." )
57+ _ = cursor .fetchmany (batch_size )
58+ customer_count += batch_size
59+ batch_count = batch_count - 1
60+
61+ assert customer_count == expected_customers , (
62+ f"💀 crap! expected { expected_customers } customers, got { customer_count } "
6063 )
6164
6265 print ("🎉 major success!" )
0 commit comments