use of com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity in project metacat by Netflix.
the class PolarisStoreConnectorTest method testPaginatedFetch.
/**
* Test to verify that table names fetch works.
*/
@Test
public void testPaginatedFetch() {
final String dbName = generateDatabaseName();
final PolarisDatabaseEntity dbEntity = createDB(dbName);
List<String> tblNames = polarisConnector.getTables(dbName, "");
Assert.assertEquals(0, tblNames.size());
final String tblNameA = "A_" + generateTableName();
final String tblNameB = "B_" + generateTableName();
final String tblNameC = "C_" + generateTableName();
createTable(dbName, tblNameA);
createTable(dbName, tblNameB);
createTable(dbName, tblNameC);
tblNames = polarisConnector.getTables(dbName, "");
Assert.assertEquals(3, tblNames.size());
Assert.assertEquals(tblNameA, tblNames.get(0));
Assert.assertEquals(tblNameB, tblNames.get(1));
Assert.assertEquals(tblNameC, tblNames.get(2));
}
use of com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity in project metacat by Netflix.
the class PolarisStoreConnectorTest method createDB.
private PolarisDatabaseEntity createDB(final String dbName) {
final String location = "file://temp";
final PolarisDatabaseEntity entity = polarisConnector.createDatabase(dbName, location);
// assert that database exists, post-creation.
Assert.assertTrue(polarisConnector.databaseExistsById(entity.getDbId()));
Assert.assertTrue(polarisConnector.databaseExists(dbName));
Assert.assertEquals(0L, entity.getVersion().longValue());
Assert.assertTrue(entity.getDbId().length() > 0);
Assert.assertEquals(dbName, entity.getDbName());
Assert.assertEquals(location, entity.getLocation());
final Optional<PolarisDatabaseEntity> fetchedEntity = polarisConnector.getDatabase(dbName);
Assert.assertTrue(fetchedEntity.isPresent());
Assert.assertEquals(entity, fetchedEntity.get());
return entity;
}
use of com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity in project metacat by Netflix.
the class PolarisStoreConnectorTest method testTableCreationAndDeletion.
/**
* Test table creation if database exists.
* Verify table deletion
*/
@Test
public void testTableCreationAndDeletion() {
final String dbName = generateDatabaseName();
final String tblName = generateTableName();
final PolarisDatabaseEntity dbEntity = createDB(dbName);
final PolarisTableEntity tblEntity = createTable(dbName, tblName);
polarisConnector.deleteTable(dbName, tblName);
Assert.assertFalse(polarisConnector.tableExistsById(tblEntity.getTblId()));
}
use of com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity in project metacat by Netflix.
the class PolarisStoreConnectorTest method testTableUpdate.
/**
* Test to verify that table name can be updated.
*/
@Test
public void testTableUpdate() {
// Create Table Entity in DB
final String dbName = generateDatabaseName();
final String tblName = generateTableName();
final PolarisDatabaseEntity dbEntity = createDB(dbName);
final PolarisTableEntity tblEntity = createTable(dbName, tblName);
// Update table name
final String newTblName = generateTableName();
tblEntity.setTblName(newTblName);
final PolarisTableEntity updatedTblEntity = polarisConnector.saveTable(tblEntity);
Assert.assertEquals(newTblName, updatedTblEntity.getTblName());
}
use of com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity in project metacat by Netflix.
the class PolarisConnectorDatabaseService method update.
/**
* {@inheritDoc}.
*/
@Override
public void update(final ConnectorRequestContext context, final DatabaseInfo databaseInfo) {
final QualifiedName name = databaseInfo.getName();
try {
final PolarisDatabaseEntity db = polarisStoreService.getDatabase(name.getDatabaseName()).orElseThrow(() -> new DatabaseNotFoundException(name));
// currently db objects have no mutable fields so this is noop
polarisStoreService.saveDatabase(db.toBuilder().build());
} catch (DatabaseNotFoundException exception) {
log.error(String.format("Not found exception for polaris database %s", name), exception);
throw exception;
} catch (DataIntegrityViolationException exception) {
throw new InvalidMetaException(name, exception);
} catch (Exception exception) {
throw new ConnectorException(String.format("Failed updating polaris database %s", databaseInfo.getName()), exception);
}
}
Aggregations