Skip to content

Commit 9e2de1b

Browse files
pradithyafeast-ci-bot
authored andcommitted
Fix validating feature row when the associated feature spec has no warehouse store (#90)
1 parent 172a0eb commit 9e2de1b

4 files changed

Lines changed: 95 additions & 4 deletions

File tree

‎ingestion/src/main/java/feast/ingestion/transform/fn/ValidateFeatureRowsDoFn.java‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
public class ValidateFeatureRowsDoFn extends BaseFeatureDoFn {
4848

49+
private static final String EMPTY_STORE = "";
4950
private final List<String> featureIds = new ArrayList<>();
5051

5152
private Set<String> supportedServingTypes = new HashSet<>();
@@ -108,10 +109,13 @@ public void processElementImpl(ProcessContext context) {
108109
String.format("Serving storage type=%s not supported", servingStorageSpec.getType()));
109110

110111
String warehouseStoreId = featureSpec.getDataStores().getWarehouse().getId();
111-
StorageSpec warehouseStorageSpec = specs.getStorageSpec(warehouseStoreId);
112-
checkArgument(
113-
supportedWarehouseTypes.contains(warehouseStorageSpec.getType()),
114-
String.format("Warehouse storage type=%s not supported", servingStorageSpec.getType()));
112+
if (!warehouseStoreId.equals(EMPTY_STORE)) {
113+
StorageSpec warehouseStorageSpec = specs.getStorageSpec(warehouseStoreId);
114+
checkArgument(
115+
supportedWarehouseTypes.contains(warehouseStorageSpec.getType()),
116+
String.format(
117+
"Warehouse storage type=%s not supported", servingStorageSpec.getType()));
118+
}
115119

116120
checkArgument(
117121
featureSpec.getEntity().equals(row.getEntityName()),

‎ingestion/src/test/java/feast/ingestion/ImportJobCSVTest.java‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,59 @@ public void testImportWithErrors() throws IOException {
276276
PAssert.that(writtenToServing).satisfies(hasCount(0));
277277
testPipeline.run();
278278
}
279+
280+
281+
@Test
282+
public void testImportWithoutWarehouseStore() throws IOException {
283+
ImportSpec importSpec =
284+
ProtoUtil.decodeProtoYaml(
285+
"---\n"
286+
+ "type: file\n"
287+
+ "options:\n"
288+
+ " format: csv\n"
289+
+ " # path: to be overwritten in tests\n"
290+
+ "entities:\n"
291+
+ " - testEntity\n"
292+
+ "schema:\n"
293+
+ " entityIdColumn: id\n"
294+
+ " timestampValue: 2018-09-25T00:00:00.000Z\n"
295+
+ " fields:\n"
296+
+ " - name: id\n"
297+
+ " - featureId: testEntity.none.testInt64NoWarehouse\n"
298+
+ " - featureId: testEntity.none.testStringNoWarehouse\n"
299+
+ "\n",
300+
ImportSpec.getDefaultInstance());
301+
302+
File csvFile = folder.newFile("data.csv");
303+
304+
// Note the string and integer features are in the wrong positions for the import spec.
305+
Files.asCharSink(csvFile, Charsets.UTF_8).write("1,101,a\n2,202,b\n3,303,c\n");
306+
importSpec = initImportSpec(importSpec, csvFile.toString());
307+
308+
ImportJobOptions options = initOptions();
309+
options.setErrorsStoreType(MOCK_ERRORS_STORE_TYPE);
310+
311+
Injector injector =
312+
Guice.createInjector(
313+
new ImportJobModule(options, importSpec), new TestPipelineModule(testPipeline));
314+
315+
ImportJob job = injector.getInstance(ImportJob.class);
316+
317+
injector.getInstance(ImportJob.class);
318+
job.expand();
319+
320+
PCollection<FeatureRowExtended> writtenToServing =
321+
PCollectionList.of(ServingStoreService.get(MockServingStore.class).getWrite().getInputs())
322+
.apply("flatten serving input", Flatten.pCollections());
323+
324+
PCollection<FeatureRowExtended> writtenToErrors =
325+
PCollectionList.of(ErrorsStoreService.get(MockErrorsStore.class).getWrite().getInputs())
326+
.apply("flatten errors input", Flatten.pCollections());
327+
328+
PAssert.that(writtenToErrors)
329+
.satisfies(hasCount(0));
330+
331+
PAssert.that(writtenToServing).satisfies(hasCount(3));
332+
testPipeline.run();
333+
}
279334
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"id": "testEntity.none.testInt64NoWarehouse",
3+
"entity": "testEntity",
4+
"granularity": "NONE",
5+
"name": "testInt64NoWarehouse",
6+
"owner": "feast@example.com",
7+
"description": "This is test feature of type integer",
8+
"uri": "https://example.com/",
9+
"valueType": "INT64",
10+
"tags": [],
11+
"options": {},
12+
"dataStores": {
13+
"serving": {
14+
"id": "TEST_SERVING"
15+
}
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"id": "testEntity.none.testStringNoWarehouse",
3+
"entity": "testEntity",
4+
"granularity": "NONE",
5+
"name": "testStringNoWarehouse",
6+
"owner": "feast@example.com",
7+
"description": "This is test feature of type integer",
8+
"uri": "https://example.com/",
9+
"valueType": "STRING",
10+
"dataStores": {
11+
"serving": {
12+
"id": "TEST_SERVING"
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)