Skip to content

Commit

Permalink
Fix Feature Table not updated on new feature addition (#1197)
Browse files Browse the repository at this point in the history
Signed-off-by: Khor Shu Heng <khor.heng@gojek.com>

Co-authored-by: Khor Shu Heng <khor.heng@gojek.com>
  • Loading branch information
2 people authored and pyalex committed Dec 1, 2020
1 parent 2f9a13e commit f156f83
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
6 changes: 3 additions & 3 deletions common-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,17 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.14.3</version>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.14.3</version>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<version>1.14.3</version>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
5 changes: 3 additions & 2 deletions common-test/src/main/java/feast/common/util/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ public static boolean compareFeatureTableSpec(FeatureTableSpec spec, FeatureTabl
.toBuilder()
.clearFeatures()
.addAllFeatures(
spec.getFeaturesList().stream()
otherSpec.getFeaturesList().stream()
.sorted(Comparator.comparing(FeatureSpecV2::getName))
.collect(Collectors.toSet()))
.clearEntities()
.addAllEntities(spec.getEntitiesList().stream().sorted().collect(Collectors.toSet()))
.addAllEntities(
otherSpec.getEntitiesList().stream().sorted().collect(Collectors.toSet()))
.build();

return spec.equals(otherSpec);
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/feast/core/model/FeatureTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ public boolean equals(Object o) {
return getName().equals(other.getName())
&& getProject().equals(other.getProject())
&& getLabelsJSON().equals(other.getLabelsJSON())
&& getFeatures().containsAll(other.getFeatures())
&& getEntities().containsAll(other.getEntities())
&& getFeatures().equals(other.getFeatures())
&& getEntities().equals(other.getEntities())
&& getMaxAgeSecs() == getMaxAgeSecs()
&& Optional.ofNullable(getBatchSource()).equals(Optional.ofNullable(other.getBatchSource()))
&& Optional.ofNullable(getStreamSource())
Expand Down
26 changes: 26 additions & 0 deletions core/src/test/java/feast/core/service/SpecServiceIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,32 @@ public void shouldUpdateFeatureTableOnFeatureTypeChange() {
assertTrue(TestUtil.compareFeatureTableSpec(updatedTable.getSpec(), updatedSpec));
}

@Test
public void shouldUpdateFeatureTableOnFeatureAddition() {
FeatureTableProto.FeatureTableSpec updatedSpec =
DataGenerator.createFeatureTableSpec(
"featuretable1",
Arrays.asList("entity1", "entity2"),
new HashMap<>() {
{
put("feature1", ValueProto.ValueType.Enum.STRING);
put("feature2", ValueProto.ValueType.Enum.FLOAT);
put("feature3", ValueProto.ValueType.Enum.FLOAT);
}
},
7200,
ImmutableMap.of("feat_key2", "feat_value2"))
.toBuilder()
.setBatchSource(
DataGenerator.createFileDataSourceSpec("file:///path/to/file", "ts_col", ""))
.build();

FeatureTableProto.FeatureTable updatedTable =
apiClient.applyFeatureTable("default", updatedSpec);

assertTrue(TestUtil.compareFeatureTableSpec(updatedTable.getSpec(), updatedSpec));
}

@Test
public void shouldNotUpdateIfNoChanges() {
FeatureTableProto.FeatureTable table = apiClient.applyFeatureTable("default", getTestSpec());
Expand Down

0 comments on commit f156f83

Please # to comment.