Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick v3.4.1 (from release 3.4.0 to 03.05) #5387

Merged
merged 6 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/common/function/FunctionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2040,8 +2040,11 @@ FunctionManager::FunctionManager() {
return v.vid;
}
case Value::Type::LIST: {
const auto &listVal = args[0].get().getList();
auto &lastVal = listVal.values.back();
const auto &listVal = args[0].get().getList().values;
if (listVal.empty()) {
return Value::kNullBadType;
}
auto &lastVal = listVal.back();
if (lastVal.isEdge()) {
return lastVal.getEdge().dst;
} else if (lastVal.isVertex()) {
Expand Down Expand Up @@ -2134,7 +2137,8 @@ FunctionManager::FunctionManager() {
return Value::kNullValue;
}
case Value::Type::LIST: {
return args[0].get().getList().values.front();
const auto &items = args[0].get().getList().values;
return items.empty() ? Value::kNullValue : items.front();
}
default: {
return Value::kNullBadType;
Expand All @@ -2153,7 +2157,8 @@ FunctionManager::FunctionManager() {
return Value::kNullValue;
}
case Value::Type::LIST: {
return args[0].get().getList().values.back();
const auto &items = args[0].get().getList().values;
return items.empty() ? Value::kNullValue : items.back();
}
default: {
return Value::kNullBadType;
Expand Down
3 changes: 3 additions & 0 deletions src/graph/validator/LookupValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ Status LookupValidator::validateWhere() {
}

auto* filter = whereClause->filter();
if (filter != nullptr) {
filter = graph::ExpressionUtils::rewriteParameter(filter, qctx_);
}
if (FTIndexUtils::needTextSearch(filter)) {
lookupCtx_->isFulltextIndex = true;
lookupCtx_->fulltextExpr = filter;
Expand Down
4 changes: 1 addition & 3 deletions src/storage/ExprVisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ void ExprVisitorBase::visit(SubscriptExpression *expr) {
expr->left()->accept(this);
expr->right()->accept(this);
}
void ExprVisitorBase::visit(AttributeExpression *expr) {
fatal(expr);
}
void ExprVisitorBase::visit(AttributeExpression *) {}
void ExprVisitorBase::visit(LogicalExpression *expr) {
for (auto operand : expr->operands()) {
operand->accept(this);
Expand Down
20 changes: 18 additions & 2 deletions tests/tck/features/yield/parameter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
Feature: Parameter

Background:
Given a graph with space named "nba"
Given an empty graph
And load "nba" csv data to a new space
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"]}

Scenario: [param-test-001] without define param
Expand Down Expand Up @@ -253,7 +254,7 @@ Feature: Parameter
"""
LOOKUP ON player WHERE player.age>$p2+43
"""
Then a SemanticError should be raised at runtime: Column type error : age
Then a SemanticError should be raised at runtime: Type error `(true+43)'
When executing query:
"""
MATCH (v:player) RETURN v LIMIT $p6
Expand Down Expand Up @@ -330,3 +331,18 @@ Feature: Parameter
| v |
| BAD_TYPE |
| BAD_TYPE |
When executing query:
"""
$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
"""
Then the execution should be successful
When executing query:
"""
$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
"""
Then the execution should be successful
When executing query:
"""
$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
"""
Then the execution should be successful
12 changes: 12 additions & 0 deletions tests/tck/features/yield/return.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ Feature: Return. A standalone return sentence is actually a yield sentence
Then the result should be, in any order:
| sum |
| 2 |
When executing query:
"""
RETURN last(LIST[]) AS a, head(LIST[]) AS b
"""
Then the result should be, in any order:
| a | b |
| NULL | NULL |
When executing query:
"""
MATCH (v:player) RETURN none_direct_dst(LIST[]) AS a
"""
Then a SemanticError should be raised at runtime:`none_direct_dst([])' is not a valid expression : Function `none_direct_dst' not defined
When executing query:
"""
RETURN DISTINCT 1+1, '1+1', (int)3.14, (string)(1+1), (string)true
Expand Down