-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1. Refactor graph to only have a single read from source 2. Move validation outside of read from source * Use post-validation transform for metrics * Tidy up code Co-Authored-By: Yu-Xi Lim <thirteen37@users.noreply.github.com>
- Loading branch information
1 parent
f3b1ce7
commit 79eb4ab
Showing
8 changed files
with
241 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
ingestion/src/main/java/feast/ingestion/transform/ValidateFeatureRows.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package feast.ingestion.transform; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import feast.core.FeatureSetProto.FeatureSetSpec; | ||
import feast.ingestion.transform.fn.ValidateFeatureRowDoFn; | ||
import feast.ingestion.utils.SpecUtil; | ||
import feast.ingestion.values.FailedElement; | ||
import feast.ingestion.values.Field; | ||
import feast.types.FeatureRowProto.FeatureRow; | ||
import java.util.Map; | ||
import org.apache.beam.sdk.transforms.PTransform; | ||
import org.apache.beam.sdk.transforms.ParDo; | ||
import org.apache.beam.sdk.values.PCollection; | ||
import org.apache.beam.sdk.values.PCollectionTuple; | ||
import org.apache.beam.sdk.values.TupleTag; | ||
import org.apache.beam.sdk.values.TupleTagList; | ||
|
||
@AutoValue | ||
public abstract class ValidateFeatureRows extends | ||
PTransform<PCollection<FeatureRow>, PCollectionTuple> { | ||
|
||
public abstract FeatureSetSpec getFeatureSetSpec(); | ||
|
||
public abstract TupleTag<FeatureRow> getSuccessTag(); | ||
|
||
public abstract TupleTag<FailedElement> getFailureTag(); | ||
|
||
public static Builder newBuilder() { | ||
return new AutoValue_ValidateFeatureRows.Builder(); | ||
} | ||
|
||
@AutoValue.Builder | ||
public abstract static class Builder { | ||
|
||
public abstract Builder setFeatureSetSpec(FeatureSetSpec featureSetSpec); | ||
|
||
public abstract Builder setSuccessTag(TupleTag<FeatureRow> successTag); | ||
|
||
public abstract Builder setFailureTag(TupleTag<FailedElement> failureTag); | ||
|
||
public abstract ValidateFeatureRows build(); | ||
} | ||
|
||
@Override | ||
public PCollectionTuple expand(PCollection<FeatureRow> input) { | ||
Map<String, Field> fieldsByName = SpecUtil | ||
.getFieldByName(getFeatureSetSpec()); | ||
|
||
return input.apply("ValidateFeatureRows", | ||
ParDo.of(ValidateFeatureRowDoFn.newBuilder() | ||
.setFeatureSetName(getFeatureSetSpec().getName()) | ||
.setFeatureSetVersion(getFeatureSetSpec().getVersion()) | ||
.setFieldByName(fieldsByName) | ||
.setSuccessTag(getSuccessTag()) | ||
.setFailureTag(getFailureTag()) | ||
.build()) | ||
.withOutputTags(getSuccessTag(), TupleTagList.of(getFailureTag()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.