Search in sources :

Example 11 with PolarisTableEntity

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;
}
Also used : PolarisTableEntity(com.netflix.metacat.connector.polaris.store.entities.PolarisTableEntity)

Example 12 with PolarisTableEntity

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());
}
Also used : PolarisTableEntity(com.netflix.metacat.connector.polaris.store.entities.PolarisTableEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with PolarisTableEntity

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);
    });
}
Also used : PolarisTableEntity(com.netflix.metacat.connector.polaris.store.entities.PolarisTableEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

PolarisTableEntity (com.netflix.metacat.connector.polaris.store.entities.PolarisTableEntity)13 InvalidMetaException (com.netflix.metacat.common.server.connectors.exception.InvalidMetaException)6 ConnectorException (com.netflix.metacat.common.server.connectors.exception.ConnectorException)5 TableAlreadyExistsException (com.netflix.metacat.common.server.connectors.exception.TableAlreadyExistsException)5 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)5 TablePreconditionFailedException (com.netflix.metacat.common.server.connectors.exception.TablePreconditionFailedException)5 Test (org.junit.jupiter.api.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)5 QualifiedName (com.netflix.metacat.common.QualifiedName)3 TableInfo (com.netflix.metacat.common.server.connectors.model.TableInfo)2 Config (com.netflix.metacat.common.server.properties.Config)2 PolarisDatabaseEntity (com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity)2 Lists (com.google.common.collect.Lists)1 Pageable (com.netflix.metacat.common.dto.Pageable)1 Sort (com.netflix.metacat.common.dto.Sort)1 ConnectorContext (com.netflix.metacat.common.server.connectors.ConnectorContext)1 ConnectorRequestContext (com.netflix.metacat.common.server.connectors.ConnectorRequestContext)1 ConnectorTableService (com.netflix.metacat.common.server.connectors.ConnectorTableService)1 ConnectorUtils (com.netflix.metacat.common.server.connectors.ConnectorUtils)1