- Notifications
You must be signed in to change notification settings - Fork1.6k
refactor(bigquery): rewrite docs in Google style, part 2#9481
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
IlyaFaer merged 8 commits intogoogleapis:masterfromMaxxleLLC:bigquery_update_docs_google_styleOct 26, 2019
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
8 commits Select commitHold shift + click to select a range
797974c refactor(bigquery): rewrite docs in Google style, part 2
2e0dc99 Fix coding error
7e870a2 Comments marking fixes.
17ea292 Revert "refactor(bigquery): rewrite docs in Google style, part 2"
f764983 Merge branch 'master' into bigquery_update_docs_google_style
72e2b4c Fix slash removal
2ec2bca Fix slash removal
731bffc Add continuation slashes in docs
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
83 changes: 35 additions & 48 deletionsbigquery/google/cloud/bigquery/_helpers.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -90,12 +90,15 @@ def _timestamp_query_param_from_json(value, field): | ||
| Args: | ||
| value (str): The timestamp. | ||
| field (google.cloud.bigquery.schema.SchemaField): | ||
IlyaFaer marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| The field corresponding to the value. | ||
| Returns: | ||
| Optional[datetime.datetime]: | ||
| The parsed datetime object from | ||
| ``value`` if the ``field`` is not null (otherwise it is | ||
| :data:`None`). | ||
| """ | ||
| if _not_null(value, field): | ||
| # Canonical formats for timestamps in BigQuery are flexible. See: | ||
| @@ -125,12 +128,14 @@ def _datetime_from_json(value, field): | ||
| Args: | ||
| value (str): The timestamp. | ||
| field (google.cloud.bigquery.schema.SchemaField): | ||
| The field corresponding to the value. | ||
| Returns: | ||
| Optional[datetime.datetime]: | ||
| The parsed datetime object from | ||
| ``value`` if the ``field`` is not null (otherwise it is | ||
| :data:`None`). | ||
| """ | ||
| if _not_null(value, field): | ||
| if "." in value: | ||
| @@ -217,15 +222,12 @@ def _row_tuple_from_json(row, schema): | ||
| Note: ``row['f']`` and ``schema`` are presumed to be of the same length. | ||
| Args: | ||
| row (Dict): A JSON response row to be converted. | ||
| schema (Tuple): A tuple of :class:`~google.cloud.bigquery.schema.SchemaField`. | ||
| Returns: | ||
| Tuple: A tuple of data converted to native types. | ||
| """ | ||
| row_data = [] | ||
| for field, cell in zip(schema, row["f"]): | ||
| @@ -344,16 +346,13 @@ def _scalar_field_to_json(field, row_value): | ||
| """Maps a field and value to a JSON-safe value. | ||
| Args: | ||
| field (google.cloud.bigquery.schema.SchemaField): | ||
| The SchemaField to use for type conversion and field name. | ||
| row_value (Any): | ||
| Value to be converted, based on the field's type. | ||
| Returns: | ||
| Any: A JSON-serializable object. | ||
| """ | ||
| converter = _SCALAR_VALUE_TO_JSON_ROW.get(field.field_type) | ||
| if converter is None: # STRING doesn't need converting | ||
| @@ -365,17 +364,14 @@ def _repeated_field_to_json(field, row_value): | ||
| """Convert a repeated/array field to its JSON representation. | ||
| Args: | ||
| field (google.cloud.bigquery.schema.SchemaField): | ||
| The SchemaField to use for type conversion and field name. The | ||
| field mode must equal ``REPEATED``. | ||
| row_value (Sequence[Any]): | ||
| A sequence of values to convert to JSON-serializable values. | ||
| Returns: | ||
| List[Any]: A list of JSON-serializable objects. | ||
| """ | ||
| # Remove the REPEATED, but keep the other fields. This allows us to process | ||
| # each item as if it were a top-level field. | ||
| @@ -391,17 +387,14 @@ def _record_field_to_json(fields, row_value): | ||
| """Convert a record/struct field to its JSON representation. | ||
| Args: | ||
| fields (Sequence[google.cloud.bigquery.schema.SchemaField]): | ||
| The :class:`~google.cloud.bigquery.schema.SchemaField`s of the | ||
| record's subfields to use for type conversion and field names. | ||
| row_value (Union[Tuple[Any], Mapping[str, Any]): | ||
| A tuple or dictionary to convert to JSON-serializable values. | ||
| Returns: | ||
| Mapping[str, Any]: A JSON-serializable dictionary. | ||
| """ | ||
| record = {} | ||
| isdict = isinstance(row_value, dict) | ||
| @@ -420,22 +413,16 @@ def _field_to_json(field, row_value): | ||
| """Convert a field into JSON-serializable values. | ||
| Args: | ||
| field (google.cloud.bigquery.schema.SchemaField): | ||
| The SchemaField to use for type conversion and field name. | ||
| row_value (Union[Sequence[List], Any]): | ||
| Row data to be inserted. If the SchemaField's mode is | ||
| REPEATED, assume this is a list. If not, the type | ||
| is inferred from the SchemaField's field_type. | ||
| Returns: | ||
| Any: A JSON-serializable object. | ||
| """ | ||
| if row_value is None: | ||
| return None | ||
| @@ -461,9 +448,9 @@ def _get_sub_prop(container, keys, default=None): | ||
| This method works like ``dict.get(key)``, but for nested values. | ||
| Arguments: | ||
| container (Dict): | ||
| A dictionary which may contain other dictionaries as values. | ||
| keys (Iterable): | ||
| A sequence of keys to attempt to get the value for. Each item in | ||
| the sequence represents a deeper nesting. The first key is for | ||
| the top level. If there is a dictionary there, the second key | ||
| @@ -504,9 +491,9 @@ def _set_sub_prop(container, keys, value): | ||
| """Set a nested value in a dictionary. | ||
| Arguments: | ||
| container (Dict): | ||
| A dictionary which may contain other dictionaries as values. | ||
| keys (Iterable): | ||
| A sequence of keys to attempt to set the value for. Each item in | ||
| the sequence represents a deeper nesting. The first key is for | ||
| the top level. If there is a dictionary there, the second key | ||
| @@ -547,9 +534,9 @@ def _del_sub_prop(container, keys): | ||
| """Remove a nested key fro a dictionary. | ||
| Arguments: | ||
| container (Dict): | ||
| A dictionary which may contain other dictionaries as values. | ||
| keys (Iterable): | ||
| A sequence of keys to attempt to clear the value for. Each item in | ||
| the sequence represents a deeper nesting. The first key is for | ||
| the top level. If there is a dictionary there, the second key | ||
9 changes: 6 additions & 3 deletionsbigquery/google/cloud/bigquery/_pandas_helpers.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.