@Override
  public void write(T record) {
    recordConsumer.startMessage();
    try {
      messageWriter.writeTopLevelMessage(record);
    } catch (RuntimeException e) {
      Message m = (record instanceof Message.Builder) ? ((Message.Builder) record).build() : (Message) record;
      LOG.error("Cannot write message {}: {}", e.getMessage(), m);
      throw e;
    }
    recordConsumer.endMessage();
  }
@Test
  public void testProto3DateTimeMessageRoundTrip() throws Exception {
    Timestamp timestamp = Timestamps.parse("2021-05-02T15:04:03.748Z");
    LocalDate date = LocalDate.of(2021, 5, 2);
    LocalTime time = LocalTime.of(15, 4, 3, 748_000_000);
    com.google.type.Date protoDate = com.google.type.Date.newBuilder()
        .setYear(date.getYear())
        .setMonth(date.getMonthValue())
        .setDay(date.getDayOfMonth())
        .build();
    com.google.type.TimeOfDay protoTime = com.google.type.TimeOfDay.newBuilder()
        .setHours(time.getHour())
        .setMinutes(time.getMinute())
        .setSeconds(time.getSecond())
        .setNanos(time.getNano())
        .build();

    TestProto3.DateTimeMessage msg = TestProto3.DateTimeMessage.newBuilder()
        .setTimestamp(timestamp)
        .setDate(protoDate)
        .setTime(protoTime)
        .build();

    // Write them out and read them back
    Path tmpFilePath = TestUtils.someTemporaryFilePath();
    ParquetWriter<MessageOrBuilder> writer = ProtoParquetWriter.<MessageOrBuilder>builder(tmpFilePath)
        .withMessage(TestProto3.DateTimeMessage.class)
        .config(ProtoWriteSupport.PB_UNWRAP_PROTO_WRAPPERS, "true")
        .build();
    writer.write(msg);
    writer.close();
    List<TestProto3.DateTimeMessage> gotBack =
        TestUtils.readMessages(tmpFilePath, TestProto3.DateTimeMessage.class);

    TestProto3.DateTimeMessage gotBackFirst = gotBack.get(0);
    assertEquals(timestamp, gotBackFirst.getTimestamp());
    assertEquals(protoDate, gotBackFirst.getDate());
    assertEquals(protoTime, gotBackFirst.getTime());
  }