<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-core</artifactId>
<version>0.11.0</version>
</dependency>
import org.apache.iceberg.Table;
import org.apache.iceberg.catalog.Catalog;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.hadoop.HadoopCatalog;
Catalog catalog = new HadoopCatalog(hadoopConf);
TableIdentifier tableIdentifier = TableIdentifier.of("my_catalog", "my_database", "my_table");
Table table = catalog.createOrLoadTable(tableIdentifier);
import org.apache.iceberg.DataFile;
import org.apache.iceberg.Transaction;
import org.apache.iceberg.PartitionSpec;
import org.apache.iceberg.catalog.TableIdentifier;
Table table = catalog.loadTable(tableIdentifier);
try(Transaction transaction = table.newTransaction()) {
PartitionSpec partitionSpec = table.spec();
StructLike partitionData = GenericRecord.create(partitionSpec.partitionType());
partitionData.set("partitionColumn", "partitionValue");
DataFile dataFile = DataFiles.builder(partitionSpec)
.withPath("path/to/datafile.parquet")
.withFormat(ParquetAvroFormat.get())
.build();
transaction.appendFile(dataFile, partitionData);
transaction.commitTransaction();
}
import org.apache.iceberg.Table;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.expressions.Expression;
Table table = catalog.loadTable(tableIdentifier);
Iterable<Record> records = table.newScan()
.filter(Expressions.equal("column", "value"))
.select("column1", "column2")
.execute();
for (Record record : records) {
// ...
}