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 792128c0b8ae3..27598b5f5197f 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 @@ public class FileSystemViewCommand implements CommandMarker { @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 @@ public String showAllFileSlices( 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 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 b6813a2146f8e..639ef0fe8dba2 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 @@ private void createPartitionedTable() throws IOException { @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 @@ public void testShowCommits() { @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 rows = new ArrayList<>();