fix bug in cli show fsview all (#6314)
diff --git a/hudi-cli/src/main/java/org/apache/hudi/cli/commands/FileSystemViewCommand.java b/hudi-cli/src/main/java/org/apache/hudi/cli/commands/FileSystemViewCommand.java
index 792128c..27598b5 100644
--- a/hudi-cli/src/main/java/org/apache/hudi/cli/commands/FileSystemViewCommand.java
+++ b/hudi-cli/src/main/java/org/apache/hudi/cli/commands/FileSystemViewCommand.java
@@ -61,7 +61,7 @@
@CliCommand(value = "show fsview all", help = "Show entire file-system view")
public String showAllFileSlices(
@CliOption(key = {"pathRegex"}, help = "regex to select files, eg: 2016/08/02",
- unspecifiedDefaultValue = "*/*/*") String globRegex,
+ unspecifiedDefaultValue = "") String globRegex,
@CliOption(key = {"baseFileOnly"}, help = "Only display base files view",
unspecifiedDefaultValue = "false") boolean baseFileOnly,
@CliOption(key = {"maxInstant"}, help = "File-Slices upto this instant are displayed",
@@ -79,6 +79,12 @@
unspecifiedDefaultValue = "false") final boolean headerOnly)
throws IOException {
+ globRegex = globRegex == null ? "" : globRegex;
+ // TODO: There is a bug in spring shell, if we pass */*/* to pathRegex, the last '/' will be lost, pathRegex will be */**
+ if (globRegex.endsWith("**")) {
+ globRegex = globRegex.replace("**", "*/*");
+ }
+
HoodieTableFileSystemView fsView = buildFileSystemView(globRegex, maxInstant, baseFileOnly, includeMaxInstant,
includeInflight, excludeCompaction);
List<Comparable[]> rows = new ArrayList<>();
diff --git a/hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java b/hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
index b6813a2..639ef0f 100644
--- a/hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
+++ b/hudi-cli/src/test/java/org/apache/hudi/cli/commands/TestFileSystemViewCommand.java
@@ -161,7 +161,7 @@
@Test
public void testShowCommits() {
// Test default show fsview all
- CommandResult cr = shell().executeCommand("show fsview all");
+ CommandResult cr = shell().executeCommand("show fsview all --pathRegex */*/*");
assertTrue(cr.isSuccess());
// Get all file groups
@@ -209,7 +209,7 @@
@Test
public void testShowCommitsWithSpecifiedValues() {
// Test command with options, baseFileOnly and maxInstant is 2
- CommandResult cr = shell().executeCommand("show fsview all --baseFileOnly true --maxInstant 2");
+ CommandResult cr = shell().executeCommand("show fsview all --pathRegex */*/* --baseFileOnly true --maxInstant 2");
assertTrue(cr.isSuccess());
List<Comparable[]> rows = new ArrayList<>();