File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1298,17 +1298,13 @@ def __init__(
12981298 page_start = _rows_page_start ,
12991299 next_token = "pageToken" ,
13001300 )
1301- self ._schema = schema
13021301 self ._field_to_index = _helpers ._field_to_index_mapping (schema )
1303-
1304- self ._total_rows = None
1305- if table is not None and hasattr (table , "num_rows" ):
1306- self ._total_rows = table .num_rows
1307-
13081302 self ._page_size = page_size
1309- self ._table = table
1310- self ._selected_fields = selected_fields
13111303 self ._project = client .project
1304+ self ._schema = schema
1305+ self ._selected_fields = selected_fields
1306+ self ._table = table
1307+ self ._total_rows = getattr (table , "num_rows" , None )
13121308
13131309 def _get_next_page_response (self ):
13141310 """Requests the next page from the path provided.
Original file line number Diff line number Diff line change @@ -4021,6 +4021,8 @@ def test_result(self):
40214021 "totalRows" : "2" ,
40224022 }
40234023 tabledata_resource = {
4024+ # Explicitly set totalRows to be different from the query response.
4025+ # to test update during iteration.
40244026 "totalRows" : "1" ,
40254027 "pageToken" : None ,
40264028 "rows" : [{"f" : [{"v" : "abc" }]}],
@@ -4038,6 +4040,8 @@ def test_result(self):
40384040 rows = list (result )
40394041 self .assertEqual (len (rows ), 1 )
40404042 self .assertEqual (rows [0 ].col1 , "abc" )
4043+ # Test that the total_rows property has changed during iteration, based
4044+ # on the response from tabledata.list.
40414045 self .assertEqual (result .total_rows , 1 )
40424046
40434047 def test_result_w_empty_schema (self ):
You can’t perform that action at this time.
0 commit comments