Skip to content

Commit 87f8b0b

Browse files
authored
Move the prepare processing of findpath to execute (#2303)
* Move prepare handle to execute * address Shylock-Hg's comment * modify cppLint
1 parent 8390267 commit 87f8b0b

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

.github/workflows/pull_request.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ jobs:
2020
- uses: actions/checkout@v2
2121
with:
2222
fetch-depth: 1
23-
- uses: jitterbit/get-changed-files@v1
24-
id: diff
2523
- name: Cpplint
2624
run: |
2725
ln -snf $PWD/.linters/cpp/hooks/pre-commit.sh $PWD/.linters/cpp/pre-commit.sh
28-
.linters/cpp/pre-commit.sh ${{ steps.diff.outputs.all }}
26+
.linters/cpp/pre-commit.sh $(git --no-pager diff --diff-filter=d --name-only HEAD^ HEAD)
2927
3028
build:
3129
name: build

src/graph/FindPathExecutor.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ FindPathExecutor::FindPathExecutor(Sentence *sentence, ExecutionContext *exct)
1616
}
1717

1818
Status FindPathExecutor::prepare() {
19+
return Status::OK();
20+
}
21+
22+
Status FindPathExecutor::prepareClauses() {
1923
spaceId_ = ectx()->rctx()->session()->space();
2024
Status status;
2125
expCtx_ = std::make_unique<ExpressionContext>();
@@ -71,6 +75,11 @@ Status FindPathExecutor::beforeExecute() {
7175
break;;
7276
}
7377

78+
status = prepareClauses();
79+
if (!status.ok()) {
80+
break;
81+
}
82+
7483
status = prepareOver();
7584
if (!status.ok()) {
7685
break;

src/graph/FindPathExecutor.h

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class FindPathExecutor final : public TraverseExecutor {
5353
cpp2::RowValue buildPathRow(const Path &path);
5454

5555
private:
56+
Status prepareClauses();
57+
5658
// Do some prepare work that can not do in prepare()
5759
Status beforeExecute();
5860

src/graph/test/FindPathTest.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,25 @@ TEST_F(FindPathTest, UseUUID) {
559559
ASSERT_TRUE(resp.get_rows() != nullptr);
560560
ASSERT_EQ(resp.get_rows()->size(), 1);
561561
}
562+
{
563+
// without use space
564+
auto client = gEnv->getClient();
565+
cpp2::ExecutionResponse resp;
566+
auto query = "FIND SHORTEST PATH FROM UUID(\"Tim Duncan\") TO UUID(\"Tony Parker\") "
567+
"OVER like UPTO 5 STEPS";
568+
auto code = client->execute(query, resp);
569+
ASSERT_EQ(cpp2::ErrorCode::E_EXECUTION_ERROR, code);
570+
ASSERT_EQ("Please choose a graph space with `USE spaceName' firstly",
571+
*(resp.get_error_msg()));
572+
573+
// multi sentences
574+
query = "USE nba; FIND SHORTEST PATH FROM UUID(\"Tim Duncan\") TO UUID(\"Tony Parker\") "
575+
"OVER like UPTO 5 STEPS";
576+
code = client->execute(query, resp);
577+
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code) << *(resp.get_error_msg());
578+
ASSERT_TRUE(resp.get_rows() != nullptr);
579+
ASSERT_EQ(resp.get_rows()->size(), 1);
580+
}
562581
}
563582
} // namespace graph
564583
} // namespace nebula

0 commit comments

Comments
 (0)