Search in sources :

Example 1 with IcebergTables

use of org.apache.drill.metastore.iceberg.components.tables.IcebergTables in project drill by apache.

the class TestExpirationHandler method testNoExpiration.

@Test
public void testNoExpiration() {
    IcebergTables tables = tables("no-expiration", false, 2);
    // check that there is no history
    assertEquals(0, tables.table().history().size());
    int operationsNumber = 5;
    execute(tables, operationsNumber);
    // check that the number of executed operations is same as number of history records
    assertEquals(operationsNumber, tables.table().history().size());
}
Also used : IcebergTables(org.apache.drill.metastore.iceberg.components.tables.IcebergTables) Test(org.junit.Test) IcebergBaseTest(org.apache.drill.metastore.iceberg.IcebergBaseTest)

Example 2 with IcebergTables

use of org.apache.drill.metastore.iceberg.components.tables.IcebergTables in project drill by apache.

the class TestExpirationHandler method tables.

private IcebergTables tables(String name, boolean shouldExpire, int retainNumber) {
    Config config = baseIcebergConfig(new File(defaultFolder.getRoot(), name)).withValue(IcebergConfigConstants.COMPONENTS_COMMON_PROPERTIES + "." + TableProperties.METADATA_PREVIOUS_VERSIONS_MAX, ConfigValueFactory.fromAnyRef(retainNumber)).withValue(IcebergConfigConstants.COMPONENTS_COMMON_PROPERTIES + "." + TableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLED, ConfigValueFactory.fromAnyRef(shouldExpire));
    DrillConfig drillConfig = new DrillConfig(config);
    return (IcebergTables) new IcebergMetastore(drillConfig).tables();
}
Also used : IcebergTables(org.apache.drill.metastore.iceberg.components.tables.IcebergTables) DrillConfig(org.apache.drill.common.config.DrillConfig) Config(com.typesafe.config.Config) DrillConfig(org.apache.drill.common.config.DrillConfig) IcebergMetastore(org.apache.drill.metastore.iceberg.IcebergMetastore) File(java.io.File)

Example 3 with IcebergTables

use of org.apache.drill.metastore.iceberg.components.tables.IcebergTables in project drill by apache.

the class TestExpirationHandler method testSubsequentExpiration.

@Test
public void testSubsequentExpiration() {
    String name = "subsequent-expiration";
    int retainNumber = 2;
    int operationsNumber = 5;
    IcebergTables initialTables = tables(name, false, retainNumber);
    execute(initialTables, operationsNumber);
    // check that number of executed operations is the same as number of history records
    assertEquals(operationsNumber, initialTables.table().history().size());
    // update table configuration, allow expiration
    IcebergTables updatedTables = tables(name, true, retainNumber);
    // check that number of history operation did not change
    assertEquals(operationsNumber, updatedTables.table().history().size());
    execute(updatedTables, operationsNumber);
    // check that number of history records corresponds to the expected retain number
    assertEquals(retainNumber, updatedTables.table().history().size());
}
Also used : IcebergTables(org.apache.drill.metastore.iceberg.components.tables.IcebergTables) Test(org.junit.Test) IcebergBaseTest(org.apache.drill.metastore.iceberg.IcebergBaseTest)

Example 4 with IcebergTables

use of org.apache.drill.metastore.iceberg.components.tables.IcebergTables in project drill by apache.

the class TestExpirationHandler method testExpiration.

@Test
public void testExpiration() {
    int retainNumber = 3;
    IcebergTables tables = tables("expiration", true, retainNumber);
    // check that there is no history
    assertEquals(0, tables.table().history().size());
    execute(tables, 5);
    // check that number of history records corresponds to the expected retain number
    assertEquals(retainNumber, tables.table().history().size());
}
Also used : IcebergTables(org.apache.drill.metastore.iceberg.components.tables.IcebergTables) Test(org.junit.Test) IcebergBaseTest(org.apache.drill.metastore.iceberg.IcebergBaseTest)

Aggregations

IcebergTables (org.apache.drill.metastore.iceberg.components.tables.IcebergTables)4 IcebergBaseTest (org.apache.drill.metastore.iceberg.IcebergBaseTest)3 Test (org.junit.Test)3 Config (com.typesafe.config.Config)1 File (java.io.File)1 DrillConfig (org.apache.drill.common.config.DrillConfig)1 IcebergMetastore (org.apache.drill.metastore.iceberg.IcebergMetastore)1