Search in sources :

Example 21 with FeatureGroupFeatureDTO

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

the class TestFilterController method testFindFilteredFeatureNoId.

@Test
public void testFindFilteredFeatureNoId() throws Exception {
    FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("fg2_ft", "double", "");
    Feature result = filterController.findFilteredFeature(featureGroupFeatureDTO, fgLookup, availableFeatureLookup);
    Assert.assertEquals("fg2_ft", result.getName());
    Assert.assertEquals("fg2", result.getFgAlias(false));
    Assert.assertEquals("double", result.getType());
    Assert.assertEquals("10.0", result.getDefaultValue());
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) Feature(io.hops.hopsworks.common.featurestore.query.Feature) Test(org.junit.Test)

Example 22 with FeatureGroupFeatureDTO

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

the class TestFilterController method testConvertFilter.

@Test
public void testConvertFilter() throws Exception {
    FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("fg2_ft", "double", "");
    FilterDTO filter = new FilterDTO(featureGroupFeatureDTO, SqlCondition.EQUALS, "10");
    Filter result = filterController.convertFilter(filter, fgLookup, availableFeatureLookup);
    Feature feature = result.getFeatures().get(0);
    Assert.assertEquals(SqlCondition.EQUALS, result.getCondition());
    Assert.assertEquals("10", result.getValue().getValue());
    Assert.assertEquals("fg2_ft", feature.getName());
    Assert.assertEquals("fg2", feature.getFgAlias(false));
    Assert.assertEquals("double", feature.getType());
    Assert.assertEquals("10.0", feature.getDefaultValue());
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) Feature(io.hops.hopsworks.common.featurestore.query.Feature) Test(org.junit.Test)

Example 23 with FeatureGroupFeatureDTO

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

the class TestFilterController method testValidateFilterLogicDTO.

@Test
public void testValidateFilterLogicDTO() throws Exception {
    // tests the validation of a FilterLogicDTO
    FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("fg1_pk", "string", "", true, "10");
    FilterDTO filter = new FilterDTO(featureGroupFeatureDTO, SqlCondition.EQUALS, "10");
    FilterLogicDTO filterLogicDTO2 = new FilterLogicDTO(SqlFilterLogic.AND);
    // case 1
    FilterLogicDTO filterLogicDTO = new FilterLogicDTO(SqlFilterLogic.AND);
    filterLogicDTO.setLeftFilter(filter);
    filterLogicDTO.setLeftLogic(filterLogicDTO2);
    thrown.expect(FeaturestoreException.class);
    filterController.validateFilterLogicDTO(filterLogicDTO);
    // case 2
    filterLogicDTO = new FilterLogicDTO(SqlFilterLogic.AND);
    filterLogicDTO.setRightFilter(filter);
    filterLogicDTO.setRightLogic(filterLogicDTO2);
    thrown.expect(FeaturestoreException.class);
    filterController.validateFilterLogicDTO(filterLogicDTO);
    // case 3
    // single and left filter null
    filterLogicDTO = new FilterLogicDTO(SqlFilterLogic.SINGLE);
    thrown.expect(FeaturestoreException.class);
    filterController.validateFilterLogicDTO(filterLogicDTO);
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) Test(org.junit.Test)

Example 24 with FeatureGroupFeatureDTO

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

the class TestFilterController method testFindFilteredFeatureWithIdException.

@Test
public void testFindFilteredFeatureWithIdException() throws Exception {
    FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("not_a_feature_of_fg2", "double", "", 2, true);
    thrown.expect(FeaturestoreException.class);
    filterController.findFilteredFeature(featureGroupFeatureDTO, fgLookup, availableFeatureLookup);
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) Test(org.junit.Test)

Example 25 with FeatureGroupFeatureDTO

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

the class TestFilterController method testConvertFilterLogic.

@Test
public void testConvertFilterLogic() throws Exception {
    // test successful conversion of FilterLogicDTO with one filter and one logic set
    FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("fg1_pk", "string", "");
    FilterDTO filter = new FilterDTO(featureGroupFeatureDTO, SqlCondition.EQUALS, "10");
    FilterLogicDTO filterLogicDTO2 = new FilterLogicDTO(SqlFilterLogic.AND);
    FilterLogicDTO filterLogicDTO = new FilterLogicDTO(SqlFilterLogic.AND);
    filterLogicDTO.setLeftFilter(filter);
    filterLogicDTO.setRightLogic(filterLogicDTO2);
    FilterLogic result = filterController.convertFilterLogic(filterLogicDTO, fgLookup, availableFeatureLookup);
    Feature feature = result.getLeftFilter().getFeatures().get(0);
    Assert.assertEquals(result.getType(), SqlFilterLogic.AND);
    Assert.assertEquals(result.getRightLogic().getType(), SqlFilterLogic.AND);
    Assert.assertEquals(SqlCondition.EQUALS, result.getLeftFilter().getCondition());
    Assert.assertEquals("10", result.getLeftFilter().getValue().getValue());
    Assert.assertEquals("fg1_pk", feature.getName());
    Assert.assertEquals("fg1", feature.getFgAlias(false));
    Assert.assertEquals("string", feature.getType());
    Assert.assertNull(feature.getDefaultValue());
}
Also used : FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) SqlFilterLogic(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.SqlFilterLogic) Feature(io.hops.hopsworks.common.featurestore.query.Feature) 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