@@ -787,9 +787,7 @@ def test_result(self):
787
787
"location" : "EU" ,
788
788
},
789
789
"schema" : {"fields" : [{"name" : "col1" , "type" : "STRING" }]},
790
- "totalRows" : "3" ,
791
- "rows" : [{"f" : [{"v" : "abc" }]}],
792
- "pageToken" : "next-page" ,
790
+ "totalRows" : "2" ,
793
791
}
794
792
job_resource = self ._make_resource (started = True , location = "EU" )
795
793
job_resource_done = self ._make_resource (started = True , ended = True , location = "EU" )
@@ -801,9 +799,9 @@ def test_result(self):
801
799
query_page_resource = {
802
800
# Explicitly set totalRows to be different from the initial
803
801
# response to test update during iteration.
804
- "totalRows" : "2 " ,
802
+ "totalRows" : "1 " ,
805
803
"pageToken" : None ,
806
- "rows" : [{"f" : [{"v" : "def " }]}],
804
+ "rows" : [{"f" : [{"v" : "abc " }]}],
807
805
}
808
806
conn = _make_connection (
809
807
query_resource , query_resource_done , job_resource_done , query_page_resource
@@ -814,20 +812,19 @@ def test_result(self):
814
812
result = job .result ()
815
813
816
814
self .assertIsInstance (result , RowIterator )
817
- self .assertEqual (result .total_rows , 3 )
815
+ self .assertEqual (result .total_rows , 2 )
818
816
rows = list (result )
819
- self .assertEqual (len (rows ), 2 )
817
+ self .assertEqual (len (rows ), 1 )
820
818
self .assertEqual (rows [0 ].col1 , "abc" )
821
- self .assertEqual (rows [1 ].col1 , "def" )
822
819
# Test that the total_rows property has changed during iteration, based
823
820
# on the response from tabledata.list.
824
- self .assertEqual (result .total_rows , 2 )
821
+ self .assertEqual (result .total_rows , 1 )
825
822
826
823
query_results_path = f"/projects/{ self .PROJECT } /queries/{ self .JOB_ID } "
827
824
query_results_call = mock .call (
828
825
method = "GET" ,
829
826
path = query_results_path ,
830
- query_params = {"location" : "EU" },
827
+ query_params = {"maxResults" : 0 , " location" : "EU" },
831
828
timeout = None ,
832
829
)
833
830
reload_call = mock .call (
@@ -842,7 +839,6 @@ def test_result(self):
842
839
query_params = {
843
840
"fields" : _LIST_ROWS_FROM_QUERY_RESULTS_FIELDS ,
844
841
"location" : "EU" ,
845
- "pageToken" : "next-page" ,
846
842
},
847
843
timeout = None ,
848
844
)
@@ -855,9 +851,7 @@ def test_result_with_done_job_calls_get_query_results(self):
855
851
"jobComplete" : True ,
856
852
"jobReference" : {"projectId" : self .PROJECT , "jobId" : self .JOB_ID },
857
853
"schema" : {"fields" : [{"name" : "col1" , "type" : "STRING" }]},
858
- "totalRows" : "2" ,
859
- "rows" : [{"f" : [{"v" : "abc" }]}],
860
- "pageToken" : "next-page" ,
854
+ "totalRows" : "1" ,
861
855
}
862
856
job_resource = self ._make_resource (started = True , ended = True , location = "EU" )
863
857
job_resource ["configuration" ]["query" ]["destinationTable" ] = {
@@ -866,9 +860,9 @@ def test_result_with_done_job_calls_get_query_results(self):
866
860
"tableId" : "dest_table" ,
867
861
}
868
862
results_page_resource = {
869
- "totalRows" : "2 " ,
863
+ "totalRows" : "1 " ,
870
864
"pageToken" : None ,
871
- "rows" : [{"f" : [{"v" : "def " }]}],
865
+ "rows" : [{"f" : [{"v" : "abc " }]}],
872
866
}
873
867
conn = _make_connection (query_resource_done , results_page_resource )
874
868
client = _make_client (self .PROJECT , connection = conn )
@@ -877,15 +871,14 @@ def test_result_with_done_job_calls_get_query_results(self):
877
871
result = job .result ()
878
872
879
873
rows = list (result )
880
- self .assertEqual (len (rows ), 2 )
874
+ self .assertEqual (len (rows ), 1 )
881
875
self .assertEqual (rows [0 ].col1 , "abc" )
882
- self .assertEqual (rows [1 ].col1 , "def" )
883
876
884
877
query_results_path = f"/projects/{ self .PROJECT } /queries/{ self .JOB_ID } "
885
878
query_results_call = mock .call (
886
879
method = "GET" ,
887
880
path = query_results_path ,
888
- query_params = {"location" : "EU" },
881
+ query_params = {"maxResults" : 0 , " location" : "EU" },
889
882
timeout = None ,
890
883
)
891
884
query_results_page_call = mock .call (
@@ -894,7 +887,6 @@ def test_result_with_done_job_calls_get_query_results(self):
894
887
query_params = {
895
888
"fields" : _LIST_ROWS_FROM_QUERY_RESULTS_FIELDS ,
896
889
"location" : "EU" ,
897
- "pageToken" : "next-page" ,
898
890
},
899
891
timeout = None ,
900
892
)
@@ -908,12 +900,6 @@ def test_result_with_max_results(self):
908
900
"jobReference" : {"projectId" : self .PROJECT , "jobId" : self .JOB_ID },
909
901
"schema" : {"fields" : [{"name" : "col1" , "type" : "STRING" }]},
910
902
"totalRows" : "5" ,
911
- # These rows are discarded because max_results is set.
912
- "rows" : [
913
- {"f" : [{"v" : "xyz" }]},
914
- {"f" : [{"v" : "uvw" }]},
915
- {"f" : [{"v" : "rst" }]},
916
- ],
917
903
}
918
904
query_page_resource = {
919
905
"totalRows" : "5" ,
@@ -939,7 +925,6 @@ def test_result_with_max_results(self):
939
925
rows = list (result )
940
926
941
927
self .assertEqual (len (rows ), 3 )
942
- self .assertEqual (rows [0 ].col1 , "abc" )
943
928
self .assertEqual (len (connection .api_request .call_args_list ), 2 )
944
929
query_page_request = connection .api_request .call_args_list [1 ]
945
930
self .assertEqual (
@@ -994,7 +979,7 @@ def test_result_w_retry(self):
994
979
query_results_call = mock .call (
995
980
method = "GET" ,
996
981
path = f"/projects/{ self .PROJECT } /queries/{ self .JOB_ID } " ,
997
- query_params = {"location" : "asia-northeast1" },
982
+ query_params = {"maxResults" : 0 , " location" : "asia-northeast1" },
998
983
timeout = None ,
999
984
)
1000
985
reload_call = mock .call (
@@ -1094,12 +1079,6 @@ def test_result_w_page_size(self):
1094
1079
"jobReference" : {"projectId" : self .PROJECT , "jobId" : self .JOB_ID },
1095
1080
"schema" : {"fields" : [{"name" : "col1" , "type" : "STRING" }]},
1096
1081
"totalRows" : "4" ,
1097
- # These rows are discarded because page_size is set.
1098
- "rows" : [
1099
- {"f" : [{"v" : "xyz" }]},
1100
- {"f" : [{"v" : "uvw" }]},
1101
- {"f" : [{"v" : "rst" }]},
1102
- ],
1103
1082
}
1104
1083
job_resource = self ._make_resource (started = True , ended = True , location = "US" )
1105
1084
q_config = job_resource ["configuration" ]["query" ]
@@ -1130,7 +1109,6 @@ def test_result_w_page_size(self):
1130
1109
# Assert
1131
1110
actual_rows = list (result )
1132
1111
self .assertEqual (len (actual_rows ), 4 )
1133
- self .assertEqual (actual_rows [0 ].col1 , "row1" )
1134
1112
1135
1113
query_results_path = f"/projects/{ self .PROJECT } /queries/{ self .JOB_ID } "
1136
1114
query_page_1_call = mock .call (
@@ -1164,12 +1142,6 @@ def test_result_with_start_index(self):
1164
1142
"jobReference" : {"projectId" : self .PROJECT , "jobId" : self .JOB_ID },
1165
1143
"schema" : {"fields" : [{"name" : "col1" , "type" : "STRING" }]},
1166
1144
"totalRows" : "5" ,
1167
- # These rows are discarded because start_index is set.
1168
- "rows" : [
1169
- {"f" : [{"v" : "xyz" }]},
1170
- {"f" : [{"v" : "uvw" }]},
1171
- {"f" : [{"v" : "rst" }]},
1172
- ],
1173
1145
}
1174
1146
tabledata_resource = {
1175
1147
"totalRows" : "5" ,
@@ -1196,7 +1168,6 @@ def test_result_with_start_index(self):
1196
1168
rows = list (result )
1197
1169
1198
1170
self .assertEqual (len (rows ), 4 )
1199
- self .assertEqual (rows [0 ].col1 , "abc" )
1200
1171
self .assertEqual (len (connection .api_request .call_args_list ), 2 )
1201
1172
tabledata_list_request = connection .api_request .call_args_list [1 ]
1202
1173
self .assertEqual (
0 commit comments