Skip to content

Instantly share code, notes, and snippets.

View ajantha-bhat's full-sized avatar
🏠
Working from home

Ajantha Bhat ajantha-bhat

🏠
Working from home
View GitHub Profile
// Iceberg schema of PartitionData (for this example, struct<Date>)
struct<1: partition: required struct<1000: c2: optional date>
// data is in Integer 19359. Exacted from manifest
// Parquet writer code
try (DataWriter<Record> dataWriter =
Parquet.writeData(outputFile)
.schema(schema)
.createWriterFunc(GenericParquetWriter::buildWriter)
@ajantha-bhat
ajantha-bhat / PartitionStatsUtil.java
Last active July 12, 2023 14:02
Sample code to write partition stats as single parquet file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@ajantha-bhat
ajantha-bhat / TestCase.java
Created May 9, 2023 14:40
Partition stats schema test
@Test
public void testPartitionStats() throws Exception {
// Create 1 million unique timestamps
List<Timestamp> timestamps = new ArrayList<>();
for (int i = 0; i < 1000000; i++) {
timestamps.add(new Timestamp(System.currentTimeMillis() + i * 1000));
}
// Create DataFrame with unique timestamps and random values for other columns
List<Row> rows = new ArrayList<>();