From 93710986612ca93f246ea0db766e6c1ee1906758 Mon Sep 17 00:00:00 2001 From: Cheng Xuntao <7731943+xtcyclist@users.noreply.github.com> Date: Fri, 30 Dec 2022 20:31:23 +0800 Subject: [PATCH] return plain null values if tag or prop does not exist. (#5151) --- src/common/expression/AttributeExpression.cpp | 4 +++ .../features/expression/Attribute1.feature | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/tck/features/expression/Attribute1.feature 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/expression/Attribute1.feature b/tests/tck/features/expression/Attribute1.feature new file mode 100644 index 00000000000..91b2e459f62 --- /dev/null +++ b/tests/tck/features/expression/Attribute1.feature @@ -0,0 +1,33 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Attribute using test + + Background: + Given load "test" csv data to a new space + + Scenario: Attribute with null data + When executing query: + """ + MATCH p0 = (v0)-[e0]->() + WHERE id(v0) in [1,2,3,4,5,6,7,8,9,10] + UNWIND nodes(p0) AS ua0 + with ua0 + where ua0.Label_5.Label_5_7_Bool + return count(*) + """ + Then the result should be, in any order: + | count(*) | + | 61 | + When executing query: + """ + MATCH p0 = (v0)-[e0]->() + WHERE id(v0) in [1,2,3,4,5,6,7,8,9,10] + UNWIND nodes(p0) AS ua0 + with ua0 + where ua0.Label_5.Label_5_7_Bool == true + return count(*) + """ + Then the result should be, in any order: + | count(*) | + | 61 |