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

Disable the bidirection edges. #3507

Merged
merged 7 commits into from
Dec 27, 2021
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
15 changes: 15 additions & 0 deletions src/graph/optimizer/rule/GetEdgesTransformRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ StatusOr<OptRule::TransformResult> GetEdgesTransformRule::transform(
OptGroupNode::create(ctx, newAppendVertices, appendVerticesGroupNode->group());

auto *newScanEdges = traverseToScanEdges(traverse);
if (newScanEdges == nullptr) {
return TransformResult::noTransform();
}
auto newScanEdgesGroup = OptGroup::create(ctx);
auto newScanEdgesGroupNode = newScanEdgesGroup->makeGroupNode(newScanEdges);

Expand Down Expand Up @@ -102,6 +105,18 @@ std::string GetEdgesTransformRule::toString() const {
/*static*/ graph::ScanEdges *GetEdgesTransformRule::traverseToScanEdges(
const graph::Traverse *traverse) {
const auto *edgeProps = traverse->edgeProps();
if (edgeProps == nullptr) {
return nullptr;
}
for (std::size_t i = 0; i < edgeProps->size(); i++) {
auto type = (*edgeProps)[i].get_type();
for (std::size_t j = i + 1; j < edgeProps->size(); j++) {
if (type == -((*edgeProps)[j].get_type())) {
// Don't support to retrieve edges of the inbound/outbound together
return nullptr;
}
}
}
auto scanEdges = ScanEdges::make(
traverse->qctx(),
nullptr,
Expand Down
14 changes: 14 additions & 0 deletions tests/tck/features/match/Scan.feature
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,17 @@ Feature: Match seek by scan
LIMIT 3
"""
Then a ExecutionError should be raised at runtime: Scan vertices must specify limit number.
When executing query:
"""
MATCH ()-[e:is_teacher]-()
RETURN type(e) AS Type, e.start_year AS StartYear, e.end_year AS EndYear
LIMIT 3
"""
Then a ExecutionError should be raised at runtime: Scan vertices must specify limit number.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error msg really confuses me. What's the correct way to write this sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MATCH ()-[e:is_teacher]->()
      RETURN type(e) AS Type, e.start_year AS StartYear, e.end_year AS EndYear
      LIMIT 3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't allow the bidirection.

When executing query:
"""
MATCH ()-[e]-()
RETURN type(e) AS Type, e.start_year AS StartYear, e.end_year AS EndYear
LIMIT 3
"""
Then a ExecutionError should be raised at runtime: Scan vertices must specify limit number.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confused to throw the scan vertices error, It's obviously scan edge in the query.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plan start from ScanVertices, and transformed to ScanEdges in optimizer, but in this case transform failed, so result in ScanVertices failed.