You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/06/08 04:01:28 UTC

[GitHub] [hudi] XuQianJin-Stars commented on a diff in pull request #5791: [MINOR] follow up HUDI-4178 automatically enable schema evolution when read hoodie table.

XuQianJin-Stars commented on code in PR #5791:
URL: https://github.com/apache/hudi/pull/5791#discussion_r891896666


##########
hudi-common/src/main/java/org/apache/hudi/internal/schema/io/FileBasedInternalSchemaStorageManager.java:
##########
@@ -131,6 +131,27 @@ private List<String> getValidInstants() {
         .filterCompletedInstants().getInstants().map(f -> f.getTimestamp()).collect(Collectors.toList());
   }
 
+  /**
+   * Return whether an available historySchema file exist in schema folder or not.
+   */
+  public boolean isValidHistorySchemaExist() {
+    try {
+      List<String> validateCommits = getValidInstants();
+      FileSystem fs = FSUtils.getFs(baseSchemaPath.toString(), conf);
+      if (fs.exists(baseSchemaPath)) {
+        List<String> validaSchemaFiles = Arrays.stream(fs.listStatus(baseSchemaPath))
+            .filter(f -> f.isFile() && f.getPath().getName().endsWith(SCHEMA_COMMIT_ACTION))
+            .map(file -> file.getPath().getName()).filter(f -> validateCommits.contains(f.split("\\.")[0])).sorted().collect(Collectors.toList());

Review Comment:
   ``` .map(file -> file.getPath().getName()).filter(f -> validateCommits.contains(f.split("\\.")[0])).sorted().collect(Collectors.toList());```
    -> ```.map(file -> file.getPath().getName()).filter(f -> validateCommits.contains(f.split("\\.")[0])).findFirst()``` ?;



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org