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 11, 2022
1 parent aa83e95 commit 2bd5abd
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
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
10 changes: 5 additions & 5 deletions tests/tck/features/expression/Attribute.feature
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ Feature: Attribute
MATCH (v)-[e:like]->() WHERE id(v) == 'Tim Duncan' RETURN e.Likeness
"""
Then the result should be, in any order:
| e.Likeness |
| UNKNOWN_PROP |
| UNKNOWN_PROP |
| e.Likeness |
| NULL |
| NULL |

Scenario: Not exists attribute
When executing query:
Expand Down Expand Up @@ -136,8 +136,8 @@ Feature: Attribute
"""
Then the result should be, in any order:
| e.not_exists_attr |
| UNKNOWN_PROP |
| UNKNOWN_PROP |
| NULL |
| NULL |

Scenario: Invalid type
When executing query:
Expand Down
54 changes: 54 additions & 0 deletions tests/tck/features/match/With.feature
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,57 @@ 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:
"""
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 |
12 changes: 6 additions & 6 deletions tests/tck/features/optimizer/PrunePropertiesRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,10 @@ Feature: Prune Properties rule
match (src_v)-[e:like|serve]->(dst_v)-[e2]-(dst_v2) where id(src_v)=="Rajon Rondo" return properties(e).degree1,properties(e).degree1,e2.a,dst_v.p.name,dst_v.player.sex1,properties(src_v).name2 limit 5;
"""
Then the result should be, in order, with relax comparison:
| properties(e).degree1 | properties(e).degree1 | e2.a | dst_v.p.name | dst_v.player.sex1 | properties(src_v).name2 |
| UNKNOWN_PROP | UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | UNKNOWN_PROP |
| UNKNOWN_PROP | UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | UNKNOWN_PROP |
| UNKNOWN_PROP | UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | UNKNOWN_PROP |
| UNKNOWN_PROP | UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | UNKNOWN_PROP |
| UNKNOWN_PROP | UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | UNKNOWN_PROP |
| properties(e).degree1 | properties(e).degree1 | e2.a | dst_v.p.name | dst_v.player.sex1 | properties(src_v).name2 |
| UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | NULL | UNKNOWN_PROP |
| UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | NULL | UNKNOWN_PROP |
| UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | NULL | UNKNOWN_PROP |
| UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | NULL | UNKNOWN_PROP |
| UNKNOWN_PROP | UNKNOWN_PROP | NULL | NULL | NULL | UNKNOWN_PROP |
Then drop the used space

0 comments on commit 2bd5abd

Please sign in to comment.