Java Code Examples for org.apache.iceberg.PartitionSpec#partitionType()

The following examples show how to use org.apache.iceberg.PartitionSpec#partitionType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestIcebergManifests.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
@Test
public void testManifestCount() throws Exception{
  int insertCount = 5;
  int partitionValueSize = 1024;
  int dataFilesCount = 1;
  String columnName = "data";
  String expectedValue = "abc";
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setString(0, expectedValue);
  int manifestCount = getManifestFileCount(partitionSpec, partitionValueSize, dataFilesCount, columnName, insertCount);
  Assert.assertTrue(manifestCount < insertCount);
}
 
Example 2
Source File: TestIcebergSerDe.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataFileSerDe() throws Exception{
  File dataFile = new File(folder.getRoot(), "a.parquet");
  dataFile.createNewFile();

  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity("i")
    .identity("data")
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.set(0, Integer.valueOf(10));
  icebergPartitionData.set(1, "def");

  DataFile d1 = DataFiles.builder(partitionSpec)
    .withInputFile(Files.localInput(dataFile))
    .withRecordCount(50)
    .withFormat(FileFormat.PARQUET)
    .withPartition(icebergPartitionData)
    .build();

  long d1RecordCount = d1.recordCount();
  byte[] dataFileBytes = IcebergSerDe.serializeDataFile(d1);
  DataFile d2 = IcebergSerDe.deserializeDataFile(dataFileBytes);
  long d2RecordCount = d2.recordCount();
  Assert.assertEquals(d1RecordCount, d2RecordCount);
  Assert.assertEquals((Integer)(d2.partition().get(0, Integer.class)), Integer.valueOf(10));
  Assert.assertEquals((String)(d2.partition().get(1, String.class)), "def");
}
 
Example 3
Source File: TestIcebergPartitionData.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testIntSpec() throws Exception{
  String columnName = "i";
  Integer expectedValue = 12322;
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setInteger(0, expectedValue);
  verifyPartitionValue(partitionSpec, icebergPartitionData, columnName, Integer.class, expectedValue);
}
 
Example 4
Source File: TestIcebergPartitionData.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testStringSpec() throws Exception{
  String columnName = "data";
  String expectedValue = "abc";
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setString(0, expectedValue);
  verifyPartitionValue(partitionSpec, icebergPartitionData, columnName, String.class, expectedValue);
}
 
Example 5
Source File: TestIcebergPartitionData.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testLongSpec() throws Exception{
  String columnName = "id";
  Long expectedValue = 123L;
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setLong(0, expectedValue);
  verifyPartitionValue(partitionSpec, icebergPartitionData, columnName, Long.class, expectedValue);
}
 
Example 6
Source File: TestIcebergPartitionData.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testBigDecimalpec() throws Exception{
  String columnName = "dec_9_0";
  BigDecimal expectedValue = new BigDecimal(234);
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setBigDecimal(0, expectedValue);
  verifyPartitionValue(partitionSpec, icebergPartitionData, columnName, BigDecimal.class, expectedValue);
}
 
Example 7
Source File: TestIcebergPartitionData.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testFloatSpec() throws Exception{
  String columnName = "f";
  Float expectedValue = 1.23f;
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setFloat(0, expectedValue);
  verifyPartitionValue(partitionSpec, icebergPartitionData, columnName, Float.class, expectedValue);
}
 
Example 8
Source File: TestIcebergPartitionData.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoubleSpec() throws Exception{
  String columnName = "d";
  Double expectedValue = Double.valueOf(1.23f);
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setDouble(0, expectedValue);
  verifyPartitionValue(partitionSpec, icebergPartitionData, columnName, Double.class, expectedValue);
}
 
Example 9
Source File: TestIcebergPartitionData.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testBooleanSpec() throws Exception{
  String columnName = "b";
  Boolean expectedValue = true;
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setBoolean(0, expectedValue);
  verifyPartitionValue(partitionSpec, icebergPartitionData, columnName, Boolean.class, expectedValue);
}
 
Example 10
Source File: TestIcebergPartitionData.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testBinarySpec() throws Exception{
  String columnName = "bytes";
  byte[] expectedValue = "test".getBytes();
  PartitionSpec partitionSpec = PartitionSpec
    .builderFor(schema)
    .identity(columnName)
    .build();

  IcebergPartitionData icebergPartitionData = new IcebergPartitionData(partitionSpec.partitionType());
  icebergPartitionData.setBytes(0, expectedValue);
  verifyPartitionValue(partitionSpec, icebergPartitionData, columnName, ByteBuffer.class, expectedValue);
}
 
Example 11
Source File: ManifestEvaluator.java    From iceberg with Apache License 2.0 4 votes vote down vote up
private ManifestEvaluator(PartitionSpec spec, Expression partitionFilter, boolean caseSensitive) {
  this.struct = spec.partitionType();
  this.expr = Binder.bind(struct, rewriteNot(partitionFilter), caseSensitive);
}