|
25 | 25 | import feast.ingestion.values.FailedElement; |
26 | 26 | import feast.test.TestUtil; |
27 | 27 | import feast.types.FeatureRowProto.FeatureRow; |
| 28 | +import feast.types.FieldProto.Field; |
| 29 | +import feast.types.ValueProto.Value; |
28 | 30 | import feast.types.ValueProto.ValueType.Enum; |
29 | 31 | import java.util.ArrayList; |
30 | 32 | import java.util.HashMap; |
@@ -138,4 +140,65 @@ public void shouldWriteSuccessAndFailureTagsCorrectly() { |
138 | 140 |
|
139 | 141 | p.run(); |
140 | 142 | } |
| 143 | + |
| 144 | + @Test |
| 145 | + public void shouldExcludeUnregisteredFields() { |
| 146 | + FeatureSet fs1 = |
| 147 | + FeatureSet.newBuilder() |
| 148 | + .setSpec( |
| 149 | + FeatureSetSpec.newBuilder() |
| 150 | + .setName("feature_set") |
| 151 | + .setVersion(1) |
| 152 | + .setProject("myproject") |
| 153 | + .addEntities( |
| 154 | + EntitySpec.newBuilder() |
| 155 | + .setName("entity_id_primary") |
| 156 | + .setValueType(Enum.INT32) |
| 157 | + .build()) |
| 158 | + .addEntities( |
| 159 | + EntitySpec.newBuilder() |
| 160 | + .setName("entity_id_secondary") |
| 161 | + .setValueType(Enum.STRING) |
| 162 | + .build()) |
| 163 | + .addFeatures( |
| 164 | + FeatureSpec.newBuilder() |
| 165 | + .setName("feature_1") |
| 166 | + .setValueType(Enum.STRING) |
| 167 | + .build()) |
| 168 | + .addFeatures( |
| 169 | + FeatureSpec.newBuilder() |
| 170 | + .setName("feature_2") |
| 171 | + .setValueType(Enum.INT64) |
| 172 | + .build())) |
| 173 | + .build(); |
| 174 | + |
| 175 | + Map<String, FeatureSet> featureSets = new HashMap<>(); |
| 176 | + featureSets.put("myproject/feature_set:1", fs1); |
| 177 | + |
| 178 | + List<FeatureRow> input = new ArrayList<>(); |
| 179 | + List<FeatureRow> expected = new ArrayList<>(); |
| 180 | + |
| 181 | + FeatureRow randomRow = TestUtil.createRandomFeatureRow(fs1); |
| 182 | + expected.add(randomRow); |
| 183 | + input.add(randomRow.toBuilder() |
| 184 | + .addFields(Field.newBuilder() |
| 185 | + .setName("extra") |
| 186 | + .setValue(Value.newBuilder().setStringVal("hello"))) |
| 187 | + .build() |
| 188 | + ); |
| 189 | + |
| 190 | + PCollectionTuple output = |
| 191 | + p.apply(Create.of(input)) |
| 192 | + .setCoder(ProtoCoder.of(FeatureRow.class)) |
| 193 | + .apply( |
| 194 | + ValidateFeatureRows.newBuilder() |
| 195 | + .setFailureTag(FAILURE_TAG) |
| 196 | + .setSuccessTag(SUCCESS_TAG) |
| 197 | + .setFeatureSets(featureSets) |
| 198 | + .build()); |
| 199 | + |
| 200 | + PAssert.that(output.get(SUCCESS_TAG)).containsInAnyOrder(expected); |
| 201 | + |
| 202 | + p.run(); |
| 203 | + } |
141 | 204 | } |
0 commit comments