Skip to content

Commit

Permalink
fix(interactive): Support specifying vertex/edge properties as null (#…
Browse files Browse the repository at this point in the history
…3956)

As titled.

---------

Co-authored-by: dongze.ldz <dongze.ldz@alibaba-inc.com>
  • Loading branch information
zhanglei1949 and lidongze0629 authored Jun 20, 2024
1 parent 2b8b395 commit f45e831
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 3 deletions.
9 changes: 7 additions & 2 deletions flex/storages/rt_mutable_graph/schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,12 @@ static Status parse_vertex_properties(YAML::Node node,
std::vector<std::string>& names,
std::vector<StorageStrategy>& strategies,
const std::string& version) {
if (!node || !node.IsSequence()) {
if (!node || node.IsNull()) {
VLOG(10) << "Found no vertex properties specified for vertex: "
<< label_name;
return Status::OK();
}
if (!node.IsSequence()) {
LOG(ERROR) << "Expect properties for " << label_name << " to be a sequence";
return Status(StatusCode::InvalidSchema,
"Expect properties for " + label_name + " to be a sequence");
Expand Down Expand Up @@ -579,7 +584,7 @@ static Status parse_edge_properties(YAML::Node node,
std::vector<PropertyType>& types,
std::vector<std::string>& names,
const std::string& version) {
if (!node) {
if (!node || node.IsNull()) {
VLOG(10) << "Found no edge properties specified for edge: " << label_name;
return Status::OK();
}
Expand Down
78 changes: 77 additions & 1 deletion python/graphscope/gsctl/tests/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,49 @@
},
}


modern_graph_with_empty_edge_property = {
"name": "modern_graph",
"description": "This is a test graph",
"schema": {
"vertex_types": [
{
"type_name": "person",
"properties": [
{
"property_name": "id",
"property_type": {"primitive_type": "DT_SIGNED_INT64"},
},
{
"property_name": "name",
"property_type": {"string": {"long_text": ""}},
},
{
"property_name": "age",
"property_type": {"primitive_type": "DT_SIGNED_INT32"},
},
],
"primary_keys": ["id"],
}
],
"edge_types": [
{
"type_name": "knows",
"vertex_type_pair_relations": [
{
"source_vertex": "person",
"destination_vertex": "person",
"relation": "MANY_TO_MANY",
}
],
"properties": [],
"primary_keys": [],
}
],
},
}


modern_graph_vertex_only = {
"name": "modern_graph",
"description": "This is a test graph, only contains vertex",
Expand Down Expand Up @@ -383,7 +426,16 @@ def test_suit_case(self):
assert stored_procedure_id == "procedure_name"
delete_graph_by_id(graph_id_2)

def test_start_service_on_vertex_only_graph(self):
def test_corner_case_on_starting_service(self):
original_graph_id = None
status = list_service_status()
for s in status:
if s.status == "Running":
original_graph_id = s.graph_id
assert original_graph_id is not None

# case 1:
# start service on vertex only graph
graph_id = create_graph(modern_graph_vertex_only)
start_service(graph_id)
status = list_service_status()
Expand All @@ -392,6 +444,30 @@ def test_start_service_on_vertex_only_graph(self):
assert s.status == "Running"
else:
assert s.status == "Stopped"
stop_service()
delete_graph_by_id(graph_id)

# case 2:
# start service on graph with empty edge property
graph_id = create_graph(modern_graph_with_empty_edge_property)
start_service(original_graph_id)
status = list_service_status()
for s in status:
if s.graph_id == original_graph_id:
assert s.status == "Running"
else:
assert s.status == "Stopped"
stop_service()
delete_graph_by_id(graph_id)

# switch to original graph
start_service(original_graph_id)
status = list_service_status()
for s in status:
if s.graph_id == original_graph_id:
assert s.status == "Running"
else:
assert s.status == "Stopped"

def teardown_class(self):
disconnect_coordinator()

0 comments on commit f45e831

Please sign in to comment.