Skip to content

Commit

Permalink
Remove warning from catch in table exists validation (#28288)
Browse files Browse the repository at this point in the history
* Remove warning from catch in table exists validation

* Remove warning from catch in read table exists validation

* Throw RuntimeException instead
  • Loading branch information
damondouglas authored Sep 29, 2023
1 parent 5e38dec commit 8031162
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import static org.apache.beam.sdk.io.gcp.bigtable.BigtableServiceFactory.BigtableServiceEntry;
import static org.apache.beam.sdk.options.ValueProvider.StaticValueProvider;
import static org.apache.beam.sdk.util.Preconditions.checkArgumentNotNull;
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument;
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkState;

import com.google.auto.value.AutoValue;
Expand Down Expand Up @@ -689,14 +689,13 @@ public final String toString() {
private void validateTableExists(
BigtableConfig config, BigtableReadOptions readOptions, PipelineOptions options) {
if (config.getValidate() && config.isDataAccessible() && readOptions.isDataAccessible()) {
String tableId = checkNotNull(readOptions.getTableId().get());
ValueProvider<String> tableIdProvider = checkArgumentNotNull(readOptions.getTableId());
String tableId = checkArgumentNotNull(tableIdProvider.get());
try {
checkArgument(
getServiceFactory().checkTableExists(config, options, tableId),
"Table %s does not exist",
tableId);
boolean exists = getServiceFactory().checkTableExists(config, options, tableId);
checkArgument(exists, "Table %s does not exist", tableId);
} catch (IOException e) {
LOG.warn("Error checking whether table {} exists; proceeding.", tableId, e);
throw new RuntimeException(e);
}
}
}
Expand Down Expand Up @@ -1122,14 +1121,13 @@ public String toString() {
private void validateTableExists(
BigtableConfig config, BigtableWriteOptions writeOptions, PipelineOptions options) {
if (config.getValidate() && config.isDataAccessible() && writeOptions.isDataAccessible()) {
String tableId = checkNotNull(writeOptions.getTableId().get());
ValueProvider<String> tableIdProvider = checkArgumentNotNull(writeOptions.getTableId());
String tableId = checkArgumentNotNull(tableIdProvider.get());
try {
checkArgument(
factory.checkTableExists(config, options, writeOptions.getTableId().get()),
"Table %s does not exist",
tableId);
boolean exists = factory.checkTableExists(config, options, tableId);
checkArgument(exists, "Table %s does not exist", tableId);
} catch (IOException e) {
LOG.warn("Error checking whether table {} exists; proceeding.", tableId, e);
throw new RuntimeException(e);
}
}
}
Expand Down

0 comments on commit 8031162

Please sign in to comment.