Skip to content

Commit c0bc4c6

Browse files
committed
feat(BigQuery): Adding ConfigurationModifier action to CreateModelExtractJobOptions
1 parent 5ea3be9 commit c0bc4c6

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.Tests/CreateModelExtractJobOptionsTest.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -24,11 +24,13 @@ public void ModifyRequest()
2424
{
2525
var options = new CreateModelExtractJobOptions
2626
{
27-
DestinationFormat = ModelFormat.XGBoostBooster
27+
DestinationFormat = ModelFormat.XGBoostBooster,
28+
ConfigurationModifier = job => job.UseAvroLogicalTypes = true
2829
};
2930
JobConfigurationExtract extract = new JobConfigurationExtract();
3031
options.ModifyRequest(extract);
3132
Assert.Equal("ML_XGBOOST_BOOSTER", extract.DestinationFormat);
33+
Assert.True(extract.UseAvroLogicalTypes);
3234
}
3335
}
34-
}
36+
}

apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/CreateModelExtractJobOptions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
using Google.Apis.Bigquery.v2.Data;
16+
using System;
1617

1718
namespace Google.Cloud.BigQuery.V2
1819
{
@@ -27,12 +28,27 @@ public sealed class CreateModelExtractJobOptions : JobCreationOptions
2728
/// </summary>
2829
public ModelFormat? DestinationFormat { get; set; }
2930

31+
/// <summary>
32+
/// Optional action to perform after preparing the request. If this property is non-null,
33+
/// the <see cref="JobConfigurationExtract"/> used for a request will be passed to the delegate
34+
/// before the request is executed. This allows for fine-grained modifications which aren't
35+
/// otherwise directly supported by the properties in this options type.
36+
/// </summary>
37+
/// <remarks>
38+
/// Prefer the properties on this type over this modifier to prepare the request.
39+
/// Only use this modifier to configure aspects for which there are no properties available.
40+
/// This modifier is applied to the request after all properties on this type have been applied.
41+
/// The delegate is only called once per operation, even if the request is automatically retried.
42+
/// </remarks>
43+
public Action<JobConfigurationExtract> ConfigurationModifier { get; set; }
44+
3045
internal void ModifyRequest(JobConfigurationExtract extract)
3146
{
3247
if (DestinationFormat != null)
3348
{
3449
extract.DestinationFormat = EnumMap.ToApiValue(DestinationFormat.Value);
3550
}
51+
ConfigurationModifier?.Invoke(extract);
3652
}
3753
}
3854
}

0 commit comments

Comments
 (0)