@@ -673,7 +673,7 @@ def test_job_cancel(self):
673
673
# raise an error, and that the job completed (in the `retry()`
674
674
# above).
675
675
676
- def test_query_rows_w_legacy_sql_types (self ):
676
+ def test_query_w_legacy_sql_types (self ):
677
677
naive = datetime .datetime (2016 , 12 , 5 , 12 , 41 , 9 )
678
678
stamp = '%s %s' % (naive .date ().isoformat (), naive .time ().isoformat ())
679
679
zoned = naive .replace (tzinfo = UTC )
@@ -706,7 +706,7 @@ def test_query_rows_w_legacy_sql_types(self):
706
706
for example in examples :
707
707
job_config = bigquery .QueryJobConfig ()
708
708
job_config .use_legacy_sql = True
709
- rows = list (Config .CLIENT .query_rows (
709
+ rows = list (Config .CLIENT .query (
710
710
example ['sql' ], job_config = job_config ))
711
711
self .assertEqual (len (rows ), 1 )
712
712
self .assertEqual (len (rows [0 ]), 1 )
@@ -806,26 +806,28 @@ def _generate_standard_sql_types_examples(self):
806
806
},
807
807
]
808
808
809
- def test_query_rows_w_standard_sql_types (self ):
809
+ def test_query_w_standard_sql_types (self ):
810
810
examples = self ._generate_standard_sql_types_examples ()
811
811
for example in examples :
812
- rows = list (Config .CLIENT .query_rows (example ['sql' ]))
812
+ rows = list (Config .CLIENT .query (example ['sql' ]))
813
813
self .assertEqual (len (rows ), 1 )
814
814
self .assertEqual (len (rows [0 ]), 1 )
815
815
self .assertEqual (rows [0 ][0 ], example ['expected' ])
816
816
817
- def test_query_rows_w_failed_query (self ):
817
+ def test_query_w_failed_query (self ):
818
818
from google .api_core .exceptions import BadRequest
819
819
820
820
with self .assertRaises (BadRequest ):
821
- Config .CLIENT .query_rows ('invalid syntax;' )
821
+ Config .CLIENT .query ('invalid syntax;' ).result ()
822
+
823
+ def test_query_w_timeout (self ):
824
+ query_job = Config .CLIENT .query (
825
+ 'SELECT * FROM `bigquery-public-data.github_repos.commits`;' ,
826
+ job_id_prefix = 'test_query_w_timeout_' )
822
827
823
- def test_query_rows_w_timeout (self ):
824
828
with self .assertRaises (concurrent .futures .TimeoutError ):
825
- Config .CLIENT .query_rows (
826
- 'SELECT * FROM `bigquery-public-data.github_repos.commits`;' ,
827
- job_id_prefix = 'test_query_rows_w_timeout_' ,
828
- timeout = 1 ) # 1 second is much too short for this query.
829
+ # 1 second is much too short for this query.
830
+ query_job .result (timeout = 1 )
829
831
830
832
def test_dbapi_w_standard_sql_types (self ):
831
833
examples = self ._generate_standard_sql_types_examples ()
@@ -1224,9 +1226,9 @@ def test_large_query_w_public_data(self):
1224
1226
SQL = 'SELECT * from `{}.{}.{}` LIMIT {}' .format (
1225
1227
PUBLIC , DATASET_ID , TABLE_NAME , LIMIT )
1226
1228
1227
- iterator = Config .CLIENT .query_rows (SQL )
1229
+ query_job = Config .CLIENT .query (SQL )
1228
1230
1229
- rows = list (iterator )
1231
+ rows = list (query_job )
1230
1232
self .assertEqual (len (rows ), LIMIT )
1231
1233
1232
1234
def test_query_future (self ):
@@ -1256,7 +1258,7 @@ def test_query_table_def(self):
1256
1258
job_config .table_definitions = {table_id : ec }
1257
1259
sql = 'SELECT * FROM %s' % table_id
1258
1260
1259
- got_rows = Config .CLIENT .query_rows (sql , job_config = job_config )
1261
+ got_rows = Config .CLIENT .query (sql , job_config = job_config )
1260
1262
1261
1263
row_tuples = [r .values () for r in got_rows ]
1262
1264
by_age = operator .itemgetter (1 )
@@ -1280,7 +1282,7 @@ def test_query_external_table(self):
1280
1282
1281
1283
sql = 'SELECT * FROM %s.%s' % (dataset_id , table_id )
1282
1284
1283
- got_rows = Config .CLIENT .query_rows (sql )
1285
+ got_rows = Config .CLIENT .query (sql )
1284
1286
1285
1287
row_tuples = [r .values () for r in got_rows ]
1286
1288
by_age = operator .itemgetter (1 )
0 commit comments