Skip to content

Commit

Permalink
feat: add preserveAsciiControlCharacter to LoadJobConfig (#1484)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattix23 committed Jan 31, 2023
1 parent 2479394 commit bd1da9a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions google/cloud/bigquery/job/load.py
Expand Up @@ -311,6 +311,19 @@ def null_marker(self):
def null_marker(self, value):
self._set_sub_prop("nullMarker", value)

@property
def preserve_ascii_control_characters(self):
"""Optional[bool]: Preserves the embedded ASCII control characters when sourceFormat is set to CSV.
See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationLoad.FIELDS.preserve_ascii_control_characters
"""
return self._get_sub_prop("preserveAsciiControlCharacters")

@preserve_ascii_control_characters.setter
def preserve_ascii_control_characters(self, value):
self._set_sub_prop("preserveAsciiControlCharacters", bool(value))

@property
def projection_fields(self) -> Optional[List[str]]:
"""Optional[List[str]]: If
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/job/test_load_config.py
Expand Up @@ -424,6 +424,20 @@ def test_null_marker_setter(self):
config.null_marker = null_marker
self.assertEqual(config._properties["load"]["nullMarker"], null_marker)

def test_preserve_ascii_control_characters_missing(self):
config = self._get_target_class()()
self.assertIsNone(config.preserve_ascii_control_characters)

def test_preserve_ascii_control_characters_hit(self):
config = self._get_target_class()()
config._properties["load"]["preserveAsciiControlCharacters"] = True
self.assertTrue(config.preserve_ascii_control_characters)

def test_preserve_ascii_control_characters_setter(self):
config = self._get_target_class()()
config.preserve_ascii_control_characters = True
self.assertTrue(config._properties["load"]["preserveAsciiControlCharacters"])

def test_projection_fields_miss(self):
config = self._get_target_class()()
self.assertIsNone(config.projection_fields)
Expand Down

0 comments on commit bd1da9a

Please sign in to comment.