title: Read local Parquet file without Hadoop Path API
body: <p>I'm trying to read a local Parquet file, however the only APIs I can find are tightly coupled with Hadoop, and require a Hadoop <code>Path</code> as input (even for pointing to a local file).</p>
  
  <pre><code>ParquetReader&lt;GenericRecord&gt; reader = AvroParquetReader.&lt;GenericRecord&gt;builder(file).build();
  GenericRecord nextRecord = reader.read();
  </code></pre>
  
  <p>is the most popular answer in <a href="https://stackoverflow.com/questions/28615511/how-to-read-a-parquet-file-in-a-standalone-java-code">how to read a parquet file, in a standalone java code?</a>, but requires a Hadoop <code>Path</code> and has now been deprecated for a mysterious <a href="https://github.com/apache/parquet-mr/blob/master/parquet-common/src/main/java/org/apache/parquet/io/InputFile.java" rel="noreferrer"><code>InputFile</code></a> instead. The only implementation of <code>InputFile</code> I can find is <code>HadoopInputFile</code>, so again no help.</p>
  
  <p>In Avro this is a simple:</p>
  
  <pre><code>DatumReader&lt;GenericRecord&gt; datumReader = new GenericDatumReader&lt;&gt;();
  this.dataFileReader = new DataFileReader&lt;&gt;(file, datumReader);
  </code></pre>
  
  <p>(where file is <code>java.io.File</code>). What's the Parquet equivalent?</p>
  
  <p>I am asking for no Hadoop <code>Path</code> dependency in the answers, because Hadoop drags in bloat and jar hell, and it seems silly to require it for reading local files.</p>
  
  <p>To further explain the backstory, I maintain a small <a href="https://github.com/benwatson528/intellij-avro-plugin" rel="noreferrer">IntelliJ plugin</a> that allows users to drag-and-drop Avro files into a pane for viewing in a table. This plugin is currently 5MB. If I include Parquet and Hadoop dependencies, it bloats to over 50MB, and <a href="https://stackoverflow.com/questions/60019230/unable-to-read-local-file-with-hdfs-api-in-intellij-plugin">doesn't even work</a>.</p>
  
  <hr>
  
  <p><strong>POST-ANSWER ADDENDUM</strong></p>
  
  <p>Now that I have it working (thanks to the accepted answer), here is my working solution that avoids all the annoying errors that can be dragged in by depending heavily on the Hadoop <code>Path</code> API:</p>
  
  <ul>
  <li><a href="https://github.com/benwatson528/intellij-avro-parquet-plugin/blob/master/src/main/java/uk/co/hadoopathome/intellij/viewer/fileformat/ParquetFileReader.java" rel="noreferrer">ParquetFileReader.java</a></li>
  <li><a href="https://github.com/benwatson528/intellij-avro-parquet-plugin/blob/master/src/main/java/uk/co/hadoopathome/intellij/viewer/fileformat/LocalInputFile.java" rel="noreferrer">LocalInputFile.java</a></li>
  </ul>