Search in sources :

Example 56 with FeatureGroupFeatureDTO

use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.

the class TestOnlineFeatureGroupController method testBuildAlterStatementDefaultValueOther.

@Test
public void testBuildAlterStatementDefaultValueOther() {
    List<FeatureGroupFeatureDTO> features = new ArrayList<>();
    features.add(new FeatureGroupFeatureDTO("feature", "float", "", false, "10.0"));
    String output = onlineFeaturegroupController.buildAlterStatement("tbl", "db", features);
    String expected = "ALTER TABLE `db`.`tbl` ADD COLUMN `feature` float NOT NULL DEFAULT 10.0;";
    Assert.assertEquals(expected, output);
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 57 with FeatureGroupFeatureDTO

use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.

the class TestOnlineFeatureGroupController method testBuildAlterStatementDefaultValueString.

@Test
public void testBuildAlterStatementDefaultValueString() {
    List<FeatureGroupFeatureDTO> features = new ArrayList<>();
    features.add(new FeatureGroupFeatureDTO("feature", "string", "", false, "defaultValue"));
    String output = onlineFeaturegroupController.buildAlterStatement("tbl", "db", features);
    String expected = "ALTER TABLE `db`.`tbl` ADD COLUMN `feature` VARCHAR(100) NOT NULL DEFAULT 'defaultValue';";
    Assert.assertEquals(expected, output);
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 58 with FeatureGroupFeatureDTO

use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.

the class TestOnlineFeatureGroupController method testBuildCreateStatementTableSpaceNoDefaultValue.

@Test
public void testBuildCreateStatementTableSpaceNoDefaultValue() {
    Mockito.when(settings.getOnlineFeatureStoreTableSpace()).thenReturn("abc");
    List<FeatureGroupFeatureDTO> features = new ArrayList<>();
    features.add(new FeatureGroupFeatureDTO("pk", "int", "", true, false));
    features.add(new FeatureGroupFeatureDTO("feature", "String", "", false, false));
    String output = onlineFeaturegroupController.buildCreateStatement("db", "tbl", features);
    String expected = "CREATE TABLE IF NOT EXISTS `db`.`tbl`(`pk` int, `feature` VARCHAR(100), PRIMARY KEY (`pk`))" + "ENGINE=ndbcluster COMMENT='NDB_TABLE=READ_BACKUP=1'/*!50100 TABLESPACE `abc` STORAGE DISK */";
    Assert.assertEquals(expected, output);
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 59 with FeatureGroupFeatureDTO

use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.

the class TestOnlineFeatureGroupController method testBuildCreateStatementNoDefaultValue.

@Test
public void testBuildCreateStatementNoDefaultValue() {
    Mockito.when(settings.getOnlineFeatureStoreTableSpace()).thenReturn("");
    List<FeatureGroupFeatureDTO> features = new ArrayList<>();
    features.add(new FeatureGroupFeatureDTO("pk", "int", "", true, false));
    features.add(new FeatureGroupFeatureDTO("feature", "String", "", false, false));
    String output = onlineFeaturegroupController.buildCreateStatement("db", "tbl", features);
    String expected = "CREATE TABLE IF NOT EXISTS `db`.`tbl`(`pk` int, `feature` VARCHAR(100), PRIMARY KEY (`pk`))" + "ENGINE=ndbcluster COMMENT='NDB_TABLE=READ_BACKUP=1'";
    Assert.assertEquals(expected, output);
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

FeatureGroupFeatureDTO (io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO)59 ArrayList (java.util.ArrayList)34 Test (org.junit.Test)33 Feature (io.hops.hopsworks.common.featurestore.query.Feature)8 Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)8 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)7 CachedFeaturegroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup)7 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)5 Before (org.junit.Before)5 FeaturegroupDTO (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO)4 OnlineFeaturestoreController (io.hops.hopsworks.common.featurestore.online.OnlineFeaturestoreController)4 FeaturegroupController (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupController)3 CachedFeaturegroupDTO (io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO)3 FilterController (io.hops.hopsworks.common.featurestore.query.filter.FilterController)3 Featurestore (io.hops.hopsworks.persistence.entity.featurestore.Featurestore)3 CachedFeature (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeature)3 CachedFeatureExtraConstraints (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeatureExtraConstraints)3 Project (io.hops.hopsworks.persistence.entity.project.Project)3 Users (io.hops.hopsworks.persistence.entity.user.Users)3 IOException (java.io.IOException)3