Skip to content

Commit

Permalink
RC4 Cherrypick #2031 #2042 #2025 #2013 #2038 (#2051)
Browse files Browse the repository at this point in the history
* remove bigint because we dont support it (#2031)

Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
(cherry picked from commit 3423df1)

* fix crash (#2042)

Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
(cherry picked from commit eea7407)

* Sampling apply to all edges starting from a vertex. (#2013)

* Sampling from all edges.

* Update test for sampling multi edges.

* Testing both inbound and outbound.

* Fix clang compiling problem.

* Update the sampling.

Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
(cherry picked from commit 8810ecc)

* Fix the error when vertex/edge not exist if update. (#2025)

* Fix the error when vertex/edge not exist if update.

* Optimize the atomic error logical.

* Fix one alignment.

Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
(cherry picked from commit 9fc4e7f)

* Correct issue 2009 which the timestamp default value for edge not treat. (#2038)

* Correct issue 2009 which the timestamp default value for edge not treat.

* Add the cover cases.

* Fix one typo.

Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
(cherry picked from commit 4aa9217)

Co-authored-by: flyingcat <1004815462@qq.com>
Co-authored-by: laura-ding <48548375+laura-ding@users.noreply.github.com>
Co-authored-by: CPWstatic <13495049+CPWstatic@users.noreply.github.com>
Co-authored-by: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com>
  • Loading branch information
5 people authored Apr 2, 2020
1 parent 2ea95f3 commit d7422b6
Show file tree
Hide file tree
Showing 25 changed files with 270 additions and 161 deletions.
1 change: 0 additions & 1 deletion .linters/cpp/checkKeyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
'KW_INDEXES',
'KW_REBUILD',
'KW_INT',
'KW_BIGINT',
'KW_DOUBLE',
'KW_STRING',
'KW_BOOL',
Expand Down
4 changes: 0 additions & 4 deletions src/common/filter/Expressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,6 @@ std::string columnTypeToString(ColumnType type) {
return "string";
case ColumnType::DOUBLE:
return "double";
case ColumnType::BIGINT:
return "bigint";
case ColumnType::BOOL:
return "bool";
case ColumnType::TIMESTAMP:
Expand Down Expand Up @@ -656,8 +654,6 @@ OptVariantType TypeCastingExpression::eval(Getters &getters) const {
return Expression::toDouble(result.value());
case ColumnType::BOOL:
return Expression::toBool(result.value());
case ColumnType::BIGINT:
return Status::Error("Type bigint not supported yet");
}
LOG(FATAL) << "casting to unknown type: " << static_cast<int>(type_);
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/filter/Expressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Cord;
using OptVariantType = StatusOr<VariantType>;

enum class ColumnType {
INT, STRING, DOUBLE, BIGINT, BOOL, TIMESTAMP,
INT, STRING, DOUBLE, BOOL, TIMESTAMP,
};

std::string columnTypeToString(ColumnType type);
Expand Down
2 changes: 1 addition & 1 deletion src/graph/TraverseExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ nebula::cpp2::SupportedType TraverseExecutor::calculateExprType(Expression* exp)
case Expression::kInputProp: {
auto* propExp = static_cast<const AliasPropertyExpression*>(exp);
const auto* propName = propExp->prop();
if (inputs_ == nullptr) {
if (inputs_ == nullptr || !inputs_->hasData()) {
return nebula::cpp2::SupportedType::UNKNOWN;
} else {
return inputs_->getColumnType(*propName);
Expand Down
2 changes: 1 addition & 1 deletion src/graph/UpdateEdgeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void UpdateEdgeExecutor::updateEdge(bool reversely) {
return;
default:
std::string errMsg =
folly::stringPrintf("Maybe edge does not exist or filter failed, "
folly::stringPrintf("Maybe edge does not exist, "
"part: %d, error code: %d!",
code.get_part_id(),
static_cast<int32_t>(code.get_code()));
Expand Down
2 changes: 1 addition & 1 deletion src/graph/UpdateVertexExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void UpdateVertexExecutor::execute() {
break;
default:
std::string errMsg =
folly::stringPrintf("Maybe vertex does not exist or filter failed, "
folly::stringPrintf("Maybe vertex does not exist, "
"part: %d, error code: %d!",
code.get_part_id(),
static_cast<int32_t>(code.get_code()));
Expand Down
12 changes: 12 additions & 0 deletions src/graph/test/FetchVerticesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,5 +422,17 @@ TEST_F(FetchVerticesTest, NonexistentProp) {
ASSERT_EQ(cpp2::ErrorCode::E_EXECUTION_ERROR, code);
}
}

TEST_F(FetchVerticesTest, EmptyInput) {
// YIELD has input prop, and input is empty
{
cpp2::ExecutionResponse resp;
auto query = "GO FROM 11 over like YIELD like._dst as id "
"| FETCH PROP ON player 11 YIELD $-.id";
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::E_SYNTAX_ERROR, code);
}
}

} // namespace graph
} // namespace nebula
29 changes: 29 additions & 0 deletions src/graph/test/SchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,5 +1090,34 @@ TEST_F(SchemaTest, TestTagAndEdge) {
LOG(FATAL) << "Space still exists after sleep " << retry << " seconds";
}

TEST_F(SchemaTest, issue2009) {
auto client = gEnv->getClient();
ASSERT_NE(nullptr, client);
{
cpp2::ExecutionResponse resp;
std::string query = "CREATE SPACE issue2009; USE issue2009";
auto code = client->execute(query, resp);
ASSERT_EQ(code, cpp2::ErrorCode::SUCCEEDED);
}
{
cpp2::ExecutionResponse resp;
std::string query = "CREATE EDGE IF NOT EXISTS relation"
"(intimacy int default 0, "
"isReversible bool default false, "
"name string default \"N/A\", "
"startTime timestamp default 0)";
auto code = client->execute(query, resp);
ASSERT_EQ(code, cpp2::ErrorCode::SUCCEEDED);
}
::sleep(FLAGS_heartbeat_interval_secs + 1);
{
cpp2::ExecutionResponse resp;
std::string query = "INSERT EDGE relation (intimacy) VALUES "
"hash(\"person.Tom\") -> hash(\"person.Marry\")@0:(3)";
auto code = client->execute(query, resp);
ASSERT_EQ(code, cpp2::ErrorCode::SUCCEEDED);
}
}

} // namespace graph
} // namespace nebula
15 changes: 14 additions & 1 deletion src/meta/processors/schemaMan/CreateEdgeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,21 @@ void CreateEdgeProcessor::process(const cpp2::CreateEdgeReq& req) {
}
defaultValue = value->get_string_value();
break;
default:
case nebula::cpp2::SupportedType::TIMESTAMP:
if (value->getType() != nebula::cpp2::Value::Type::timestamp) {
LOG(ERROR) << "Create Edge Failed: " << name
<< " type mismatch";
handleErrorCode(cpp2::ErrorCode::E_CONFLICT);
onFinished();
return;
}
defaultValue = folly::to<std::string>(value->get_timestamp());
break;
default:
LOG(ERROR) << "Unknown type " << static_cast<int>(column.get_type().get_type());
handleErrorCode(cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}
VLOG(3) << "Get Edge Default value: Property Name " << name
<< ", Value " << defaultValue;
Expand Down
4 changes: 3 additions & 1 deletion src/meta/processors/schemaMan/CreateTagProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ void CreateTagProcessor::process(const cpp2::CreateTagReq& req) {
defaultValue = folly::to<std::string>(value->get_timestamp());
break;
default:
LOG(ERROR) << "Unsupported type";
LOG(ERROR) << "Unknown type " << static_cast<int>(column.get_type().get_type());
handleErrorCode(cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}

Expand Down
3 changes: 1 addition & 2 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static constexpr size_t MAX_ABS_INTEGER = 9223372036854775808ULL;
%token KW_GO KW_AS KW_TO KW_OR KW_AND KW_XOR KW_USE KW_SET KW_FROM KW_WHERE KW_ALTER
%token KW_MATCH KW_INSERT KW_VALUES KW_YIELD KW_RETURN KW_CREATE KW_VERTEX KW_OFFLINE
%token KW_EDGE KW_EDGES KW_STEPS KW_OVER KW_UPTO KW_REVERSELY KW_SPACE KW_DELETE KW_FIND KW_REBUILD
%token KW_INT KW_BIGINT KW_DOUBLE KW_STRING KW_BOOL KW_TAG KW_TAGS KW_UNION KW_INTERSECT KW_MINUS
%token KW_INT KW_DOUBLE KW_STRING KW_BOOL KW_TAG KW_TAGS KW_UNION KW_INTERSECT KW_MINUS
%token KW_NO KW_OVERWRITE KW_IN KW_DESCRIBE KW_DESC KW_SHOW KW_HOSTS KW_PART KW_PARTS KW_TIMESTAMP KW_ADD
%token KW_PARTITION_NUM KW_REPLICA_FACTOR KW_CHARSET KW_COLLATE KW_COLLATION
%token KW_DROP KW_REMOVE KW_SPACES KW_INGEST KW_INDEX KW_INDEXES
Expand Down Expand Up @@ -484,7 +484,6 @@ type_spec
| KW_DOUBLE { $$ = ColumnType::DOUBLE; }
| KW_STRING { $$ = ColumnType::STRING; }
| KW_BOOL { $$ = ColumnType::BOOL; }
| KW_BIGINT { $$ = ColumnType::BIGINT; }
| KW_TIMESTAMP { $$ = ColumnType::TIMESTAMP; }
;

Expand Down
2 changes: 0 additions & 2 deletions src/parser/scanner.lex
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ INDEXES ([Ii][Nn][Dd][Ee][Xx][Ee][Ss])
REBUILD ([Rr][Ee][Bb][Uu][Ii][Ll][Dd])
STATUS ([Ss][Tt][Aa][Tt][Uu][Ss])
INT ([Ii][Nn][Tt])
BIGINT ([Bb][Ii][Gg][Ii][Nn][Tt])
DOUBLE ([Dd][Oo][Uu][Bb][Ll][Ee])
STRING ([Ss][Tt][Rr][Ii][Nn][Gg])
BOOL ([Bb][Oo][Oo][Ll])
Expand Down Expand Up @@ -204,7 +203,6 @@ RECOVER ([Rr][Ee][Cc][Oo][Vv][Ee][Rr])
{INDEXES} { return TokenType::KW_INDEXES; }
{REBUILD} { return TokenType::KW_REBUILD; }
{INT} { return TokenType::KW_INT; }
{BIGINT} { return TokenType::KW_BIGINT; }
{DOUBLE} { return TokenType::KW_DOUBLE; }
{STRING} { return TokenType::KW_STRING; }
{BOOL} { return TokenType::KW_BOOL; }
Expand Down
3 changes: 0 additions & 3 deletions src/parser/test/ScannerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ TEST(Scanner, Basic) {
CHECK_SEMANTIC_TYPE("PARTS", TokenType::KW_PARTS),
CHECK_SEMANTIC_TYPE("Parts", TokenType::KW_PARTS),
CHECK_SEMANTIC_TYPE("parts", TokenType::KW_PARTS),
CHECK_SEMANTIC_TYPE("BIGINT", TokenType::KW_BIGINT),
CHECK_SEMANTIC_TYPE("Bigint", TokenType::KW_BIGINT),
CHECK_SEMANTIC_TYPE("bigint", TokenType::KW_BIGINT),
CHECK_SEMANTIC_TYPE("DOUBLE", TokenType::KW_DOUBLE),
CHECK_SEMANTIC_TYPE("double", TokenType::KW_DOUBLE),
CHECK_SEMANTIC_TYPE("STRING", TokenType::KW_STRING),
Expand Down
1 change: 0 additions & 1 deletion src/parser/test/fuzzing/nebula.dict
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ keyword_REVERSELY="REVERSELY"
keyword_SPACE="SPACE"
keyword_SPACES="SPACES"
keyword_INT="INT"
keyword_BIGINT="BIGINT"
keyword_DOUBLE="DOUBLE"
keyword_STRING="STRING"
keyword_BOOL="BOOL"
Expand Down
7 changes: 0 additions & 7 deletions src/storage/CommonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ bool checkDataExpiredForTTL(const meta::SchemaProviderIf* schema,
int64_t ttlDuration);


enum class FilterResult {
SUCCEEDED = 0, // pass filter
E_FILTER_OUT = -1, // filter out
E_ERROR = -2, // exception when filter
E_BAD_SCHEMA = -3, // Bad schema
};


} // namespace storage
} // namespace nebula
Expand Down
56 changes: 17 additions & 39 deletions src/storage/mutate/UpdateEdgeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,23 +328,20 @@ std::string UpdateEdgeProcessor::updateAndWriteBack(PartitionID partId,
}


FilterResult UpdateEdgeProcessor::checkFilter(const PartitionID partId,
const cpp2::EdgeKey& edgeKey) {
cpp2::ErrorCode UpdateEdgeProcessor::checkFilter(const PartitionID partId,
const cpp2::EdgeKey& edgeKey) {
auto ret = collectEdgesProps(partId, edgeKey);
switch (ret) {
case kvstore::ResultCode::SUCCEEDED:
break;
case kvstore::ResultCode::ERR_CORRUPT_DATA:
return FilterResult::E_BAD_SCHEMA;
default:
return FilterResult::E_ERROR;
if (ret == kvstore::ResultCode::ERR_CORRUPT_DATA) {
return cpp2::ErrorCode::E_EDGE_NOT_FOUND;
} else if (ret != kvstore::ResultCode::SUCCEEDED) {
return to(ret);
}
for (auto& tc : this->tagContexts_) {
VLOG(3) << "partId " << partId << ", vId " << edgeKey.src
<< ", tagId " << tc.tagId_ << ", prop size " << tc.props_.size();
ret = collectVertexProps(partId, edgeKey.src, tc.tagId_, tc.props_);
if (ret != kvstore::ResultCode::SUCCEEDED) {
return FilterResult::E_ERROR;
return to(ret);
}
}

Expand Down Expand Up @@ -379,14 +376,14 @@ FilterResult UpdateEdgeProcessor::checkFilter(const PartitionID partId,
auto filterResult = this->exp_->eval(getters);
if (!filterResult.ok()) {
VLOG(1) << "Invalid filter expression";
return FilterResult::E_ERROR;
return cpp2::ErrorCode::E_INVALID_FILTER;
}
if (!Expression::asBool(filterResult.value())) {
VLOG(1) << "Filter skips the update";
return FilterResult::E_FILTER_OUT;
return cpp2::ErrorCode::E_FILTER_OUT;
}
}
return FilterResult::SUCCEEDED;
return cpp2::ErrorCode::SUCCEEDED;
}


Expand Down Expand Up @@ -488,18 +485,11 @@ void UpdateEdgeProcessor::process(const cpp2::UpdateEdgeRequest& req) {
// TODO(shylock) the AtomicOP can't return various error
// so put it in the processor
filterResult_ = checkFilter(partId, edgeKey);
switch (filterResult_) {
case FilterResult::SUCCEEDED : {
if (filterResult_ == cpp2::ErrorCode::SUCCEEDED) {
return updateAndWriteBack(partId, edgeKey);
}
case FilterResult::E_FILTER_OUT:
// fallthrough
case FilterResult::E_ERROR:
// fallthrough
default: {
} else {
return folly::none;
}
}
},
[this, partId, edgeKey, req] (kvstore::ResultCode code) {
while (true) {
Expand All @@ -518,24 +508,12 @@ void UpdateEdgeProcessor::process(const cpp2::UpdateEdgeRequest& req) {
break;
}
if (code == kvstore::ResultCode::ERR_ATOMIC_OP_FAILED) {
switch (filterResult_) {
case FilterResult::E_FILTER_OUT:
// Filter out
// https://github.com/vesoft-inc/nebula/issues/1888
// Only filter out so we still return the data
onProcessFinished(req.get_return_columns().size());
this->pushResultCode(cpp2::ErrorCode::E_FILTER_OUT, partId);
break;
case FilterResult::E_ERROR:
this->pushResultCode(cpp2::ErrorCode::E_INVALID_FILTER, partId);
break;
case FilterResult::E_BAD_SCHEMA:
this->pushResultCode(cpp2::ErrorCode::E_EDGE_NOT_FOUND, partId);
break;
default:
this->pushResultCode(to(code), partId);
break;
// https://github.com/vesoft-inc/nebula/issues/1888
// Only filter out so we still return the data
if (filterResult_ == cpp2::ErrorCode::E_FILTER_OUT) {
onProcessFinished(req.get_return_columns().size());
}
this->pushResultCode(filterResult_, partId);
} else {
this->pushResultCode(to(code), partId);
}
Expand Down
4 changes: 2 additions & 2 deletions src/storage/mutate/UpdateEdgeProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UpdateEdgeProcessor
kvstore::ResultCode collectEdgesProps(const PartitionID partId,
const cpp2::EdgeKey& edgeKey);

FilterResult checkFilter(const PartitionID partId, const cpp2::EdgeKey& edgeKey);
cpp2::ErrorCode checkFilter(const PartitionID partId, const cpp2::EdgeKey& edgeKey);

std::string updateAndWriteBack(PartitionID partId, const cpp2::EdgeKey& edgeKey);

Expand All @@ -68,7 +68,7 @@ class UpdateEdgeProcessor
std::unique_ptr<RowUpdater> updater_;
meta::IndexManager* indexMan_{nullptr};
std::vector<std::shared_ptr<nebula::cpp2::IndexItem>> indexes_;
std::atomic<FilterResult> filterResult_{FilterResult::E_ERROR};
std::atomic<cpp2::ErrorCode> filterResult_{cpp2::ErrorCode::SUCCEEDED};
};

} // namespace storage
Expand Down
Loading

0 comments on commit d7422b6

Please sign in to comment.