Skip to content

Commit

Permalink
nullMarker support for BigQuery Load Jobs (#3449) (#3777)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon de Almeida authored and lukesneeringer committed Aug 9, 2017
1 parent c24123c commit 1fcd53d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ class _LoadConfiguration(object):
_field_delimiter = None
_ignore_unknown_values = None
_max_bad_records = None
_null_marker = None
_quote_character = None
_skip_leading_rows = None
_source_format = None
Expand Down Expand Up @@ -672,6 +673,11 @@ def output_rows(self):
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.maxBadRecords
"""

null_marker = _TypedProperty('null_marker', six.string_types)
"""See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.nullMarker
"""

quote_character = _TypedProperty('quote_character', six.string_types)
"""See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.quote
Expand Down Expand Up @@ -710,6 +716,8 @@ def _populate_config_resource(self, configuration):
configuration['ignoreUnknownValues'] = self.ignore_unknown_values
if self.max_bad_records is not None:
configuration['maxBadRecords'] = self.max_bad_records
if self.null_marker is not None:
configuration['nullMarker'] = self.null_marker
if self.quote_character is not None:
configuration['quote'] = self.quote_character
if self.skip_leading_rows is not None:
Expand Down
8 changes: 8 additions & 0 deletions bigquery/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ def _verifyResourceProperties(self, job, resource):
config['maxBadRecords'])
else:
self.assertIsNone(job.max_bad_records)
if 'nullMarker' in config:
self.assertEqual(job.null_marker,
config['nullMarker'])
else:
self.assertIsNone(job.null_marker)
if 'quote' in config:
self.assertEqual(job.quote_character,
config['quote'])
Expand Down Expand Up @@ -288,6 +293,7 @@ def test_ctor(self):
self.assertIsNone(job.field_delimiter)
self.assertIsNone(job.ignore_unknown_values)
self.assertIsNone(job.max_bad_records)
self.assertIsNone(job.null_marker)
self.assertIsNone(job.quote_character)
self.assertIsNone(job.skip_leading_rows)
self.assertIsNone(job.source_format)
Expand Down Expand Up @@ -592,6 +598,7 @@ def test_begin_w_alternate_client(self):
'fieldDelimiter': '|',
'ignoreUnknownValues': True,
'maxBadRecords': 100,
'nullMarker': r'\N',
'quote': "'",
'skipLeadingRows': 1,
'sourceFormat': 'CSV',
Expand Down Expand Up @@ -619,6 +626,7 @@ def test_begin_w_alternate_client(self):
job.field_delimiter = '|'
job.ignore_unknown_values = True
job.max_bad_records = 100
job.null_marker = r'\N'
job.quote_character = "'"
job.skip_leading_rows = 1
job.source_format = 'CSV'
Expand Down

0 comments on commit 1fcd53d

Please sign in to comment.