@@ -145,3 +145,49 @@ def check_transaction(s: ydb.table.Session):
145145 assert rs [0 ].rows [0 ].cnt == 2
146146
147147 pool .retry_operation_sync (check_transaction )
148+
149+
150+ def test_truncated_response (driver_sync , table_name , table_path ):
151+ column_types = ydb .BulkUpsertColumns ().add_column ("id" , ydb .PrimitiveType .Int64 )
152+
153+ rows = []
154+
155+ rows_count = 1100
156+ for i in range (rows_count ):
157+ rows .append ({"id" : i })
158+
159+ driver_sync .table_client .bulk_upsert (table_path , rows , column_types )
160+
161+ table_client = (
162+ driver_sync .table_client
163+ ) # default table client with driver's settings
164+ s = table_client .session ()
165+ s .create ()
166+ t = s .transaction ()
167+
168+ result = t .execute ("SELECT * FROM %s" % table_name )
169+ assert result [0 ].truncated
170+ assert len (result [0 ].rows ) == 1000
171+
172+
173+ @pytest .mark .asyncio
174+ async def test_truncated_response_deny (driver_sync , table_name , table_path ):
175+ column_types = ydb .BulkUpsertColumns ().add_column ("id" , ydb .PrimitiveType .Int64 )
176+
177+ rows = []
178+
179+ rows_count = 1100
180+ for i in range (rows_count ):
181+ rows .append ({"id" : i })
182+
183+ driver_sync .table_client .bulk_upsert (table_path , rows , column_types )
184+
185+ table_client = ydb .TableClient (
186+ driver_sync , ydb .TableClientSettings ().with_allow_truncated_result (False )
187+ )
188+ s = table_client .session ()
189+ s .create ()
190+ t = s .transaction ()
191+
192+ with pytest .raises (ydb .TruncatedResponseError ):
193+ t .execute ("SELECT * FROM %s" % table_name )
0 commit comments