Skip to content

Commit

Permalink
[HOPSWORKS-3095][Append] Modify offline sql string to remove feature …
Browse files Browse the repository at this point in the history
…group prefix (logicalclocks#928)
  • Loading branch information
moritzmeister authored and SirOibaf committed May 12, 2022
1 parent 5ad3f68 commit 996a3ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions hopsworks-IT/src/test/ruby/spec/stream_feature_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,12 @@
expect_status_details(200)
query = JSON.parse(json_result)

expect(query['query']).to eql("SELECT `fg1`.`a_testfeature`, `fg1`.`a_testfeature1`, `fg0`.`b_testfeature1`\n" +
expect(query['query']).to eql("SELECT `fg1`.`a_testfeature` `a_testfeature`, `fg1`.`a_testfeature1` `a_testfeature1`, `fg0`.`b_testfeature1` `b_testfeature1`\n" +
"FROM `#{project_name.downcase}_featurestore`.`#{fg_a_name}_1` `fg1`\n" +
"INNER JOIN `#{project_name.downcase}_featurestore`.`#{fg_b_name}_1` `fg0` ON `fg1`.`a_testfeature` = `fg0`.`a_testfeature`\n" +
"WHERE (`fg1`.`a_testfeature` = 10 OR `fg0`.`b_testfeature1` = 10) AND `fg0`.`b_testfeature2` = 10")

expect(query['queryOnline']).to eql("SELECT `fg1`.`a_testfeature`, `fg1`.`a_testfeature1`, `fg0`.`b_testfeature1`\n" +
expect(query['queryOnline']).to eql("SELECT `fg1`.`a_testfeature` `a_testfeature`, `fg1`.`a_testfeature1` `a_testfeature1`, `fg0`.`b_testfeature1` `b_testfeature1`\n" +
"FROM `#{project_name.downcase}`.`#{fg_a_name}_1` `fg1`\n" +
"INNER JOIN `#{project_name.downcase}`.`#{fg_b_name}_1` `fg0` ON `fg1`.`a_testfeature` = `fg0`.`a_testfeature`\n" +
"WHERE (`fg1`.`a_testfeature` = 10 OR `fg0`.`b_testfeature1` = 10) AND `fg0`.`b_testfeature2` = 10")
Expand Down Expand Up @@ -610,23 +610,23 @@
expect_status_details(200)
query = JSON.parse(json_result)

expect(query['query']).to eql("SELECT `fg1`.`a_testfeature`, `fg1`.`a_testfeature1`, `fg0`.`b_testfeature1`\n" +
expect(query['query']).to eql("SELECT `fg1`.`a_testfeature` `a_testfeature`, `fg1`.`a_testfeature1` `a_testfeature1`, `fg0`.`b_testfeature1` `b_testfeature1`\n" +
"FROM `#{project_name.downcase}_featurestore`.`#{fg_a_name}_1` `fg1`\n" +
"INNER JOIN `#{project_name.downcase}_featurestore`.`#{fg_b_name}_1` `fg0` ON `fg1`.`a_testfeature` = `fg0`.`a_testfeature`\n" +
"WHERE (`fg1`.`a_testfeature` = 10 OR `fg0`.`b_testfeature1` = 10) AND `fg0`.`b_testfeature2` = 10")

expect(query['queryOnline']).to eql("SELECT `fg1`.`a_testfeature`, `fg1`.`a_testfeature1`, `fg0`.`b_testfeature1`\n" +
expect(query['queryOnline']).to eql("SELECT `fg1`.`a_testfeature` `a_testfeature`, `fg1`.`a_testfeature1` `a_testfeature1`, `fg0`.`b_testfeature1` `b_testfeature1`\n" +
"FROM `#{project_name.downcase}`.`#{fg_a_name}_1` `fg1`\n" +
"INNER JOIN `#{project_name.downcase}`.`#{fg_b_name}_1` `fg0` ON `fg1`.`a_testfeature` = `fg0`.`a_testfeature`\n" +
"WHERE (`fg1`.`a_testfeature` = 10 OR `fg0`.`b_testfeature1` = 10) AND `fg0`.`b_testfeature2` = 10")

expect(query['pitQuery']).to eql("WITH right_fg0 AS (" +
"SELECT *\nFROM " +
"(SELECT `fg1`.`a_testfeature`, `fg1`.`a_testfeature1`, `fg1`.`a_testfeature` `join_pk_a_testfeature`, `fg1`.`event_time` `join_evt_event_time`, `fg0`.`b_testfeature1`, RANK() OVER (PARTITION BY `fg0`.`a_testfeature`, `fg1`.`event_time` ORDER BY `fg0`.`event_time` DESC) pit_rank_hopsworks\n" +
"(SELECT `fg1`.`a_testfeature` `a_testfeature`, `fg1`.`a_testfeature1` `a_testfeature1`, `fg1`.`a_testfeature` `join_pk_a_testfeature`, `fg1`.`event_time` `join_evt_event_time`, `fg0`.`b_testfeature1` `b_testfeature1`, RANK() OVER (PARTITION BY `fg0`.`a_testfeature`, `fg1`.`event_time` ORDER BY `fg0`.`event_time` DESC) pit_rank_hopsworks\n" +
"FROM `#{project_name.downcase}_featurestore`.`#{fg_a_name}_1` `fg1`\n" +
"INNER JOIN `#{project_name.downcase}_featurestore`.`#{fg_b_name}_1` `fg0` ON `fg1`.`a_testfeature` = `fg0`.`a_testfeature` AND `fg1`.`event_time` >= `fg0`.`event_time`\n" +
"WHERE (`fg1`.`a_testfeature` = 10 OR `fg0`.`b_testfeature1` = 10) AND `fg0`.`b_testfeature2` = 10) NA\n" +
"WHERE `pit_rank_hopsworks` = 1) (SELECT `right_fg0`.`a_testfeature`, `right_fg0`.`a_testfeature1`, `right_fg0`.`b_testfeature1`\nFROM right_fg0)")
"WHERE `pit_rank_hopsworks` = 1) (SELECT `right_fg0`.`a_testfeature` `a_testfeature`, `right_fg0`.`a_testfeature1` `a_testfeature1`, `right_fg0`.`b_testfeature1` `b_testfeature1`\nFROM right_fg0)")
end

it "should be able to create stream feature group with many features and get features in specific order on get" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ public void testHandleJoiningKeyRightSide() throws Exception {
public void testGetWithOrWithoutPrefix() throws Exception {
Feature feature = new Feature("ft1", "fg1", "int", null, null);
Assert.assertEquals("`fg1`.`ft1` `ft1`",
target.getWithOrWithoutAs(feature, true,false)
target.getWithOrWithoutAs(feature, true, false)
.toSqlString(new SparkSqlDialect(SqlDialect.EMPTY_CONTEXT)).getSql());
}

@Test
public void testGetWithOrWithoutPrefixWithPrefix() throws Exception {
Feature feature = new Feature("ft1", "fg1", "int", null, "right_");
Assert.assertEquals("`fg1`.`ft1` `right_ft1`",
target.getWithOrWithoutAs(feature, true,true)
target.getWithOrWithoutAs(feature, true, true)
.toSqlString(new SparkSqlDialect(SqlDialect.EMPTY_CONTEXT)).getSql());
}

Expand Down

0 comments on commit 996a3ce

Please sign in to comment.