diff --git a/common-test/pom.xml b/common-test/pom.xml index 563129cf063..62fd6ae00f2 100644 --- a/common-test/pom.xml +++ b/common-test/pom.xml @@ -106,17 +106,17 @@ org.testcontainers junit-jupiter - 1.14.3 + 1.15.0 org.testcontainers postgresql - 1.14.3 + 1.15.0 org.testcontainers kafka - 1.14.3 + 1.15.0 org.junit.jupiter diff --git a/common-test/src/main/java/feast/common/util/TestUtil.java b/common-test/src/main/java/feast/common/util/TestUtil.java index 142c5e4850d..ee355d3766f 100644 --- a/common-test/src/main/java/feast/common/util/TestUtil.java +++ b/common-test/src/main/java/feast/common/util/TestUtil.java @@ -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); diff --git a/core/src/main/java/feast/core/model/FeatureTable.java b/core/src/main/java/feast/core/model/FeatureTable.java index 8c62df64867..72ad77f1b3e 100644 --- a/core/src/main/java/feast/core/model/FeatureTable.java +++ b/core/src/main/java/feast/core/model/FeatureTable.java @@ -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()) diff --git a/core/src/test/java/feast/core/service/SpecServiceIT.java b/core/src/test/java/feast/core/service/SpecServiceIT.java index 8d56de606b0..40d6aa1a7aa 100644 --- a/core/src/test/java/feast/core/service/SpecServiceIT.java +++ b/core/src/test/java/feast/core/service/SpecServiceIT.java @@ -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());