diff --git a/parquet-common/src/main/java/org/apache/parquet/io/LocalInputFile.java b/parquet-common/src/main/java/org/apache/parquet/io/LocalInputFile.java index 7174b42d5d..f4f2a996a3 100644 --- a/parquet-common/src/main/java/org/apache/parquet/io/LocalInputFile.java +++ b/parquet-common/src/main/java/org/apache/parquet/io/LocalInputFile.java @@ -99,4 +99,9 @@ public void close() throws IOException { } }; } + + @Override + public String toString() { + return path.toString(); + } } diff --git a/parquet-common/src/test/java/org/apache/parquet/io/TestLocalInputOutput.java b/parquet-common/src/test/java/org/apache/parquet/io/TestLocalInputOutput.java index 84d728f14e..42d5b7ca6f 100644 --- a/parquet-common/src/test/java/org/apache/parquet/io/TestLocalInputOutput.java +++ b/parquet-common/src/test/java/org/apache/parquet/io/TestLocalInputOutput.java @@ -47,6 +47,17 @@ public void outputFileOverwritesFile() throws IOException { } } + @Test + public void inputFileToStringReturnsPath() throws IOException { + Path path = Paths.get(createTempFile().getPath()); + InputFile read = new LocalInputFile(path); + // toString() is used by ParquetFileReader when constructing error messages + // such as " is not a Parquet file (length is too low: ...)". A + // path-bearing toString() keeps those error messages actionable for + // implementations that don't expose a more specific accessor. + assertEquals(path.toString(), read.toString()); + } + @Test public void outputFileCreateFailsAsFileAlreadyExists() throws IOException { Path path = Paths.get(createTempFile().getPath());