diff --git a/java/src/main/java/com/logicalclocks/featurestore/FeatureGroup.java b/java/src/main/java/com/logicalclocks/featurestore/FeatureGroup.java index 43aea510b0..73f07fc717 100644 --- a/java/src/main/java/com/logicalclocks/featurestore/FeatureGroup.java +++ b/java/src/main/java/com/logicalclocks/featurestore/FeatureGroup.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @JsonIgnoreProperties(ignoreUnknown = true) public class FeatureGroup { @@ -57,7 +58,14 @@ public void show(int numRows) throws FeatureStoreException, IOException { selectAll().show(numRows); } - public Query select(List features) throws FeatureStoreException, IOException { + public Query select(List features) throws FeatureStoreException, IOException { + // Create a feature object for each string feature given by the user. + // For the query building each feature need only the name set. + List featureObjList = features.stream().map(Feature::new).collect(Collectors.toList()); + return selectFeatures(featureObjList); + } + + public Query selectFeatures(List features) throws FeatureStoreException, IOException { return new Query(this, features); } diff --git a/java/src/main/java/com/logicalclocks/featurestore/metadata/Query.java b/java/src/main/java/com/logicalclocks/featurestore/metadata/Query.java index 044d4c9e26..6f730352a9 100644 --- a/java/src/main/java/com/logicalclocks/featurestore/metadata/Query.java +++ b/java/src/main/java/com/logicalclocks/featurestore/metadata/Query.java @@ -12,6 +12,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class Query { @@ -38,12 +39,21 @@ public Query join(Query subquery) { return join(subquery, JoinType.INNER); } - public Query join(Query subquery, List on) { - return join(subquery, on, JoinType.INNER); + public Query join(Query subquery, List on) { + return joinFeatures(subquery, on.stream().map(Feature::new).collect(Collectors.toList()), JoinType.INNER); } - public Query join(Query subquery, List leftOn, List rightOn) { - return join(subquery, leftOn, rightOn, JoinType.INNER); + public Query joinFeatures(Query subquery, List on) { + return joinFeatures(subquery, on, JoinType.INNER); + } + + public Query join(Query subquery, List leftOn, List rightOn) { + return joinFeatures(subquery, leftOn.stream().map(Feature::new).collect(Collectors.toList()), + rightOn.stream().map(Feature::new).collect(Collectors.toList()), JoinType.INNER); + } + + public Query joinFeatures(Query subquery, List leftOn, List rightOn) { + return joinFeatures(subquery, leftOn, rightOn, JoinType.INNER); } public Query join(Query subquery, JoinType joinType) { @@ -51,12 +61,23 @@ public Query join(Query subquery, JoinType joinType) { return this; } - public Query join(Query subquery, List on, JoinType joinType) { + public Query join(Query subquery, List on, JoinType joinType) { + joins.add(new Join(subquery, on.stream().map(Feature::new).collect(Collectors.toList()), joinType)); + return this; + } + + public Query joinFeatures(Query subquery, List on, JoinType joinType) { joins.add(new Join(subquery, on, joinType)); return this; } - public Query join(Query subquery, List leftOn, List rightOn, JoinType joinType) { + public Query join(Query subquery, List leftOn, List rightOn, JoinType joinType) { + joins.add(new Join(subquery, leftOn.stream().map(Feature::new).collect(Collectors.toList()), + rightOn.stream().map(Feature::new).collect(Collectors.toList()), joinType)); + return this; + } + + public Query joinFeatures(Query subquery, List leftOn, List rightOn, JoinType joinType) { joins.add(new Join(subquery, leftOn, rightOn, joinType)); return this; }