FlechazoW commented on issue #3014:
URL: https://github.com/apache/parquet-java/issues/3014#issuecomment-2408477192

   My example code runs fine, and I can’t reproduce your issue. Could you take 
a look at my sample code? The code is as follows:
   ```java
   import java.io.IOException;
   import java.nio.file.Paths;
   import org.apache.avro.Schema;
   import org.apache.avro.SchemaBuilder;
   import org.apache.avro.generic.GenericData;
   import org.apache.avro.generic.GenericRecord;
   import org.apache.parquet.avro.AvroParquetWriter;
   import org.apache.parquet.hadoop.ParquetWriter;
   import org.apache.parquet.io.LocalOutputFile;
   
   public class _02_Parquet_Example {
     public static void main(String[] args) throws IOException {
       // Define the Avro schema
       Schema schema = SchemaBuilder.record("User")
           .fields()
           .name("name").type().stringType().noDefault()
           .name("age").type().intType().noDefault()
           .endRecord();
   
       // Create a GenericRecord
       GenericRecord genericRecord = new GenericData.Record(schema);
       genericRecord.put("name", "John Doe");
       genericRecord.put("age", 30);
   
       // Parquet file paths
       String localFilePath = "./output-file1.parquet";
       String localFilePath2 = "./output-file2.parquet";
   
       LocalOutputFile localOutputFile = new 
LocalOutputFile(Paths.get(localFilePath));
       LocalOutputFile localOutputFile2 = new 
LocalOutputFile(Paths.get(localFilePath2));
   
       // Write to the first Parquet file
       ParquetWriter<GenericRecord> writer = AvroParquetWriter
           .<GenericRecord>builder(localOutputFile)
           .withSchema(schema)
           .build();
       writer.write(genericRecord);
       writer.close();
   
       // Write to the second Parquet file with the same record
       writer = AvroParquetWriter
           .<GenericRecord>builder(localOutputFile2)
           .withSchema(schema)
           .build();
       writer.write(genericRecord);
       writer.close();
   
       System.out.println("Data written to Parquet files successfully.");
     }
   }
   ```


-- 
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