@Override
  public boolean hasNext() {
    try {
      // To handle when hasNext() is called multiple times for idempotency and/or the first time
      if (this.next == null) {
        this.next = parquetReader.read();
      }
      return this.next != null;
    } catch (Exception e) {
      FileIOUtils.closeQuietly(parquetReader);
      throw new HoodieException("unable to read next record from parquet file ", e);
    }
  }
@Test
  public void testParquetIteratorIdempotency() throws IOException {
    ParquetReader reader = mock(ParquetReader.class);
    // only 1 record in reader
    when(reader.read()).thenReturn(1).thenReturn(null);
    ParquetReaderIterator<Integer> iterator = new ParquetReaderIterator<>(reader);
    int idempotencyCheckCounter = 0;
    // call hasNext() 3 times
    while (idempotencyCheckCounter < 3) {
      assertTrue(iterator.hasNext());
      idempotencyCheckCounter++;
    }
  }