in iceberg-catalog-migrator/cli/src/main/java/org/apache/polaris/iceberg/catalog/migrator/cli/IdentifierOptions.java [71:103]
protected Set<TableIdentifier> processIdentifiersInput() {
if (!identifiers.isEmpty()) {
return identifiers.stream()
.map(TableIdentifier::parse)
.collect(Collectors.toCollection(LinkedHashSet::new));
} else if (identifiersFromFile != null) {
Preconditions.checkArgument(
Files.exists(Paths.get(identifiersFromFile)),
"File specified in `--identifiers-from-file` option does not exist");
try {
consoleLog.info("Collecting identifiers from the file {} ...", identifiersFromFile);
return Files.readAllLines(Paths.get(identifiersFromFile)).stream()
.map(String::trim)
.filter(string -> !string.isEmpty())
.map(TableIdentifier::parse)
.collect(Collectors.toCollection(LinkedHashSet::new));
} catch (IOException e) {
throw new UncheckedIOException(
String.format("Failed to read the file: %s", identifiersFromFile), e);
}
} else if (identifiersRegEx != null) {
Preconditions.checkArgument(
!identifiersRegEx.trim().isEmpty(), "--identifiers-regex should not be empty");
// check whether pattern is compilable
try {
Pattern.compile(identifiersRegEx);
} catch (PatternSyntaxException ex) {
throw new IllegalArgumentException("--identifiers-regex pattern is not compilable", ex);
}
}
return Sets.newHashSet();
}