6262import java .time .format .DateTimeFormatter ;
6363import java .time .format .DateTimeParseException ;
6464import java .util .Arrays ;
65+ import java .util .Collections ;
6566import java .util .HashMap ;
67+ import java .util .List ;
6668import java .util .Locale ;
6769import java .util .Map ;
6870import java .util .Optional ;
@@ -207,8 +209,8 @@ public static WriteMethod from(@Nullable String writeMethod) {
207209 com .google .common .base .Optional <JobInfo .CreateDisposition > createDisposition = empty ();
208210 boolean optimizedEmptyProjection = true ;
209211 boolean useAvroLogicalTypes = false ;
210- ImmutableList <String > decimalTargetTypes = ImmutableList . of ();
211- ImmutableList <JobInfo .SchemaUpdateOption > loadSchemaUpdateOptions = ImmutableList . of ();
212+ List <String > decimalTargetTypes = Collections . emptyList ();
213+ List <JobInfo .SchemaUpdateOption > loadSchemaUpdateOptions = Collections . emptyList ();
212214 int materializationExpirationTimeInMinutes ;
213215 int maxReadRowsRetries = 3 ;
214216 boolean pushAllFilters = true ;
@@ -233,8 +235,8 @@ public static WriteMethod from(@Nullable String writeMethod) {
233235 private int cacheExpirationTimeInMinutes = DEFAULT_CACHE_EXPIRATION_IN_MINUTES ;
234236 // used to create BigQuery ReadSessions
235237 private com .google .common .base .Optional <String > traceId ;
236- private ImmutableMap <String , String > bigQueryJobLabels = ImmutableMap . of ();
237- private ImmutableMap <String , String > bigQueryTableLabels = ImmutableMap . of ();
238+ private Map <String , String > bigQueryJobLabels = Collections . emptyMap ();
239+ private Map <String , String > bigQueryTableLabels = Collections . emptyMap ();
238240 private com .google .common .base .Optional <Long > createReadSessionTimeoutInSeconds ;
239241 private QueryJobConfiguration .Priority queryJobPriority = DEFAULT_JOB_PRIORITY ;
240242
@@ -464,11 +466,11 @@ public static SparkBigQueryConfig from(
464466 if (allowFieldRelaxation ) {
465467 loadSchemaUpdateOptions .add (JobInfo .SchemaUpdateOption .ALLOW_FIELD_RELAXATION );
466468 }
467- config .loadSchemaUpdateOptions = loadSchemaUpdateOptions .build ();
469+ config .loadSchemaUpdateOptions = Collections . unmodifiableList ( loadSchemaUpdateOptions .build () );
468470 com .google .common .base .Optional <String []> decimalTargetTypes =
469471 getOption (options , "decimalTargetTypes" ).transform (s -> s .split ("," ));
470472 if (decimalTargetTypes .isPresent ()) {
471- config .decimalTargetTypes = ImmutableList . copyOf (decimalTargetTypes .get ());
473+ config .decimalTargetTypes = Arrays . asList (decimalTargetTypes .get ());
472474 }
473475 config .bigQueryStorageGrpcEndpoint =
474476 getAnyOption (globalOptions , options , "bigQueryStorageGrpcEndpoint" );
@@ -630,7 +632,7 @@ private static com.google.common.base.Optional<String> stripPrefix(
630632 // takes only the options with the BIGQUERY_JOB_LABEL_PREFIX prefix, and strip them of this
631633 // prefix.
632634 // The `options` map overrides the `globalOptions` map.
633- static ImmutableMap <String , String > parseBigQueryLabels (
635+ static Map <String , String > parseBigQueryLabels (
634636 ImmutableMap <String , String > globalOptions ,
635637 ImmutableMap <String , String > options ,
636638 String labelPrefix ) {
@@ -650,7 +652,7 @@ static ImmutableMap<String, String> parseBigQueryLabels(
650652 }
651653 }
652654
653- return result .build ();
655+ return Collections . unmodifiableMap ( result .build () );
654656 }
655657
656658 private static ImmutableMap <String , String > toLowerCaseKeysMap (Map <String , String > map ) {
@@ -859,7 +861,7 @@ public boolean isUseAvroLogicalTypes() {
859861 }
860862
861863 public ImmutableList <String > getDecimalTargetTypes () {
862- return decimalTargetTypes ;
864+ return ImmutableList . copyOf ( decimalTargetTypes ) ;
863865 }
864866
865867 public boolean isViewsEnabled () {
@@ -925,7 +927,7 @@ public boolean isOptimizedEmptyProjection() {
925927 }
926928
927929 public ImmutableList <JobInfo .SchemaUpdateOption > getLoadSchemaUpdateOptions () {
928- return loadSchemaUpdateOptions ;
930+ return ImmutableList . copyOf ( loadSchemaUpdateOptions ) ;
929931 }
930932
931933 public int getMaterializationExpirationTimeInMinutes () {
@@ -1049,7 +1051,7 @@ public Optional<String> getTraceId() {
10491051
10501052 @ Override
10511053 public ImmutableMap <String , String > getBigQueryJobLabels () {
1052- return bigQueryJobLabels ;
1054+ return ImmutableMap . copyOf ( bigQueryJobLabels ) ;
10531055 }
10541056
10551057 public boolean getAllowMapTypeConversion () {
@@ -1061,7 +1063,7 @@ public long getBigQueryJobTimeoutInMinutes() {
10611063 }
10621064
10631065 public ImmutableMap <String , String > getBigQueryTableLabels () {
1064- return bigQueryTableLabels ;
1066+ return ImmutableMap . copyOf ( bigQueryTableLabels ) ;
10651067 }
10661068
10671069 public Optional <String > getGpn () {
0 commit comments