Skip to content

Preserve order in BigQuery JSON #2353

Closed
@dhermes

Description

@dhermes

See #2342. Can be done using json.loads(..., object_pairs_hook=OrderedDict) h/t to @c0b

  • It's unclear if any methods "need" this behavior.
  • It's nice that we don't support Python 2.6 any more because collections.OrderedDict was introduced in 2.7
  • If this "feature" is actually worth it, we should determine which subset of payloads need this behavior

Here are all the call sites where JSON is parsed from a string to a Python dictionary:

$ git grep -n 'json.loads(' -- google/cloud/bigquery/
google/cloud/bigquery/table.py:961:        return client.job_from_resource(json.loads(response_content))
$
$ git grep -n 'api_request' -- google/cloud/bigquery/
google/cloud/bigquery/client.py:105:        resp = self.connection.api_request(method='GET', path=path,
google/cloud/bigquery/client.py:148:        resp = self.connection.api_request(method='GET', path=path,
google/cloud/bigquery/client.py:239:        resp = self.connection.api_request(method='GET', path=path,
google/cloud/bigquery/dataset.py:424:        api_response = client.connection.api_request(
google/cloud/bigquery/dataset.py:445:            client.connection.api_request(method='GET', path=self.path,
google/cloud/bigquery/dataset.py:465:        api_response = client.connection.api_request(
google/cloud/bigquery/dataset.py:504:        api_response = client.connection.api_request(
google/cloud/bigquery/dataset.py:520:        api_response = client.connection.api_request(
google/cloud/bigquery/dataset.py:536:        client.connection.api_request(method='DELETE', path=self.path)
google/cloud/bigquery/dataset.py:569:        resp = connection.api_request(method='GET', path=path,
google/cloud/bigquery/job.py:318:        api_response = client.connection.api_request(
google/cloud/bigquery/job.py:339:            client.connection.api_request(method='GET', path=self.path,
google/cloud/bigquery/job.py:359:        api_response = client.connection.api_request(
google/cloud/bigquery/job.py:376:        api_response = client.connection.api_request(
google/cloud/bigquery/query.py:335:        api_response = client.connection.api_request(
google/cloud/bigquery/query.py:392:        response = client.connection.api_request(method='GET',
google/cloud/bigquery/table.py:28:from google.cloud.streaming.http_wrapper import make_api_request
google/cloud/bigquery/table.py:490:        api_response = client.connection.api_request(
google/cloud/bigquery/table.py:511:            client.connection.api_request(method='GET', path=self.path,
google/cloud/bigquery/table.py:531:        api_response = client.connection.api_request(
google/cloud/bigquery/table.py:605:        api_response = client.connection.api_request(
google/cloud/bigquery/table.py:621:        api_response = client.connection.api_request(
google/cloud/bigquery/table.py:637:        client.connection.api_request(method='DELETE', path=self.path)
google/cloud/bigquery/table.py:681:        response = client.connection.api_request(method='GET',
google/cloud/bigquery/table.py:767:        response = client.connection.api_request(
google/cloud/bigquery/table.py:955:            http_response = make_api_request(connection.http, request,
$
$ # current hash
$ git log -1 --pretty=%H
d3e28ce8ae5bee1a637a11d11227d294cfa8302c

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions