From ca0f0cee8baff98ee0bd771920435f42b23c6ac6 Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Thu, 29 Dec 2022 11:11:54 +0800 Subject: [PATCH] return plain null values if tag or prop does not exist. --- src/common/expression/AttributeExpression.cpp | 4 +++ .../optimizer/PrunePropertiesRule.feature | 36 +++++++++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/common/expression/AttributeExpression.cpp b/src/common/expression/AttributeExpression.cpp index 17736004486..026fce2bb0c 100644 --- a/src/common/expression/AttributeExpression.cpp +++ b/src/common/expression/AttributeExpression.cpp @@ -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; } } diff --git a/tests/tck/features/optimizer/PrunePropertiesRule.feature b/tests/tck/features/optimizer/PrunePropertiesRule.feature index c2f32a43b98..f6e47d5ced9 100644 --- a/tests/tck/features/optimizer/PrunePropertiesRule.feature +++ b/tests/tck/features/optimizer/PrunePropertiesRule.feature @@ -766,12 +766,12 @@ 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) @@ -779,12 +779,12 @@ 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 | - | "男" | 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" @@ -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;