This is an automated email from the ASF dual-hosted git repository.
forwardxu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 71909f0f82 fix bug in cli show fsview all (#6314)
71909f0f82 is described below
commit 71909f0f8299d86e25f7bfc82ae571e7c72e4fb9
Author: Manu <[email protected]>
AuthorDate: Thu Aug 11 22:49:30 2022 +0800
fix bug in cli show fsview all (#6314)
---
.../java/org/apache/hudi/cli/commands/FileSystemViewCommand.java | 8 +++++++-
.../org/apache/hudi/cli/commands/TestFileSystemViewCommand.java | 4 ++--
2 files changed, 9 insertions(+), 3 deletions(-)
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 792128c0b8..27598b5f51 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 class FileSystemViewCommand implements CommandMarker {
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 b6813a2146..639ef0fe8d 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 @@ public class TestFileSystemViewCommand extends
CLIFunctionalTestHarness {
@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 class TestFileSystemViewCommand extends
CLIFunctionalTestHarness {
@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<>();