Skip to content

Commit

Permalink
return plain null values if tag or prop does not exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
xtcyclist committed Dec 29, 2022
1 parent 1fae55d commit ca0f0ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/common/expression/AttributeExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ const Value &AttributeExpression::eval(ExpressionContext &ctx) {
result_ = time::TimeUtils::getDateTimeAttr(lvalue.getDateTime(), rvalue.getStr());
return result_;
default:
if (lvalue.isNull() && lvalue.getNull() == NullType::UNKNOWN_PROP) {
// return UNKNOWN_PROP as plain null values, instead of bad type.
return Value::kNullValue;
}
return Value::kNullBadType;
}
}
Expand Down
36 changes: 18 additions & 18 deletions tests/tck/features/optimizer/PrunePropertiesRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -766,25 +766,25 @@ Feature: Prune Properties rule
order by degree, name, age limit 5;
"""
Then the result should be, in order, with relax comparison:
| properties(src_v).sex | degree | name | age | e[1].start_year | dst_v.player.age |
| "男" | 88 | "Aron Baynes" | 41 | 2013 | 32 |
| "男" | 88 | "Boris Diaw" | 41 | 2012 | 36 |
| "男" | 88 | "Cory Joseph" | 41 | 2011 | 27 |
| "男" | 88 | "Danny Green" | 41 | 2010 | 31 |
| "男" | 88 | "David West" | 41 | 2015 | 38 |
| properties(src_v).sex | properties(e[0]).degree | properties(dst_v).name | age | e[1].start_year | dst_v.player.age |
| "男" | 88 | "Danny Green" | 41 | 2010 | 31 |
| "男" | UNKNOWN_PROP | "Danny Green" | 41 | 2022 | 31 |
| "男" | UNKNOWN_PROP | "LeBron James" | 41 | 2022 | 34 |
| "男" | 88 | "Cory Joseph" | 41 | 2011 | 27 |
| "男" | UNKNOWN_PROP | "76ers" | 41 | 2017 | NULL |
When executing query:
"""
match (src_v:player{name:"Manu Ginobili"})-[e:like*2..3]-(dst_v)
return distinct properties(src_v).sex,properties(e[0]).degree as degree,properties(dst_v).name as name,src_v.player.age AS age, e[1].start_year,dst_v.player.age
order by degree, name, age limit 5;
"""
Then the result should be, in order, with relax comparison:
| properties(src_v).sex | degree | name | age | e[1].start_year | dst_v.player.age |
| "男" | UNKNOWN_PROP | "Aron Baynes" | 41 | 2022 | 32 |
| "男" | UNKNOWN_PROP | "Blake Griffin" | 41 | 2022 | 30 |
| "男" | UNKNOWN_PROP | "Boris Diaw" | 41 | 2022 | 36 |
| "男" | UNKNOWN_PROP | "Carmelo Anthony" | 41 | 2022 | 34 |
| "男" | UNKNOWN_PROP | "Chris Paul" | 41 | 2022 | 33 |
| properties(src_v).sex | properties(e[0]).degree | properties(dst_v).name | age | e[1].start_year | dst_v.player.age |
| "男" | UNKNOWN_PROP | "Danny Green" | 41 | 2022 | 31 |
| "男" | UNKNOWN_PROP | "Danny Green" | 41 | 2022 | 31 |
| "男" | UNKNOWN_PROP | "Kyle Anderson" | 41 | 2022 | 25 |
| "男" | UNKNOWN_PROP | "LeBron James" | 41 | 2022 | 34 |
| "男" | UNKNOWN_PROP | "Kevin Durant" | 41 | 2022 | 30 |
When executing query:
"""
match (v1)-->(v2)-->(v3) where id(v1)=="Manu Ginobili"
Expand Down Expand Up @@ -848,12 +848,12 @@ Feature: Prune Properties rule
order by degree, degree1 limit 5;
"""
Then the result should be, in order, with relax comparison:
| degree | degree1 |
| 88 | 88 |
| 88 | 88 |
| 88 | 88 |
| 88 | 88 |
| 88 | 88 |
| properties(e).degree | degree |
| 88 | 88 |
| UNKNOWN_PROP | 88 |
| 88 | 88 |
| UNKNOWN_PROP | 88 |
| 88 | 88 |
When executing query:
"""
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;
Expand Down

0 comments on commit ca0f0ce

Please sign in to comment.