Skip to content

Commit

Permalink
[HOPSWORKS-3141] Fix query filter date type (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethmhc authored and SirOibaf committed Jul 18, 2022
1 parent fa44855 commit ace3848
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 14 deletions.
60 changes: 57 additions & 3 deletions hopsworks-IT/src/test/ruby/spec/featureview_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
featurestore_id = get_featurestore_id(@project.id)
featurestore_name = get_featurestore_name(@project.id)
featuregroup_suffix = short_random_id
project_name = @project.projectname.downcase
query = make_sample_query(@project, featurestore_id, featuregroup_suffix: featuregroup_suffix)
json_result = create_feature_view(@project.id, featurestore_id, query)
parsed_json = JSON.parse(json_result)
Expand Down Expand Up @@ -64,7 +63,6 @@
it "should be able to retrieve original query" do
featurestore_id = get_featurestore_id(@project.id)
featurestore_name = get_featurestore_name(@project.id)
project_name = @project.projectname.downcase
featuregroup_suffix = short_random_id
query = make_sample_query(@project, featurestore_id, featuregroup_suffix: featuregroup_suffix)
json_result = create_feature_view(@project.id, featurestore_id, query)
Expand All @@ -91,7 +89,6 @@
it "should be able to create batch query using retrieved query" do
featurestore_id = get_featurestore_id(@project.id)
featurestore_name = get_featurestore_name(@project.id)
project_name = @project.projectname.downcase
featuregroup_suffix = short_random_id
query = make_sample_query(@project, featurestore_id, featuregroup_suffix: featuregroup_suffix)
json_result = create_feature_view(@project.id, featurestore_id, query)
Expand Down Expand Up @@ -132,6 +129,63 @@
expect(parsed_query_result["filter"]["rightLogic"]["leftFilter"]["condition"]).to eql("LESS_THAN_OR_EQUAL")
expect(parsed_query_result["filter"]["rightLogic"]["leftFilter"]["value"]).to eql("4321")
end


it "should be able to create sql string with different type of event time filter" do
featurestore_id = get_featurestore_id(@project.id)
project_name = @project.projectname.downcase
featurestore_name = get_featurestore_name(@project.id)
featuregroup_suffix = short_random_id
features_a = [
{ type: "INT", name: "id", primary: true },
{ type: "DATE", name: "ts_date" },
{ type: "TIMESTAMP", name: "ts" },
]
fg_id = create_cached_featuregroup_checked(@project.id, featurestore_id, "test_fg_a#{featuregroup_suffix}",
features: features_a,
event_time: "ts")
query = {
leftFeatureGroup: {
id: fg_id
},
leftFeatures: [{ name: 'ts_date' }, { name: 'ts' }],
filter: {
type: "AND",
leftFilter: {
feature: {
name: "ts_date",
featureGroupId: fg_id
},
condition: "GREATER_THAN",
value: "2022-01-01"
},
rightFilter: {
feature: {
name: "ts",
featureGroupId: fg_id
},
condition: "GREATER_THAN",
value: "2022-02-01 00:00:00"
}
}
}

query_result = put "#{ENV['HOPSWORKS_API']}/project/#{@project.id}/featurestores/query", query.to_json
expect_status_details(200)
parsed_query_result = JSON.parse(query_result)

expect(parsed_query_result['query']).to eql(
"SELECT `fg0`.`ts_date` `ts_date`, `fg0`.`ts` `ts`\n" +
"FROM `#{featurestore_name}`.`test_fg_a#{featuregroup_suffix}_1` `fg0`\n" +
"WHERE `fg0`.`ts_date` > DATE '#{query[:filter][:leftFilter][:value]}' AND `fg0`.`ts` > TIMESTAMP '#{query[:filter][:rightFilter][:value]}.000'"
)

expect(parsed_query_result['queryOnline']).to eql(
"SELECT `fg0`.`ts_date` `ts_date`, `fg0`.`ts` `ts`\n" +
"FROM `#{project_name.downcase}`.`test_fg_a#{featuregroup_suffix}_1` `fg0`\n" +
"WHERE `fg0`.`ts_date` > DATE '#{query[:filter][:leftFilter][:value]}' AND `fg0`.`ts` > TIMESTAMP '#{query[:filter][:rightFilter][:value]}.000'"
)
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions hopsworks-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<groupId>io.hops.calcite</groupId>
<artifactId>calcite-core-shaded-guava-31</artifactId>
</dependency>
<!-- Here we are lying to Maven. Calcite has some dependency that depends on protobuf 3.0.0.
We are not going to use that codepath as we only use a small subset of calcite code.
Expand Down
4 changes: 2 additions & 2 deletions hopsworks-persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<groupId>io.hops.calcite</groupId>
<artifactId>calcite-core-shaded-guava-31</artifactId>
</dependency>
<!-- Here we are lying to Maven. Calcite has some dependency that depends on protobuf 3.0.0.
We are not going to use that codepath as we only use a small subset of calcite code.
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
<bcprov-jdk15on.version>1.69</bcprov-jdk15on.version>
<bijection-avro_2.12.version>0.9.6</bijection-avro_2.12.version>
<caffeine.version>2.8.0</caffeine.version>
<calcite-core.version>1.27.0</calcite-core.version>
<calcite-server.version>1.27.0</calcite-server.version>
<calcite-core.version>1.31.0-SNAPSHOT</calcite-core.version>
<calcite-server.version>1.31.0-SNAPSHOT</calcite-server.version>
<commons-collections.version>3.2.2</commons-collections.version>
<commons-fileupload.version>1.4</commons-fileupload.version>
<commons-httpclient.version>3.1</commons-httpclient.version>
Expand All @@ -112,7 +112,7 @@
<!-- gitlab4j-api 4.10.15 Switched to the jakarta version of the activation and servlet dependencies. -->
<gitlab4j-api.version>4.10.14</gitlab4j-api.version>
<google-gson.version>2.2</google-gson.version>
<google-guava.version>21.0</google-guava.version>
<google-guava.version>19.0</google-guava.version>
<google-zxing-javase.version>3.0.0</google-zxing-javase.version>
<googlecode-json-simple.version>1.1.1</googlecode-json-simple.version>
<handy-uri-templates.version>2.1.8</handy-uri-templates.version>
Expand Down Expand Up @@ -673,8 +673,8 @@
<version>${avro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<groupId>io.hops.calcite</groupId>
<artifactId>calcite-core-shaded-guava-31</artifactId>
<version>${calcite-core.version}</version>
<exclusions>
<exclusion>
Expand All @@ -688,8 +688,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-server</artifactId>
<groupId>io.hops.calcite</groupId>
<artifactId>calcite-server-shaded-guava-31</artifactId>
<version>${calcite-server.version}</version>
</dependency>
<dependency>
Expand Down

0 comments on commit ace3848

Please sign in to comment.