| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -924,7 +924,8 @@ def list_rows(self, table, selected_fields=None, max_results=None, | |||
| 924 | 924 | ||
| 925 | 925 | params = {} | |
| 926 | 926 | if selected_fields is not None: | |
| 927 | - params['selectedFields'] = [f.name for f in selected_fields] | ||
| 927 | + params['selectedFields'] = ','.join( | ||
| 928 | + [f.name for f in selected_fields]) | ||
| 928 | 929 | if start_index is not None: | |
| 929 | 930 | params['startIndex'] = start_index | |
| 930 | 931 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -312,8 +312,9 @@ def test_update_table_schema(self): | |||
| 312 | 312 | self.assertEqual(found.mode, expected.mode) | |
| 313 | 313 | ||
| 314 | 314 | @staticmethod | |
| 315 | - def _fetch_single_page(table): | ||
| 316 | - iterator = Config.CLIENT.list_rows(table) | ||
| 315 | + def _fetch_single_page(table, selected_fields=None): | ||
| 316 | + iterator = Config.CLIENT.list_rows( | ||
| 317 | + table, selected_fields=selected_fields) | ||
| 317 | 318 | page = six.next(iterator.pages) | |
| 318 | 319 | return list(page) | |
| 319 | 320 | ||
@@ -1236,6 +1237,23 @@ def test_dump_table_w_public_data(self): | |||
| 1236 | 1237 | table = Config.CLIENT.get_table(table_ref) | |
| 1237 | 1238 | self._fetch_single_page(table) | |
| 1238 | 1239 | ||
| 1240 | + def test_dump_table_w_public_data_selected_fields(self): | ||
| 1241 | + PUBLIC = 'bigquery-public-data' | ||
| 1242 | + DATASET_ID = 'samples' | ||
| 1243 | + TABLE_NAME = 'natality' | ||
| 1244 | + selected_fields = [ | ||
| 1245 | + bigquery.SchemaField('year', 'INTEGER', mode='NULLABLE'), | ||
| 1246 | + bigquery.SchemaField('month', 'INTEGER', mode='NULLABLE'), | ||
| 1247 | + bigquery.SchemaField('day', 'INTEGER', mode='NULLABLE'), | ||
| 1248 | + ] | ||
| 1249 | + table_ref = DatasetReference(PUBLIC, DATASET_ID).table(TABLE_NAME) | ||
| 1250 | + | ||
| 1251 | + rows = self._fetch_single_page( | ||
| 1252 | + table_ref, selected_fields=selected_fields) | ||
| 1253 | + | ||
| 1254 | + self.assertGreater(len(rows), 0) | ||
| 1255 | + self.assertEqual(len(rows[0]), 3) | ||
| 1256 | + | ||
| 1239 | 1257 | def test_large_query_w_public_data(self): | |
| 1240 | 1258 | PUBLIC = 'bigquery-public-data' | |
| 1241 | 1259 | DATASET_ID = 'samples' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments