use of com.netflix.metacat.connector.polaris.store.entities.PolarisTableEntity in project metacat by Netflix.
the class PolarisStoreConnectorTest method createTable.
private PolarisTableEntity createTable(final String dbName, final String tblName) {
final PolarisTableEntity entity = polarisConnector.createTable(dbName, tblName, "loc");
Assert.assertTrue(polarisConnector.tableExistsById(entity.getTblId()));
Assert.assertTrue(polarisConnector.tableExists(dbName, tblName));
Assert.assertTrue(entity.getTblId().length() > 0);
Assert.assertTrue(entity.getVersion() >= 0);
Assert.assertEquals(dbName, entity.getDbName());
Assert.assertEquals(tblName, entity.getTblName());
final Optional<PolarisTableEntity> fetchedEntity = polarisConnector.getTable(dbName, tblName);
Assert.assertTrue(fetchedEntity.isPresent());
Assert.assertEquals(entity, fetchedEntity.get());
return entity;
}
use of com.netflix.metacat.connector.polaris.store.entities.PolarisTableEntity in project metacat by Netflix.
the class PolarisStoreConnectorTest method createTableWithSaveApi.
/**
* Test to validate that the table can be created via a PolarisTableEntity parameter.
* Also tests that metadata_location is getting stored.
*/
@Test
public void createTableWithSaveApi() {
final String dbName = generateDatabaseName();
createDB(dbName);
final String tblName = generateTableName();
final String metadataLocation = "s3/s3n://dataoven-prod/hive/dataoven_prod/warehouse/foo";
final PolarisTableEntity e = new PolarisTableEntity(dbName, tblName);
e.setMetadataLocation(metadataLocation);
final PolarisTableEntity savedEntity = polarisConnector.saveTable(e);
Assert.assertEquals(metadataLocation, savedEntity.getMetadataLocation());
}
use of com.netflix.metacat.connector.polaris.store.entities.PolarisTableEntity in project metacat by Netflix.
the class PolarisStoreConnectorTest method updateMetadataLocationWithInterleavedSave.
/**
* Test updateLocation(...) while save(...) is called in interleaved fashion.
*/
@Test
public void updateMetadataLocationWithInterleavedSave() {
final String dbName = generateDatabaseName();
createDB(dbName);
final String tblName = generateTableName();
final String location0 = "s3/s3n://dataoven-prod/hive/dataoven_prod/warehouse/location0";
final PolarisTableEntity e = new PolarisTableEntity(dbName, tblName);
e.setMetadataLocation(location0);
final PolarisTableEntity savedEntity = polarisConnector.saveTable(e);
final String location1 = "s3/s3n://dataoven-prod/hive/dataoven_prod/warehouse/location1";
// update the metadata location.
final boolean updatedSuccess = polarisConnector.updateTableMetadataLocation(dbName, tblName, location0, location1);
Assert.assertTrue(updatedSuccess);
final String location2 = "s3/s3n://dataoven-prod/hive/dataoven_prod/warehouse/location2";
// At this point, savedEntity is stale, and any updates to savedEntity should not be allowed
// to persist.
savedEntity.setMetadataLocation(location2);
Assertions.assertThrows(OptimisticLockingFailureException.class, () -> {
polarisConnector.saveTable(savedEntity);
});
}
Aggregations