From bc1b00f2873b669024aa5a0bcd63b00fea3d3179 Mon Sep 17 00:00:00 2001 From: Anshuman Date: Thu, 12 Dec 2024 15:25:30 +0530 Subject: [PATCH] Refactor: Dynamically generate valid write preferences from JobInfo.WriteDisposition --- .../cdap/plugin/gcp/bigquery/action/BigQueryExecute.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java b/src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java index 4be9c2208..1566fe4fb 100644 --- a/src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java +++ b/src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java @@ -58,9 +58,11 @@ import java.io.IOException; import java.time.Duration; +import java.util.Arrays; import java.util.Collections; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.Nullable; /** @@ -292,11 +294,8 @@ public static final class Config extends AbstractBigQueryActionConfig { // Sn = a * (1 - r^n) / (r - 1) public static final long DEFULT_MAX_RETRY_DURATION_SECONDS = 63L; public static final int DEFAULT_READ_TIMEOUT = 120; - public static final Set VALID_WRITE_PREFERENCES = ImmutableSet.of( - JobInfo.WriteDisposition.WRITE_EMPTY.name(), - JobInfo.WriteDisposition.WRITE_APPEND.name(), - JobInfo.WriteDisposition.WRITE_TRUNCATE.name() - ); + public static final Set VALID_WRITE_PREFERENCES = Arrays.stream(JobInfo.WriteDisposition.values()) + .map(Enum::name).collect(Collectors.toSet()); @Description("Dialect of the SQL command. The value must be 'legacy' or 'standard'. " + "If set to 'standard', the query will use BigQuery's standard SQL: " +