Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@
intersphinx_mapping = {
"python": ("https://python.readthedocs.org/en/latest/", None),
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
"google.api_core": (
"https://googleapis.dev/python/google-api-core/latest/",
None,
),
"grpc": ("https://grpc.github.io/grpc/python/", None),
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
Expand Down
5 changes: 4 additions & 1 deletion google/cloud/bigquery/_pandas_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,10 @@ def dataframe_to_parquet(
bq_schema = schema._to_schema_fields(bq_schema)
arrow_table = dataframe_to_arrow(dataframe, bq_schema)
pyarrow.parquet.write_table(
arrow_table, filepath, compression=parquet_compression, **kwargs,
arrow_table,
filepath,
compression=parquet_compression,
**kwargs,
)


Expand Down
4 changes: 3 additions & 1 deletion google/cloud/bigquery/_tqdm_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def wait_for_query(
progress_bar.total = len(query_job.query_plan)
progress_bar.set_description(
"Query executing stage {} and status {} : {:0.2f}s".format(
current_stage.name, current_stage.status, time.time() - start_time,
current_stage.name,
current_stage.status,
time.time() - start_time,
),
)
try:
Expand Down
11 changes: 5 additions & 6 deletions google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1894,9 +1894,7 @@ def _get_query_results(

def job_from_resource(
self, resource: dict
) -> Union[
job.CopyJob, job.ExtractJob, job.LoadJob, job.QueryJob, job.UnknownJob,
]:
) -> Union[job.CopyJob, job.ExtractJob, job.LoadJob, job.QueryJob, job.UnknownJob]:
"""Detect correct job type from resource and instantiate.

Args:
Expand Down Expand Up @@ -1978,8 +1976,8 @@ def create_job(
timeout=timeout,
)
elif "extract" in job_config:
extract_job_config = google.cloud.bigquery.job.ExtractJobConfig.from_api_repr(
job_config
extract_job_config = (
google.cloud.bigquery.job.ExtractJobConfig.from_api_repr(job_config)
)
source = _get_sub_prop(job_config, ["extract", "sourceTable"])
if source:
Expand Down Expand Up @@ -2152,7 +2150,8 @@ def cancel_job(
job_instance = self.job_from_resource(resource["job"]) # never an UnknownJob

return typing.cast(
Union[job.LoadJob, job.CopyJob, job.ExtractJob, job.QueryJob], job_instance,
Union[job.LoadJob, job.CopyJob, job.ExtractJob, job.QueryJob],
job_instance,
)

def list_jobs(
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def __repr__(self):
)

def _key(self):
""" A tuple key that uniquely describes this field.
"""A tuple key that uniquely describes this field.
Used to compute this instance's hashcode and evaluate equality.
Returns:
Tuple: The contents of this :class:`~google.cloud.bigquery.dataset.AccessEntry`.
Expand Down
6 changes: 2 additions & 4 deletions google/cloud/bigquery/dbapi/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,7 @@ def raise_on_closed(
"""Make public instance methods raise an error if the instance is closed."""

def _raise_on_closed(method):
"""Make a non-static method raise an error if its containing instance is closed.
"""
"""Make a non-static method raise an error if its containing instance is closed."""

def with_closed_check(self, *args, **kwargs):
if getattr(self, closed_attr_name):
Expand All @@ -498,8 +497,7 @@ def with_closed_check(self, *args, **kwargs):
return with_closed_check

def decorate_public_methods(klass):
"""Apply ``_raise_on_closed()`` decorator to public instance methods.
"""
"""Apply ``_raise_on_closed()`` decorator to public instance methods."""
for name in dir(klass):
if name.startswith("_") and name != "__iter__":
continue
Expand Down
9 changes: 6 additions & 3 deletions google/cloud/bigquery/external_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ def from_api_repr(cls, resource: dict) -> "BigtableColumnFamily":


class BigtableOptions(object):
"""Options that describe how to treat Bigtable tables as BigQuery tables.
"""
"""Options that describe how to treat Bigtable tables as BigQuery tables."""

_SOURCE_FORMAT = "BIGTABLE"
_RESOURCE_NAME = "bigtableOptions"
Expand Down Expand Up @@ -557,7 +556,11 @@ def from_api_repr(cls, resource: dict) -> "GoogleSheetsOptions":
)

OptionsType = Union[
AvroOptions, BigtableOptions, CSVOptions, GoogleSheetsOptions, ParquetOptions,
AvroOptions,
BigtableOptions,
CSVOptions,
GoogleSheetsOptions,
ParquetOptions,
]


Expand Down
3 changes: 2 additions & 1 deletion google/cloud/bigquery/job/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ def connection_properties(self) -> List[ConnectionProperty]:
@connection_properties.setter
def connection_properties(self, value: Iterable[ConnectionProperty]):
self._set_sub_prop(
"connectionProperties", [prop.to_api_repr() for prop in value],
"connectionProperties",
[prop.to_api_repr() for prop in value],
)

@property
Expand Down
7 changes: 5 additions & 2 deletions google/cloud/bigquery/magics/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,9 @@ def _cell_magic(line, query):
bqstorage_client_options.api_endpoint = args.bqstorage_api_endpoint

bqstorage_client = _make_bqstorage_client(
client, use_bqstorage_api, bqstorage_client_options,
client,
use_bqstorage_api,
bqstorage_client_options,
)

close_transports = functools.partial(_close_transports, client, bqstorage_client)
Expand Down Expand Up @@ -637,7 +639,8 @@ def _cell_magic(line, query):
return

result = rows.to_dataframe(
bqstorage_client=bqstorage_client, create_bqstorage_client=False,
bqstorage_client=bqstorage_client,
create_bqstorage_client=False,
)
if args.destination_var:
IPython.get_ipython().push({args.destination_var: result})
Expand Down
44 changes: 22 additions & 22 deletions google/cloud/bigquery/opentelemetry_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@
@contextmanager
def create_span(name, attributes=None, client=None, job_ref=None):
"""Creates a ContextManager for a Span to be exported to the configured exporter.
If no configuration exists yields None.

Args:
name (str): Name that will be set for the span being created
attributes (Optional[dict]):
Additional attributes that pertain to
the specific API call (i.e. not a default attribute)
client (Optional[google.cloud.bigquery.client.Client]):
Pass in a Client object to extract any attributes that may be
relevant to it and add them to the created spans.
job_ref (Optional[google.cloud.bigquery.job._AsyncJob])
Pass in a _AsyncJob object to extract any attributes that may be
relevant to it and add them to the created spans.

Yields:
opentelemetry.trace.Span: Yields the newly created Span.

Raises:
google.api_core.exceptions.GoogleAPICallError:
Raised if a span could not be yielded or issue with call to
OpenTelemetry.
"""
If no configuration exists yields None.

Args:
name (str): Name that will be set for the span being created
attributes (Optional[dict]):
Additional attributes that pertain to
the specific API call (i.e. not a default attribute)
client (Optional[google.cloud.bigquery.client.Client]):
Pass in a Client object to extract any attributes that may be
relevant to it and add them to the created spans.
job_ref (Optional[google.cloud.bigquery.job._AsyncJob])
Pass in a _AsyncJob object to extract any attributes that may be
relevant to it and add them to the created spans.

Yields:
opentelemetry.trace.Span: Yields the newly created Span.

Raises:
google.api_core.exceptions.GoogleAPICallError:
Raised if a span could not be yielded or issue with call to
OpenTelemetry.
"""
global _warned_telemetry
final_attributes = _get_final_span_attributes(attributes, client, job_ref)
if not HAS_OPENTELEMETRY:
Expand Down
3 changes: 1 addition & 2 deletions google/cloud/bigquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ def __repr__(self):


class _AbstractQueryParameter(object):
"""Base class for named / positional query parameters.
"""
"""Base class for named / positional query parameters."""

@classmethod
def from_api_repr(cls, resource: dict) -> "_AbstractQueryParameter":
Expand Down
3 changes: 1 addition & 2 deletions google/cloud/bigquery/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ def __init__(self, names: Iterable[str] = ()):

@property
def names(self):
"""Tuple[str]: Policy tags associated with this definition.
"""
"""Tuple[str]: Policy tags associated with this definition."""
return self._properties.get("names", ())

def _key(self):
Expand Down
11 changes: 8 additions & 3 deletions google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ def __init__(self, dataset_ref: "DatasetReference", table_id: str):
dataset_ref.dataset_id,
)
_helpers._set_sub_prop(
self._properties, self._PROPERTY_TO_API_FIELD["table_id"], table_id,
self._properties,
self._PROPERTY_TO_API_FIELD["table_id"],
table_id,
)

@classmethod
Expand Down Expand Up @@ -886,7 +888,9 @@ def mview_refresh_interval(self, value):

api_field = self._PROPERTY_TO_API_FIELD["mview_refresh_interval"]
_helpers._set_sub_prop(
self._properties, [api_field, "refreshIntervalMs"], refresh_interval_ms,
self._properties,
[api_field, "refreshIntervalMs"],
refresh_interval_ms,
)

@property
Expand Down Expand Up @@ -1598,7 +1602,8 @@ def total_rows(self):
return self._total_rows

def _maybe_warn_max_results(
self, bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"],
self,
bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"],
):
"""Issue a warning if BQ Storage client is not ``None`` with ``max_results`` set.

Expand Down
9 changes: 7 additions & 2 deletions google/cloud/bigquery_v2/types/encryption_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@


__protobuf__ = proto.module(
package="google.cloud.bigquery.v2", manifest={"EncryptionConfiguration",},
package="google.cloud.bigquery.v2",
manifest={
"EncryptionConfiguration",
},
)


Expand All @@ -36,7 +39,9 @@ class EncryptionConfiguration(proto.Message):
"""

kms_key_name = proto.Field(
proto.MESSAGE, number=1, message=wrappers_pb2.StringValue,
proto.MESSAGE,
number=1,
message=wrappers_pb2.StringValue,
)


Expand Down
Loading