Skip to content

Commit

Permalink
Don't set spark type as online type in Java API (#131)
Browse files Browse the repository at this point in the history
Closes #130
  • Loading branch information
SirOibaf committed Nov 5, 2020
1 parent 7169a09 commit 2665497
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 15 additions & 0 deletions java/src/main/java/com/logicalclocks/hsfs/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ public Feature(@NonNull String name, @NonNull String type, @NonNull String defau
this.defaultValue = defaultValue;
}

public Feature(String name, String type, Boolean primary, Boolean partition)
throws FeatureStoreException {
if (Strings.isNullOrEmpty(name)) {
throw new FeatureStoreException("Name is required when creating a feature");
}
this.name = name;

if (Strings.isNullOrEmpty(type)) {
throw new FeatureStoreException("Type is required when creating a feature");
}
this.type = type;
this.primary = primary;
this.partition = partition;
}

@Builder
public Feature(String name, String type, String onlineType, Boolean primary, Boolean partition, String defaultValue)
throws FeatureStoreException {
Expand Down
7 changes: 5 additions & 2 deletions java/src/main/java/com/logicalclocks/hsfs/engine/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public List<Feature> parseFeatureGroupSchema(Dataset<Row> dataset) throws Featur
List<Feature> features = new ArrayList<>();
for (StructField structField : dataset.schema().fields()) {
// TODO(Fabio): unit test this one for complext types
features.add(new Feature(structField.name(), structField.dataType().catalogString(),
structField.dataType().catalogString(), false, false, null));
Feature f = new Feature(structField.name(), structField.dataType().catalogString(), false, false);
if (structField.metadata().contains("description")) {
f.setDescription(structField.metadata().getString("description"));
}
features.add(f);
}

return features;
Expand Down

0 comments on commit 2665497

Please sign in to comment.