Skip to content

Commit 0099429

Browse files
committed
feat(BigQuery): Adding ConfigurationModifier action to CreateModelExtractJobOptions
1 parent e0270b6 commit 0099429

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,27 @@ public sealed class CreateModelExtractJobOptions : JobCreationOptions
2727
/// </summary>
2828
public ModelFormat? DestinationFormat { get; set; }
2929

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

0 commit comments

Comments
 (0)