Skip to content

Commit

Permalink
fix union bug (#5674)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 authored Aug 16, 2023
1 parent d0086dd commit 18813f3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/graph/validator/SetValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,29 @@ Status SetValidator::toPlan() {
tail_ = lValidator_->tail();
return Status::OK();
}
removeStartNode(lValidator_.get());
removeStartNode(rValidator_.get());
tail_ = PassThroughNode::make(qctx_, nullptr);
NG_RETURN_IF_ERROR(lValidator_->appendPlan(tail_));
NG_RETURN_IF_ERROR(rValidator_->appendPlan(tail_));
return Status::OK();
}

void SetValidator::removeStartNode(Validator* validator) {
if (validator->tail()->kind() != PlanNode::Kind::kStart) {
return;
}

PlanNode* node = validator->root();
while (node->dependencies()[0]->dependencies().size() > 0UL) {
node = const_cast<PlanNode*>(node->dependencies()[0]);
}
if (node->dependencies().size() == 1UL) {
// Remain one size for add dependency
node->dependencies()[0] = nullptr;
validator->setTail(node);
}
}

} // namespace graph
} // namespace nebula
2 changes: 2 additions & 0 deletions src/graph/validator/SetValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class SetValidator final : public Validator {
*/
Status toPlan() override;

void removeStartNode(Validator* validator);

private:
std::unique_ptr<Validator> lValidator_;
std::unique_ptr<Validator> rValidator_;
Expand Down
10 changes: 10 additions & 0 deletions tests/tck/features/set/Set.feature
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ Feature: Set Test
| "Manu Ginobili" | 2002 | "Spurs" |
| "Tony Parker" | 1999 | "Spurs" |
| "Tony Parker" | 2018 | "Hornets" |
When executing query:
"""
fetch prop on player 'Tony Parker' yield player.age AS age
UNION
go from 'Tim Duncan' over like yield $$.player.age AS age
"""
Then the result should be, in any order:
| age |
| 36 |
| 41 |

Scenario: Minus
Given a graph with space named "nba"
Expand Down

0 comments on commit 18813f3

Please sign in to comment.