Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Feature Table not updated on new feature addition #1197

Merged
merged 1 commit into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -409,8 +409,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 @@ -648,6 +648,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