Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: remove redundant array deepcopy #26

Merged
merged 7 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion google/cloud/bigquery/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ def _record_field_to_json(fields, row_value):


def _single_field_to_json(field, row_value):
"""Convert a single (non-repeating) field into JSON-serializable values.
"""Convert a single field into JSON-serializable values.

Ignores mode so that this can function for ARRAY / REPEATING fiels
tswast marked this conversation as resolved.
Show resolved Hide resolved
without requiring a deepcopy of the field. See:
https://github.com/googleapis/python-bigquery/issues/6

Args:
field (google.cloud.bigquery.schema.SchemaField):
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,12 @@ def test_w_scalar(self):
converted = self._call_fut(field, original)
self.assertEqual(converted, str(original))

def test_w_scalar_ignores_mode(self):
field = _make_field("STRING", mode="REPEATED")
original = "hello world"
converted = self._call_fut(field, original)
self.assertEqual(converted, original)


class Test_repeated_field_to_json(unittest.TestCase):
def _call_fut(self, field, value):
Expand Down