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

Support subscript in update. #5457

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion src/common/function/FunctionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,6 @@ FunctionManager::FunctionManager() {
if (args[0].get().isStr()) {
auto result = time::TimeUtils::parseTime(args[0].get().getStr());
if (!result.ok()) {
DLOG(ERROR) << "DEBUG POINT: " << result.status();
return Value::kNullBadData;
}
if (result.value().withTimeZone) {
Expand Down
1 change: 0 additions & 1 deletion src/graph/validator/MutateValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,6 @@ Expression *UpdateValidator::rewriteSymExpr(Expression *expr,
Expression::Kind::kVarProperty,
Expression::Kind::kInputProperty,
// Expression::Kind::kLabelAttribute, valid only for update edge
Expression::Kind::kSubscript,
Expression::Kind::kUUID,
Expression::Kind::kTagProperty,
Expression::Kind::kLabelTagProperty,
Expand Down
15 changes: 14 additions & 1 deletion src/storage/query/QueryBaseProcessor-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* This source code is licensed under Apache 2.0 License.
*/

#include "common/expression/SubscriptExpression.h"

namespace nebula {
namespace storage {

Expand Down Expand Up @@ -603,8 +605,19 @@ nebula::cpp2::ErrorCode QueryBaseProcessor<REQ, RESP>::checkExp(
}
return nebula::cpp2::ErrorCode::SUCCEEDED;
}
case Expression::Kind::kSubscript: {
auto sbExpr = static_cast<const SubscriptExpression*>(exp);
auto ret = checkExp(sbExpr->left(), returned, filtered, updated, allowNoexistentProp);
if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) {
return ret;
}
ret = checkExp(sbExpr->right(), returned, filtered, updated, allowNoexistentProp);
if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) {
return ret;
}
return nebula::cpp2::ErrorCode::SUCCEEDED;
}
case Expression::Kind::kInputProperty:
case Expression::Kind::kSubscript:
case Expression::Kind::kLabelTagProperty:
case Expression::Kind::kLabelAttribute:
case Expression::Kind::kVertex:
Expand Down
50 changes: 50 additions & 0 deletions tests/tck/features/bugfix/SubscriptInUpdate.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (c) 2023 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: Test subscript in update

# #5445
Scenario: Subscript in update
Given an empty graph
And create a space with following options:
| partition_num | 1 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(30) |
| charset | utf8 |
| collate | utf8_bin |
When executing query:
"""
create tag test_tag(i1 int, json string);
create edge test_edge(i1 int, json string);
"""
Then the execution should be successful
When try to execute query:
"""
INSERT VERTEX test_tag(i1, json) VALUES 'xxx':(1, '{"a":1,"b":2}');
"""
Then the execution should be successful
When try to execute query:
"""
UPDATE VERTEX ON test_tag 'xxx'
SET i1=json_extract(json)['b']
WHEN json_extract(json)['a'] == 1
YIELD i1;
"""
Then the result should be, in any order:
| i1 |
| 2 |
When try to execute query:
"""
INSERT EDGE test_edge(i1, json) VALUES 'xxx'->'xxx':(1, '{"a":1,"b":2}');
"""
Then the execution should be successful
When try to execute query:
"""
UPDATE EDGE ON test_edge 'xxx'->'xxx'
SET i1=json_extract(json)['b']
WHEN json_extract(json)['a'] == 1
YIELD i1;
"""
Then the result should be, in any order:
| i1 |
| 2 |