Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 9319eb1

Browse files
plamuttswastgcf-owl-bot[bot]release-please[bot]
authored
chore: merge recent changes from master (#823)
* chore: protect v3.x.x branch (#816) * chore: protect v3.x.x branch In preparation for breaking changes. * force pattern to be a string * simplify branch name * fix: no longer raise a warning in `to_dataframe` if `max_results` set (#815) That warning should only be used when BQ Storage client is explicitly passed in to RowIterator methods when max_results value is also set. * feat: Update proto definitions for bigquery/v2 to support new proto fields for BQML. (#817) PiperOrigin-RevId: 387137741 Source-Link: googleapis/googleapis@8962c92 Source-Link: https://github.com/googleapis/googleapis-gen/commit/102f1b4277cc5a049663535d9eeb77831b67de25 * chore: release 2.23.0 (#819) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Tim Swast <swast@google.com> Co-authored-by: gcf-owl-bot[bot] <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
1 parent 9cd7554 commit 9319eb1

7 files changed

Lines changed: 298 additions & 22 deletions

File tree

.github/sync-repo-settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
branchProtectionRules:
44
# Identifies the protection rule pattern. Name of the branch to be protected.
55
# Defaults to `master`
6-
- pattern: master
6+
- pattern: '{master,v3}'
77
requiredStatusCheckContexts:
88
- 'Kokoro'
99
- 'Kokoro snippets-3.8'

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55
[1]: https://pypi.org/project/google-cloud-bigquery/#history
66

77

8+
## [2.23.0](https://www.github.com/googleapis/python-bigquery/compare/v2.22.1...v2.23.0) (2021-07-27)
9+
10+
11+
### Features
12+
13+
* Update proto definitions for bigquery/v2 to support new proto fields for BQML. ([#817](https://www.github.com/googleapis/python-bigquery/issues/817)) ([fe7a902](https://www.github.com/googleapis/python-bigquery/commit/fe7a902e8b3e723ace335c9b499aea6d180a025b))
14+
15+
16+
### Bug Fixes
17+
18+
* no longer raise a warning in `to_dataframe` if `max_results` set ([#815](https://www.github.com/googleapis/python-bigquery/issues/815)) ([3c1be14](https://www.github.com/googleapis/python-bigquery/commit/3c1be149e76b1d1d8879fdcf0924ddb1c1839e94))
19+
* retry ChunkedEncodingError by default ([#802](https://www.github.com/googleapis/python-bigquery/issues/802)) ([419d36d](https://www.github.com/googleapis/python-bigquery/commit/419d36d6b1887041e5795dbc8fc808890e91ab11))
20+
21+
22+
### Documentation
23+
24+
* correct docs for `LoadJobConfig.destination_table_description` ([#810](https://www.github.com/googleapis/python-bigquery/issues/810)) ([da87fd9](https://www.github.com/googleapis/python-bigquery/commit/da87fd921cc8067b187d7985c978aac8eb58d107))
25+
826
### [2.22.1](https://www.github.com/googleapis/python-bigquery/compare/v2.22.0...v2.22.1) (2021-07-22)
927

1028

google/cloud/bigquery/table.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,11 +1544,6 @@ def _validate_bqstorage(self, bqstorage_client, create_bqstorage_client):
15441544
return False
15451545

15461546
if self.max_results is not None:
1547-
warnings.warn(
1548-
"Cannot use bqstorage_client if max_results is set, "
1549-
"reverting to fetching data with the REST endpoint.",
1550-
stacklevel=2,
1551-
)
15521547
return False
15531548

15541549
return True
@@ -1585,6 +1580,25 @@ def total_rows(self):
15851580
"""int: The total number of rows in the table."""
15861581
return self._total_rows
15871582

1583+
def _maybe_warn_max_results(
1584+
self, bqstorage_client: Optional["bigquery_storage.BigQueryReadClient"],
1585+
):
1586+
"""Issue a warning if BQ Storage client is not ``None`` with ``max_results`` set.
1587+
1588+
This helper method should be used directly in the relevant top-level public
1589+
methods, so that the warning is issued for the correct line in user code.
1590+
1591+
Args:
1592+
bqstorage_client:
1593+
The BigQuery Storage client intended to use for downloading result rows.
1594+
"""
1595+
if bqstorage_client is not None and self.max_results is not None:
1596+
warnings.warn(
1597+
"Cannot use bqstorage_client if max_results is set, "
1598+
"reverting to fetching data with the REST endpoint.",
1599+
stacklevel=3,
1600+
)
1601+
15881602
def _to_page_iterable(
15891603
self, bqstorage_download, tabledata_list_download, bqstorage_client=None
15901604
):
@@ -1674,6 +1688,8 @@ def to_arrow(
16741688
16751689
.. versionadded:: 1.17.0
16761690
"""
1691+
self._maybe_warn_max_results(bqstorage_client)
1692+
16771693
if not self._validate_bqstorage(bqstorage_client, create_bqstorage_client):
16781694
create_bqstorage_client = False
16791695
bqstorage_client = None
@@ -1763,6 +1779,8 @@ def to_dataframe_iterable(
17631779
if dtypes is None:
17641780
dtypes = {}
17651781

1782+
self._maybe_warn_max_results(bqstorage_client)
1783+
17661784
column_names = [field.name for field in self._schema]
17671785
bqstorage_download = functools.partial(
17681786
_pandas_helpers.download_dataframe_bqstorage,
@@ -1866,6 +1884,8 @@ def to_dataframe(
18661884
if dtypes is None:
18671885
dtypes = {}
18681886

1887+
self._maybe_warn_max_results(bqstorage_client)
1888+
18691889
if not self._validate_bqstorage(bqstorage_client, create_bqstorage_client):
18701890
create_bqstorage_client = False
18711891
bqstorage_client = None

google/cloud/bigquery/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "2.22.1"
15+
__version__ = "2.23.0"

google/cloud/bigquery_v2/types/model.py

Lines changed: 95 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class Model(proto.Message):
9696
Output only. Label columns that were used to train this
9797
model. The output of the model will have a `predicted_`
9898
prefix to these columns.
99+
best_trial_id (int):
100+
The best trial_id across all training runs.
99101
"""
100102

101103
class ModelType(proto.Enum):
@@ -113,6 +115,7 @@ class ModelType(proto.Enum):
113115
ARIMA = 11
114116
AUTOML_REGRESSOR = 12
115117
AUTOML_CLASSIFIER = 13
118+
ARIMA_PLUS = 19
116119

117120
class LossType(proto.Enum):
118121
r"""Loss metric to evaluate model training performance."""
@@ -151,6 +154,7 @@ class DataFrequency(proto.Enum):
151154
WEEKLY = 5
152155
DAILY = 6
153156
HOURLY = 7
157+
PER_MINUTE = 8
154158

155159
class HolidayRegion(proto.Enum):
156160
r"""Type of supported holiday regions for time series forecasting
@@ -285,7 +289,7 @@ class RegressionMetrics(proto.Message):
285289
median_absolute_error (google.protobuf.wrappers_pb2.DoubleValue):
286290
Median absolute error.
287291
r_squared (google.protobuf.wrappers_pb2.DoubleValue):
288-
R^2 score.
292+
R^2 score. This corresponds to r2_score in ML.EVALUATE.
289293
"""
290294

291295
mean_absolute_error = proto.Field(
@@ -528,7 +532,7 @@ class ClusteringMetrics(proto.Message):
528532
Mean of squared distances between each sample
529533
to its cluster centroid.
530534
clusters (Sequence[google.cloud.bigquery_v2.types.Model.ClusteringMetrics.Cluster]):
531-
[Beta] Information for all clusters.
535+
Information for all clusters.
532536
"""
533537

534538
class Cluster(proto.Message):
@@ -697,10 +701,29 @@ class ArimaSingleModelForecastingMetrics(proto.Message):
697701
Is arima model fitted with drift or not. It
698702
is always false when d is not 1.
699703
time_series_id (str):
700-
The id to indicate different time series.
704+
The time_series_id value for this time series. It will be
705+
one of the unique values from the time_series_id_column
706+
specified during ARIMA model training. Only present when
707+
time_series_id_column training option was used.
708+
time_series_ids (Sequence[str]):
709+
The tuple of time_series_ids identifying this time series.
710+
It will be one of the unique tuples of values present in the
711+
time_series_id_columns specified during ARIMA model
712+
training. Only present when time_series_id_columns training
713+
option was used and the order of values here are same as the
714+
order of time_series_id_columns.
701715
seasonal_periods (Sequence[google.cloud.bigquery_v2.types.Model.SeasonalPeriod.SeasonalPeriodType]):
702716
Seasonal periods. Repeated because multiple
703717
periods are supported for one time series.
718+
has_holiday_effect (google.protobuf.wrappers_pb2.BoolValue):
719+
If true, holiday_effect is a part of time series
720+
decomposition result.
721+
has_spikes_and_dips (google.protobuf.wrappers_pb2.BoolValue):
722+
If true, spikes_and_dips is a part of time series
723+
decomposition result.
724+
has_step_changes (google.protobuf.wrappers_pb2.BoolValue):
725+
If true, step_changes is a part of time series decomposition
726+
result.
704727
"""
705728

706729
non_seasonal_order = proto.Field(
@@ -711,9 +734,19 @@ class ArimaSingleModelForecastingMetrics(proto.Message):
711734
)
712735
has_drift = proto.Field(proto.BOOL, number=3,)
713736
time_series_id = proto.Field(proto.STRING, number=4,)
737+
time_series_ids = proto.RepeatedField(proto.STRING, number=9,)
714738
seasonal_periods = proto.RepeatedField(
715739
proto.ENUM, number=5, enum="Model.SeasonalPeriod.SeasonalPeriodType",
716740
)
741+
has_holiday_effect = proto.Field(
742+
proto.MESSAGE, number=6, message=wrappers_pb2.BoolValue,
743+
)
744+
has_spikes_and_dips = proto.Field(
745+
proto.MESSAGE, number=7, message=wrappers_pb2.BoolValue,
746+
)
747+
has_step_changes = proto.Field(
748+
proto.MESSAGE, number=8, message=wrappers_pb2.BoolValue,
749+
)
717750

718751
non_seasonal_order = proto.RepeatedField(
719752
proto.MESSAGE, number=1, message="Model.ArimaOrder",
@@ -901,7 +934,7 @@ class TrainingRun(proto.Message):
901934
"""
902935

903936
class TrainingOptions(proto.Message):
904-
r"""
937+
r"""Options used in model training.
905938
Attributes:
906939
max_iterations (int):
907940
The maximum number of iterations in training.
@@ -972,8 +1005,9 @@ class TrainingOptions(proto.Message):
9721005
num_clusters (int):
9731006
Number of clusters for clustering models.
9741007
model_uri (str):
975-
[Beta] Google Cloud Storage URI from which the model was
976-
imported. Only applicable for imported models.
1008+
Google Cloud Storage URI from which the model
1009+
was imported. Only applicable for imported
1010+
models.
9771011
optimization_strategy (google.cloud.bigquery_v2.types.Model.OptimizationStrategy):
9781012
Optimization strategy for training linear
9791013
regression models.
@@ -1030,8 +1064,11 @@ class TrainingOptions(proto.Message):
10301064
If a valid value is specified, then holiday
10311065
effects modeling is enabled.
10321066
time_series_id_column (str):
1033-
The id column that will be used to indicate
1034-
different time series to forecast in parallel.
1067+
The time series id column that was used
1068+
during ARIMA model training.
1069+
time_series_id_columns (Sequence[str]):
1070+
The time series id columns that were used
1071+
during ARIMA model training.
10351072
horizon (int):
10361073
The number of periods ahead that need to be
10371074
forecasted.
@@ -1042,6 +1079,15 @@ class TrainingOptions(proto.Message):
10421079
output feature name is A.b.
10431080
auto_arima_max_order (int):
10441081
The max value of non-seasonal p and q.
1082+
decompose_time_series (google.protobuf.wrappers_pb2.BoolValue):
1083+
If true, perform decompose time series and
1084+
save the results.
1085+
clean_spikes_and_dips (google.protobuf.wrappers_pb2.BoolValue):
1086+
If true, clean spikes and dips in the input
1087+
time series.
1088+
adjust_step_changes (google.protobuf.wrappers_pb2.BoolValue):
1089+
If true, detect step changes and make data
1090+
adjustment in the input time series.
10451091
"""
10461092

10471093
max_iterations = proto.Field(proto.INT64, number=1,)
@@ -1120,9 +1166,19 @@ class TrainingOptions(proto.Message):
11201166
proto.ENUM, number=42, enum="Model.HolidayRegion",
11211167
)
11221168
time_series_id_column = proto.Field(proto.STRING, number=43,)
1169+
time_series_id_columns = proto.RepeatedField(proto.STRING, number=51,)
11231170
horizon = proto.Field(proto.INT64, number=44,)
11241171
preserve_input_structs = proto.Field(proto.BOOL, number=45,)
11251172
auto_arima_max_order = proto.Field(proto.INT64, number=46,)
1173+
decompose_time_series = proto.Field(
1174+
proto.MESSAGE, number=50, message=wrappers_pb2.BoolValue,
1175+
)
1176+
clean_spikes_and_dips = proto.Field(
1177+
proto.MESSAGE, number=52, message=wrappers_pb2.BoolValue,
1178+
)
1179+
adjust_step_changes = proto.Field(
1180+
proto.MESSAGE, number=53, message=wrappers_pb2.BoolValue,
1181+
)
11261182

11271183
class IterationResult(proto.Message):
11281184
r"""Information about a single iteration of the training run.
@@ -1218,10 +1274,29 @@ class ArimaModelInfo(proto.Message):
12181274
Whether Arima model fitted with drift or not.
12191275
It is always false when d is not 1.
12201276
time_series_id (str):
1221-
The id to indicate different time series.
1277+
The time_series_id value for this time series. It will be
1278+
one of the unique values from the time_series_id_column
1279+
specified during ARIMA model training. Only present when
1280+
time_series_id_column training option was used.
1281+
time_series_ids (Sequence[str]):
1282+
The tuple of time_series_ids identifying this time series.
1283+
It will be one of the unique tuples of values present in the
1284+
time_series_id_columns specified during ARIMA model
1285+
training. Only present when time_series_id_columns training
1286+
option was used and the order of values here are same as the
1287+
order of time_series_id_columns.
12221288
seasonal_periods (Sequence[google.cloud.bigquery_v2.types.Model.SeasonalPeriod.SeasonalPeriodType]):
12231289
Seasonal periods. Repeated because multiple
12241290
periods are supported for one time series.
1291+
has_holiday_effect (google.protobuf.wrappers_pb2.BoolValue):
1292+
If true, holiday_effect is a part of time series
1293+
decomposition result.
1294+
has_spikes_and_dips (google.protobuf.wrappers_pb2.BoolValue):
1295+
If true, spikes_and_dips is a part of time series
1296+
decomposition result.
1297+
has_step_changes (google.protobuf.wrappers_pb2.BoolValue):
1298+
If true, step_changes is a part of time series decomposition
1299+
result.
12251300
"""
12261301

12271302
non_seasonal_order = proto.Field(
@@ -1237,11 +1312,21 @@ class ArimaModelInfo(proto.Message):
12371312
)
12381313
has_drift = proto.Field(proto.BOOL, number=4,)
12391314
time_series_id = proto.Field(proto.STRING, number=5,)
1315+
time_series_ids = proto.RepeatedField(proto.STRING, number=10,)
12401316
seasonal_periods = proto.RepeatedField(
12411317
proto.ENUM,
12421318
number=6,
12431319
enum="Model.SeasonalPeriod.SeasonalPeriodType",
12441320
)
1321+
has_holiday_effect = proto.Field(
1322+
proto.MESSAGE, number=7, message=wrappers_pb2.BoolValue,
1323+
)
1324+
has_spikes_and_dips = proto.Field(
1325+
proto.MESSAGE, number=8, message=wrappers_pb2.BoolValue,
1326+
)
1327+
has_step_changes = proto.Field(
1328+
proto.MESSAGE, number=9, message=wrappers_pb2.BoolValue,
1329+
)
12451330

12461331
arima_model_info = proto.RepeatedField(
12471332
proto.MESSAGE,
@@ -1319,6 +1404,7 @@ class ArimaModelInfo(proto.Message):
13191404
label_columns = proto.RepeatedField(
13201405
proto.MESSAGE, number=11, message=standard_sql.StandardSqlField,
13211406
)
1407+
best_trial_id = proto.Field(proto.INT64, number=19,)
13221408

13231409

13241410
class GetModelRequest(proto.Message):

google/cloud/bigquery_v2/types/table_reference.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,23 @@ class TableReference(proto.Message):
3636
maximum length is 1,024 characters. Certain operations allow
3737
suffixing of the table ID with a partition decorator, such
3838
as ``sample_table$20190123``.
39+
project_id_alternative (Sequence[str]):
40+
The alternative field that will be used when ESF is not able
41+
to translate the received data to the project_id field.
42+
dataset_id_alternative (Sequence[str]):
43+
The alternative field that will be used when ESF is not able
44+
to translate the received data to the project_id field.
45+
table_id_alternative (Sequence[str]):
46+
The alternative field that will be used when ESF is not able
47+
to translate the received data to the project_id field.
3948
"""
4049

4150
project_id = proto.Field(proto.STRING, number=1,)
4251
dataset_id = proto.Field(proto.STRING, number=2,)
4352
table_id = proto.Field(proto.STRING, number=3,)
53+
project_id_alternative = proto.RepeatedField(proto.STRING, number=4,)
54+
dataset_id_alternative = proto.RepeatedField(proto.STRING, number=5,)
55+
table_id_alternative = proto.RepeatedField(proto.STRING, number=6,)
4456

4557

4658
__all__ = tuple(sorted(__protobuf__.manifest))

0 commit comments

Comments
 (0)