Skip to content

Commit

Permalink
Return a plain null value instead of unkown_prop if no prop was found.
Browse files Browse the repository at this point in the history
  • Loading branch information
xtcyclist committed Nov 10, 2022
1 parent 4191724 commit 492f33f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/expression/AttributeExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Value &AttributeExpression::eval(ExpressionContext &ctx) {
}
auto iter = lvalue.getEdge().props.find(rvalue.getStr());
if (iter == lvalue.getEdge().props.end()) {
return Value::kNullUnknownProp;
return Value::kNullValue;
}
return iter->second;
}
Expand Down
55 changes: 55 additions & 0 deletions tests/tck/features/match/With.feature
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,58 @@ Feature: With clause
RETURN a
"""
Then a SemanticError should be raised at runtime: Alias `b` not defined

Scenario: condition on nonexist prop
Given an empty graph
And having executed:
"""
DROP SPACE `nebula_huskie`;
CREATE SPACE IF NOT EXISTS `nebula_huskie` (partition_num = 32, replica_factor = 1, charset = utf8, collate = utf8_bin, vid_type = INT64, atomic_edge = false);
"""
And having executed:
"""
USE `nebula_huskie`
"""
And having executed:
"""
CREATE EDGE IF NOT EXISTS `EDGE_0` (`edgeProp_0_0` bool NULL, `edgeProp_0_1` bool NULL, `edgeProp_0_2` float NULL,
`edgeProp_0_3` string NULL, `edgeProp_0_4` float NULL)
ttl_duration = 0, ttl_col = ""
"""
And having executed:
"""
CREATE EDGE IF NOT EXISTS `EDGE_1` (`edgeProp_1_0` bool NULL) ttl_duration = 0, ttl_col = ""
"""
And having executed:
"""
CREATE TAG IF NOT EXISTS `Label_0` (`labelProp_0_0` float NULL, `labelProp_0_1` string NULL, `labelProp_0_2` bool NULL, `labelProp_0_3` string NULL) ttl_duration = 0, ttl_col = ""
"""
And wait 3 seconds
And having executed:
"""
insert vertex Label_0(labelProp_0_0, labelProp_0_1, labelProp_0_2, labelProp_0_3) values 100:(0.5402889847755432,"Rajon Rondo",true,"Shaquile O'Neal");
insert vertex Label_0(labelProp_0_0, labelProp_0_1, labelProp_0_2, labelProp_0_3) values 101:(0.5402889847755432,"Rajon Rondo",true,"Shaquile O'Neal");
insert edge EDGE_0 values 100->101:(true, false, 0.9068049788475037, "Yao Ming", 0.906804);
insert edge EDGE_1 values 100->101:(true);
"""
When executing query:
"""
Match p = (v)-[e]->(t) where id(v) in [100] and e.edgeProp_1_0 == true with e as e, t as t where e.edgeProp_1_0 == true return e;
"""
Then the result should be, in any order:
| e |
| [:EDGE_1 100->101 @0 {edgeProp_1_0: true}] |
When executing query:
"""
match p = (v)-[e]->(t) where id(v) in [100] and e.edgeProp_0_0 == true with e as e, t as t where e.edgeProp_0_0 == true return e.edgeProp_0_0;
"""
Then the result should be, in any order:
| e.edgeProp_0_0 |
| true |
When executing query:
"""
match p = (v)-[e]->(t) where id(v) in [100] and e.edgeProp_0_0 == true with e as e, t as t where e.edgeProp_0_0 == true return e.edgeProp_1_0;
"""
Then the result should be, in any order:
| e.edgeProp_1_0 |
| NULL |

0 comments on commit 492f33f

Please sign in to comment.