Skip to content

Commit 0a6173b

Browse files
authored
fix(interactive): Fix builtin procedure shortest_path_among_three, accept any type pk values (#4552)
As titled.
1 parent 36510de commit 0a6173b

File tree

5 files changed

+34
-16
lines changed

5 files changed

+34
-16
lines changed

flex/engines/graph_db/app/builtin/shortest_path_among_three.cc

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
namespace gs {
1818

1919
results::CollectiveResults ShortestPathAmongThree::Query(
20-
const GraphDBSession& sess, std::string label_name1, int64_t oid1,
21-
std::string label_name2, int64_t oid2, std::string label_name3,
22-
int64_t oid3) {
20+
const GraphDBSession& sess, std::string label_name1, std::string oid1_str,
21+
std::string label_name2, std::string oid2_str, std::string label_name3,
22+
std::string oid3_str) {
2323
ReadTransaction txn = sess.GetReadTransaction();
2424
const Schema& schema_ = txn.schema();
2525

@@ -30,8 +30,26 @@ results::CollectiveResults ShortestPathAmongThree::Query(
3030
return {};
3131
}
3232
label_t label_v1 = schema_.get_vertex_label_id(label_name1);
33+
auto oid1 = ConvertStringToAny(
34+
oid1_str, std::get<0>(schema_.get_vertex_primary_key(label_v1)[0]));
35+
if (oid1.type == PropertyType::Empty()) {
36+
LOG(ERROR) << "Invalid oid1.";
37+
return {};
38+
}
3339
label_t label_v2 = schema_.get_vertex_label_id(label_name2);
40+
auto oid2 = ConvertStringToAny(
41+
oid2_str, std::get<0>(schema_.get_vertex_primary_key(label_v2)[0]));
42+
if (oid2.type == PropertyType::Empty()) {
43+
LOG(ERROR) << "Invalid oid2.";
44+
return {};
45+
}
3446
label_t label_v3 = schema_.get_vertex_label_id(label_name3);
47+
auto oid3 = ConvertStringToAny(
48+
oid3_str, std::get<0>(schema_.get_vertex_primary_key(label_v3)[0]));
49+
if (oid3.type == PropertyType::Empty()) {
50+
LOG(ERROR) << "Invalid oid3.";
51+
return {};
52+
}
3553
vid_t index_v1{};
3654
vid_t index_v2{};
3755
vid_t index_v3{};

flex/engines/graph_db/app/builtin/shortest_path_among_three.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
namespace gs {
2222
class ShortestPathAmongThree
23-
: public CypherReadAppBase<std::string, int64_t, std::string, int64_t,
24-
std::string, int64_t> {
23+
: public CypherReadAppBase<std::string, std::string, std::string,
24+
std::string, std::string, std::string> {
2525
public:
2626
ShortestPathAmongThree() {}
2727
results::CollectiveResults Query(const GraphDBSession& sess,
28-
std::string label_name1, int64_t oid1,
29-
std::string label_name2, int64_t oid2,
30-
std::string label_name3, int64_t oid3);
28+
std::string label_name1, std::string oid1,
29+
std::string label_name2, std::string oid2,
30+
std::string label_name3, std::string oid3);
3131

3232
private:
3333
bool ShortestPath(const gs::ReadTransaction& txn, label_t v1_l,

flex/interactive/sdk/python/gs_interactive/tests/test_robustness.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,11 @@ def test_builtin_procedure(interactive_session, neo4j_session, create_modern_gra
282282
create_modern_graph,
283283
"shortest_path_among_three",
284284
'"person"',
285-
"1L",
285+
'"1"',
286286
'"person"',
287-
"2L",
287+
'"2"',
288288
'"person"',
289-
"4L",
289+
'"4"',
290290
)
291291

292292

flex/storages/metadata/graph_meta_store.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ const std::vector<PluginMeta>& get_builtin_plugin_metas() {
125125
shortest_path_among_three.params.push_back(
126126
{"label_name1", PropertyType::kString, true});
127127
shortest_path_among_three.params.push_back(
128-
{"oid1", PropertyType::kInt64, false});
128+
{"oid1", PropertyType::kString, false});
129129
shortest_path_among_three.params.push_back(
130130
{"label_name2", PropertyType::kString, true});
131131
shortest_path_among_three.params.push_back(
132-
{"oid2", PropertyType::kInt64, false});
132+
{"oid2", PropertyType::kString, false});
133133
shortest_path_among_three.params.push_back(
134134
{"label_name3", PropertyType::kString, true});
135135
shortest_path_among_three.params.push_back(
136-
{"oid3", PropertyType::kInt64, false});
136+
{"oid3", PropertyType::kString, false});
137137
shortest_path_among_three.returns.push_back(
138138
{"path", PropertyType::kString});
139139
builtin_plugins.push_back(shortest_path_among_three);

flex/utils/property/types.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,9 @@ Any ConvertStringToAny(const std::string& value, const gs::PropertyType& type) {
626626
} else if (type == gs::PropertyType::StringView()) {
627627
return gs::Any(std::string_view(value));
628628
} else {
629-
LOG(FATAL) << "Unsupported type: " << type;
629+
LOG(ERROR) << "Unsupported type: " << type.ToString();
630+
return gs::Any();
630631
}
631-
return gs::Any();
632632
}
633633

634634
} // namespace gs

0 commit comments

Comments
 (0)