Skip to content

Commit a6dc673

Browse files
Sophie-Xieczpmango
andauthored
Cherry pick v3.4.1 (from release 3.4.0 to 03.05) (#5387)
* Fix the crash when lookup parameter expression eval in storage (#5336) * Small fix for parameter tck (#5371) * Fix crash of list related functions (#5383) * fix coflicts * fix coflicts * fix tck --------- Co-authored-by: kyle.cao <kyle.cao@vesoft.com>
1 parent db3c1b3 commit a6dc673

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

src/common/function/FunctionManager.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,8 +2040,11 @@ FunctionManager::FunctionManager() {
20402040
return v.vid;
20412041
}
20422042
case Value::Type::LIST: {
2043-
const auto &listVal = args[0].get().getList();
2044-
auto &lastVal = listVal.values.back();
2043+
const auto &listVal = args[0].get().getList().values;
2044+
if (listVal.empty()) {
2045+
return Value::kNullBadType;
2046+
}
2047+
auto &lastVal = listVal.back();
20452048
if (lastVal.isEdge()) {
20462049
return lastVal.getEdge().dst;
20472050
} else if (lastVal.isVertex()) {
@@ -2134,7 +2137,8 @@ FunctionManager::FunctionManager() {
21342137
return Value::kNullValue;
21352138
}
21362139
case Value::Type::LIST: {
2137-
return args[0].get().getList().values.front();
2140+
const auto &items = args[0].get().getList().values;
2141+
return items.empty() ? Value::kNullValue : items.front();
21382142
}
21392143
default: {
21402144
return Value::kNullBadType;
@@ -2153,7 +2157,8 @@ FunctionManager::FunctionManager() {
21532157
return Value::kNullValue;
21542158
}
21552159
case Value::Type::LIST: {
2156-
return args[0].get().getList().values.back();
2160+
const auto &items = args[0].get().getList().values;
2161+
return items.empty() ? Value::kNullValue : items.back();
21572162
}
21582163
default: {
21592164
return Value::kNullBadType;

src/graph/validator/LookupValidator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ Status LookupValidator::validateWhere() {
191191
}
192192

193193
auto* filter = whereClause->filter();
194+
if (filter != nullptr) {
195+
filter = graph::ExpressionUtils::rewriteParameter(filter, qctx_);
196+
}
194197
if (FTIndexUtils::needTextSearch(filter)) {
195198
lookupCtx_->isFulltextIndex = true;
196199
lookupCtx_->fulltextExpr = filter;

src/storage/ExprVisitorBase.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ void ExprVisitorBase::visit(SubscriptExpression *expr) {
3333
expr->left()->accept(this);
3434
expr->right()->accept(this);
3535
}
36-
void ExprVisitorBase::visit(AttributeExpression *expr) {
37-
fatal(expr);
38-
}
36+
void ExprVisitorBase::visit(AttributeExpression *) {}
3937
void ExprVisitorBase::visit(LogicalExpression *expr) {
4038
for (auto operand : expr->operands()) {
4139
operand->accept(this);

tests/tck/features/yield/parameter.feature

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
Feature: Parameter
55

66
Background:
7-
Given a graph with space named "nba"
7+
Given an empty graph
8+
And load "nba" csv data to a new space
89
Given parameters: {"p1":1,"p2":true,"p3":"Tim Duncan","p4":3.3,"p5":[1,true,3],"p6":{"a":3,"b":false,"c":"Tim Duncan"},"p7":{"a":{"b":{"c":"Tim Duncan","d":[1,2,3,true,"Tim Duncan"]}}},"p8":"Manu Ginobili", "p9":["Tim Duncan","Tony Parker"]}
910

1011
Scenario: [param-test-001] without define param
@@ -253,7 +254,7 @@ Feature: Parameter
253254
"""
254255
LOOKUP ON player WHERE player.age>$p2+43
255256
"""
256-
Then a SemanticError should be raised at runtime: Column type error : age
257+
Then a SemanticError should be raised at runtime: Type error `(true+43)'
257258
When executing query:
258259
"""
259260
MATCH (v:player) RETURN v LIMIT $p6
@@ -330,3 +331,18 @@ Feature: Parameter
330331
| v |
331332
| BAD_TYPE |
332333
| BAD_TYPE |
334+
When executing query:
335+
"""
336+
$var=lookup on player where player.name==$p6.c and player.age in [43,35,42,45] yield id(vertex) AS VertexID;RETURN count($var.VertexID) AS record
337+
"""
338+
Then the execution should be successful
339+
When executing query:
340+
"""
341+
$var=lookup on player where player.name==$p3 and player.age in [43,35,42,45] yield id(vertex) AS VertexID;RETURN count($var.VertexID) AS record
342+
"""
343+
Then the execution should be successful
344+
When executing query:
345+
"""
346+
$var=lookup on player where player.name==$p7.a.b.d[4] and player.age in [43,35,42,45] yield id(vertex) AS VertexID;RETURN count($var.VertexID) AS record
347+
"""
348+
Then the execution should be successful

tests/tck/features/yield/return.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ Feature: Return. A standalone return sentence is actually a yield sentence
1414
Then the result should be, in any order:
1515
| sum |
1616
| 2 |
17+
When executing query:
18+
"""
19+
RETURN last(LIST[]) AS a, head(LIST[]) AS b
20+
"""
21+
Then the result should be, in any order:
22+
| a | b |
23+
| NULL | NULL |
24+
When executing query:
25+
"""
26+
MATCH (v:player) RETURN none_direct_dst(LIST[]) AS a
27+
"""
28+
Then a SemanticError should be raised at runtime:`none_direct_dst([])' is not a valid expression : Function `none_direct_dst' not defined
1729
When executing query:
1830
"""
1931
RETURN DISTINCT 1+1, '1+1', (int)3.14, (string)(1+1), (string)true

0 commit comments

Comments
 (0)