yihua commented on code in PR #11679:
URL: https://github.com/apache/hudi/pull/11679#discussion_r1695590082
##########
hudi-gcp/src/main/java/org/apache/hudi/gcp/bigquery/HoodieBigQuerySyncClient.java:
##########
@@ -328,6 +323,29 @@ public boolean
tableNotExistsOrDoesNotMatchSpecification(String tableName) {
return manifestDoesNotExist;
}
+ private boolean isBasePathUpdated(ExternalTableDefinition
externalTableDefinition) {
+ String basePath = StringUtils.stripEnd(getBasePath(), "/");
+ if (externalTableDefinition.getHivePartitioningOptions() == null) {
+ List<String> sourceUris =
Option.ofNullable(externalTableDefinition.getSourceUris()).orElse(Collections.emptyList());
+ // compare source uris with trailing slash to make sure it unwanted
prefix matches are avoided
+ String basePathWithTrailingSlash = String.format("%s/", basePath);
+ boolean isTableBasePathUpdated = sourceUris.stream()
+ .noneMatch(sourceUri ->
sourceUri.startsWith(basePathWithTrailingSlash));
+ if (isTableBasePathUpdated) {
+ LOG.warn("Base path in table source uris: {}, new base path: {}",
sourceUris, basePathWithTrailingSlash);
+ }
+ return isTableBasePathUpdated;
+ } else {
+ String basePathInTableDefinition =
externalTableDefinition.getHivePartitioningOptions().getSourceUriPrefix();
+ basePathInTableDefinition =
StringUtils.stripEnd(basePathInTableDefinition, "/");
+ boolean isTableBasePathUpdated =
!basePathInTableDefinition.equals(basePath);
+ if (isTableBasePathUpdated) {
+ LOG.warn("Base path in table definition: {}, new base path: {}",
basePathInTableDefinition, basePath);
+ }
+ return isTableBasePathUpdated;
+ }
Review Comment:
```suggestion
String basePathInTableDefinition =
externalTableDefinition.getHivePartitioningOptions().getSourceUriPrefix();
basePathInTableDefinition =
StringUtils.stripEnd(basePathInTableDefinition, "/");
boolean isTableBasePathUpdated =
!basePathInTableDefinition.equals(basePath);
if (isTableBasePathUpdated) {
LOG.warn("Base path in table definition: {}, new base path: {}",
basePathInTableDefinition, basePath);
}
return isTableBasePathUpdated;
```
##########
hudi-gcp/src/main/java/org/apache/hudi/gcp/bigquery/HoodieBigQuerySyncClient.java:
##########
@@ -328,6 +323,29 @@ public boolean
tableNotExistsOrDoesNotMatchSpecification(String tableName) {
return manifestDoesNotExist;
}
+ private boolean isBasePathUpdated(ExternalTableDefinition
externalTableDefinition) {
+ String basePath = StringUtils.stripEnd(getBasePath(), "/");
+ if (externalTableDefinition.getHivePartitioningOptions() == null) {
+ List<String> sourceUris =
Option.ofNullable(externalTableDefinition.getSourceUris()).orElse(Collections.emptyList());
Review Comment:
What's the scenario when `externalTableDefinition.getSourceUris()` contains
multiple URIs?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]