Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0fd7347

Browse files
authored
feat: Support jsonExtension in LoadJobConfig (#1751)
* feat: support jsonExtension in LoadJobConfig* reformatted with black* Updated doc string and added test for the encoding of jsonExtension* modified setter test to make sure property is set correctly
1 parenta167f9a commit0fd7347

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

‎google/cloud/bigquery/job/load.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,19 @@ def ignore_unknown_values(self):
327327
defignore_unknown_values(self,value):
328328
self._set_sub_prop("ignoreUnknownValues",value)
329329

330+
@property
331+
defjson_extension(self):
332+
"""Optional[str]: The extension to use for writing JSON data to BigQuery. Only supports GeoJSON currently.
333+
334+
See: https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationLoad.FIELDS.json_extension
335+
336+
"""
337+
returnself._get_sub_prop("jsonExtension")
338+
339+
@json_extension.setter
340+
defjson_extension(self,value):
341+
self._set_sub_prop("jsonExtension",value)
342+
330343
@property
331344
defmax_bad_records(self):
332345
"""Optional[int]: Number of invalid rows to ignore.

‎tests/unit/job/test_load_config.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,29 @@ def test_ignore_unknown_values_setter(self):
413413
config.ignore_unknown_values=True
414414
self.assertTrue(config._properties["load"]["ignoreUnknownValues"])
415415

416+
deftest_json_extension_missing(self):
417+
config=self._get_target_class()()
418+
self.assertIsNone(config.json_extension)
419+
420+
deftest_json_extension_hit(self):
421+
config=self._get_target_class()()
422+
config._properties["load"]["jsonExtension"]="GEOJSON"
423+
self.assertEqual(config.json_extension,"GEOJSON")
424+
425+
deftest_json_extension_setter(self):
426+
config=self._get_target_class()()
427+
self.assertFalse(config.json_extension)
428+
config.json_extension="GEOJSON"
429+
self.assertTrue(config.json_extension)
430+
self.assertEqual(config._properties["load"]["jsonExtension"],"GEOJSON")
431+
432+
deftest_to_api_repr_includes_json_extension(self):
433+
config=self._get_target_class()()
434+
config._properties["load"]["jsonExtension"]="GEOJSON"
435+
api_repr=config.to_api_repr()
436+
self.assertIn("jsonExtension",api_repr["load"])
437+
self.assertEqual(api_repr["load"]["jsonExtension"],"GEOJSON")
438+
416439
deftest_max_bad_records_missing(self):
417440
config=self._get_target_class()()
418441
self.assertIsNone(config.max_bad_records)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp