diff --git a/src/executor/test/GoTest.cpp b/src/executor/test/GoTest.cpp index 7f5a98722f32b7c3df2a2e8e8f192501d2f7efec..bbfe4f632f3c932d0f64269ec6cb869db53a9c0a 100644 --- a/src/executor/test/GoTest.cpp +++ b/src/executor/test/GoTest.cpp @@ -626,5 +626,69 @@ TEST_F(GoTest, NotExistTagProp) { ASSERT_NE(cpp2::ErrorCode::SUCCEEDED, code); } } + +TEST_F(GoTest, is_inCall) { + { + cpp2::ExecutionResponse resp; + auto &player = players_["Boris Diaw"]; + auto *fmt = "GO FROM %ld OVER serve " + "WHERE udf_is_in($$.team.name, \"Hawks\", \"Suns\") " + "YIELD $^.player.name, serve.start_year, serve.end_year, $$.team.name"; + auto query = folly::stringPrintf(fmt, player.vid()); + auto code = client_->execute(query, resp); + ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code) << *resp.get_error_msg(); + + std::vector<std::string> expectedColNames{ + {"$^.player.name"}, {"serve.start_year"}, {"serve.end_year"}, {"$$.team.name"} + }; + ASSERT_TRUE(verifyColNames(resp, expectedColNames)); + + std::vector<std::tuple<std::string, int64_t, int64_t, std::string>> expected = { + {player.name(), 2003, 2005, "Hawks"}, + {player.name(), 2005, 2008, "Suns"}, + }; + ASSERT_TRUE(verifyResult(resp, expected)); + } + { + cpp2::ExecutionResponse resp; + auto *fmt = "GO FROM %ld OVER like YIELD like._dst AS id" + "| GO FROM $-.id OVER serve WHERE udf_is_in($-.id, %ld, 123)"; + auto query = folly::stringPrintf(fmt, + players_["Tim Duncan"].vid(), players_["Tony Parker"].vid()); + auto code = client_->execute(query, resp); + ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); + + std::vector<std::string> expectedColNames{ + {"serve._dst"} + }; + ASSERT_TRUE(verifyColNames(resp, expectedColNames)); + + std::vector<std::tuple<int64_t>> expected = { + {teams_["Spurs"].vid()}, + {teams_["Hornets"].vid()}, + }; + ASSERT_TRUE(verifyResult(resp, expected)); + } + { + cpp2::ExecutionResponse resp; + auto *fmt = "GO FROM %ld OVER like YIELD like._dst AS id" + "| GO FROM $-.id OVER serve WHERE udf_is_in($-.id, %ld, 123) && 1 == 1"; + auto query = folly::stringPrintf(fmt, + players_["Tim Duncan"].vid(), players_["Tony Parker"].vid()); + auto code = client_->execute(query, resp); + ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); + + std::vector<std::string> expectedColNames{ + {"serve._dst"} + }; + ASSERT_TRUE(verifyColNames(resp, expectedColNames)); + + std::vector<std::tuple<int64_t>> expected = { + {teams_["Spurs"].vid()}, + {teams_["Hornets"].vid()}, + }; + ASSERT_TRUE(verifyResult(resp, expected)); + } +} } // namespace graph } // namespace nebula diff --git a/src/executor/test/YieldTest.cpp b/src/executor/test/YieldTest.cpp index 865635edc7f9bd07030901d0c92466e310c3db7f..791ce0c7ca992ac21fe018c516896ec6db3552b5 100644 --- a/src/executor/test/YieldTest.cpp +++ b/src/executor/test/YieldTest.cpp @@ -203,5 +203,24 @@ TEST_F(YieldTest, Logic) { ASSERT_TRUE(verifyResult(resp, expected)); } } + +TEST_F(YieldTest, inCall) { + auto client = gEnv->getClient(); + ASSERT_NE(nullptr, client); + { + cpp2::ExecutionResponse resp; + std::string query = "YIELD udf_is_in(1,0,1,2), 123"; + auto code = client->execute(query, resp); + ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code) << *resp.get_error_msg(); + std::vector<std::string> expectedColNames{ + {"udf_is_in(1,0,1,2)"}, {"123"} + }; + ASSERT_TRUE(verifyColNames(resp, expectedColNames)); + std::vector<std::tuple<bool, uint64_t>> expected{ + {true, 123} + }; + ASSERT_TRUE(verifyResult(resp, expected)); + } +} } // namespace graph } // namespace nebula