use of org.apache.iceberg.Transaction in project hive by apache.
the class HiveCreateReplaceTableTest method testCreateOrReplaceTableTxnTableNotExists.
@Test
public void testCreateOrReplaceTableTxnTableNotExists() {
Assert.assertFalse("Table should not exist", catalog.tableExists(TABLE_IDENTIFIER));
Transaction txn = catalog.newReplaceTableTransaction(TABLE_IDENTIFIER, SCHEMA, SPEC, true);
txn.updateProperties().set("prop", "value").commit();
txn.commitTransaction();
Table table = catalog.loadTable(TABLE_IDENTIFIER);
Assert.assertEquals("Table props should match", "value", table.properties().get("prop"));
}
use of org.apache.iceberg.Transaction in project hive by apache.
the class HiveCreateReplaceTableTest method testReplaceTableTxnTableDeletedConcurrently.
@Test
public void testReplaceTableTxnTableDeletedConcurrently() {
catalog.createTable(TABLE_IDENTIFIER, SCHEMA, SPEC, tableLocation, Maps.newHashMap());
Assert.assertTrue("Table should exist", catalog.tableExists(TABLE_IDENTIFIER));
Transaction txn = catalog.newReplaceTableTransaction(TABLE_IDENTIFIER, SCHEMA, SPEC, false);
catalog.dropTable(TABLE_IDENTIFIER);
txn.updateProperties().set("prop", "value").commit();
AssertHelpers.assertThrows("Replace table txn should fail", NoSuchTableException.class, "No such table: hivedb.tbl", txn::commitTransaction);
}
use of org.apache.iceberg.Transaction in project hive by apache.
the class HiveCreateReplaceTableTest method testCreateTableTxn.
@Test
public void testCreateTableTxn() {
Assert.assertFalse("Table should not exist", catalog.tableExists(TABLE_IDENTIFIER));
Transaction txn = catalog.newCreateTableTransaction(TABLE_IDENTIFIER, SCHEMA, SPEC, tableLocation, Maps.newHashMap());
txn.updateProperties().set("prop", "value").commit();
// verify the table is still not visible before the transaction is committed
Assert.assertFalse(catalog.tableExists(TABLE_IDENTIFIER));
txn.commitTransaction();
Table table = catalog.loadTable(TABLE_IDENTIFIER);
Assert.assertEquals("Table props should match", "value", table.properties().get("prop"));
}
use of org.apache.iceberg.Transaction in project hive by apache.
the class HiveCreateReplaceTableTest method testCreateOrReplaceTableTxnTableDeletedConcurrently.
@Test
public void testCreateOrReplaceTableTxnTableDeletedConcurrently() {
Assert.assertFalse("Table should not exist", catalog.tableExists(TABLE_IDENTIFIER));
catalog.createTable(TABLE_IDENTIFIER, SCHEMA, SPEC);
Assert.assertTrue("Table should be created", catalog.tableExists(TABLE_IDENTIFIER));
Transaction txn = catalog.newReplaceTableTransaction(TABLE_IDENTIFIER, SCHEMA, PartitionSpec.unpartitioned(), tableLocation, Maps.newHashMap(), true);
txn.updateProperties().set("prop", "value").commit();
// drop the table concurrently
catalog.dropTable(TABLE_IDENTIFIER);
// expect the transaction to succeed anyway
txn.commitTransaction();
Table table = catalog.loadTable(TABLE_IDENTIFIER);
Assert.assertEquals("Table props should match", "value", table.properties().get("prop"));
}
use of org.apache.iceberg.Transaction in project drill by apache.
the class IcebergModify method executeOperations.
private void executeOperations(List<IcebergOperation> operations) {
Transaction transaction = context.table().newTransaction();
operations.forEach(op -> op.add(transaction));
transaction.commitTransaction();
// expiration process should not intervene with data modification operations
// if expiration fails, will attempt to expire the next time
context.expirationHandler().expireQuietly();
}
Aggregations