1fanwang opened a new pull request, #3804:
URL: https://github.com/apache/parquet-java/pull/3804

   ### Rationale for this change
   
   When a local Parquet file is invalid, the error shows a Java object ID 
instead of the filename. Callers cannot identify the failing input.
   
   Related to https://github.com/apache/parquet-java/issues/3354. This fixes 
the built-in local input implementation, not the third-party input in that 
report.
   
   ### What changes are included in this PR?
   
   Return the stored path from the local input's string representation, as 
Hadoop-backed inputs already do.
   
   ### Are these changes tested?
   
   #### Testing Done
   
   On Java 17, the same program opens a real ten-byte file through the Parquet 
reader.
   
   Before, at 2df8d02678dab4bb8b926a0d3221cc652984c7ab:
   
   ```text
   org.apache.parquet.io.LocalInputFile@6bffbc6d is not a Parquet file (length 
is too low: 10)
   ```
   
   After:
   
   ```text
   invalid.parquet is not a Parquet file (length is too low: 10)
   ```
   
   Run from either checkout:
   
   ```bash
   mvn -q -pl parquet-hadoop -am -DskipTests package dependency:build-classpath 
-Dmdep.outputFile=target/runtime-classpath
   java -cp "parquet-common/target/classes:parquet-hadoop/target/classes:$(cat 
parquet-hadoop/target/runtime-classpath)" target/InvalidLocalFileProbe.java 
invalid.parquet
   ```
   
   <details>
   <summary>Reproducer source</summary>
   
   Save this as target/InvalidLocalFileProbe.java after the build:
   
   ```java
   import java.nio.file.Files;
   import java.nio.file.Path;
   import org.apache.parquet.hadoop.ParquetFileReader;
   import org.apache.parquet.io.LocalInputFile;
   
   class InvalidLocalFileProbe {
     public static void main(String[] args) throws Exception {
       Path path = Files.write(Path.of(args[0]), new byte[10]);
       try (ParquetFileReader ignored = ParquetFileReader.open(new 
LocalInputFile(path))) {
         throw new AssertionError("Invalid file was accepted");
       } catch (RuntimeException exception) {
         System.out.println(exception.getMessage());
       }
     }
   }
   ```
   
   </details>
   
   ### Are there any user-facing changes?
   
   Local-file errors and reader file identifiers now show the supplied path. 
File contents and read behavior are unchanged.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to