import org.apache.iceberg.Metrics;
import org.apache.iceberg.types.Types;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.HashMap;
// Create data file with metrics
Map<Integer, Long> valueCounts = new HashMap<>();
Map<Integer, Long> nullValueCounts = new HashMap<>();
Map<Integer, ByteBuffer> lowerBounds = new HashMap<>();
Map<Integer, ByteBuffer> upperBounds = new HashMap<>();
valueCounts.put(1, 50000L); // id column
nullValueCounts.put(1, 0L);
lowerBounds.put(1, longToBuffer(1L));
upperBounds.put(1, longToBuffer(50000L));
Metrics metrics = new Metrics(
50000L, // row count
null, // column sizes
valueCounts, // value counts
nullValueCounts, // null value counts
null, // nan value counts
lowerBounds, // lower bounds
upperBounds // upper bounds
);
DataFile file = DataFiles.builder(spec)
.withPath("/data/file.parquet")
.withFileSizeInBytes(10485760)
.withMetrics(metrics)
.build();
table.newAppend()
.appendFile(file)
.commit();