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

Fix wrong output when using pattern expression as the filter in MATCH #4788

Merged
merged 3 commits into from
Oct 27, 2022

Conversation

Aiee
Copy link
Contributor

@Aiee Aiee commented Oct 26, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Close #4760

Description:

The roolUp executor produces wrong results.

After fix:

(root@nebula) [nba]> match p = (v:player{name:"Tim Duncan"})-[e]->(t) where not (v)-[]->(t:player) return t
+--------------------------------+
| t                              |
+--------------------------------+
| ("Spurs" :team{name: "Spurs"}) |
+--------------------------------+
Got 1 rows (time spent 22.629ms/23.301331ms)

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

ex. Fixed the bug .....

@Aiee Aiee added ready-for-testing PR: ready for the CI test ready for review cherry-pick-v3.3 PR: need cherry-pick to this version labels Oct 26, 2022
jievince
jievince previously approved these changes Oct 26, 2022
Shylock-Hg
Shylock-Hg previously approved these changes Oct 26, 2022
Copy link
Contributor

@Shylock-Hg Shylock-Hg left a comment

Choose a reason for hiding this comment

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

Good job.

Value val = col->eval(ctx(probeIter));
// Clone the expression so when evaluating the InputPropertyExpression, the propIndex_ will
// not be cached
auto* colCopy = col->clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

The header of input table is fixed, why propIndex_ will be incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example, the column t is the 3rd column in the left iterator and is the 2nd column in the right iterator.

I20221026 16:00:58.585834 2228773 RollUpApplyExecutor.cpp:39] left iter size: 7
I20221026 16:00:58.585844 2228773 RollUpApplyExecutor.cpp:40] left iter value: v|e|t|p|

I20221026 16:00:58.586164 2228773 RollUpApplyExecutor.cpp:42] right iter size: 6
I20221026 16:00:58.586175 2228773 RollUpApplyExecutor.cpp:43] right iter value: v|t|(v)-->(t:player)|

@Shylock-Hg
Copy link
Contributor

build and probe will eval the shared expression object on different input tables.

@Aiee
Copy link
Contributor Author

Aiee commented Oct 26, 2022

build and probe will eval the shared expression object on different input tables.

This is correct, but the propIndex_ is cached in the expression, and the same column name may have a different column index in different input tables.

@Shylock-Hg
Copy link
Contributor

build and probe will eval the shared expression object on different input tables.

This is correct, but the propIndex_ is cached in the expression, and the same column name may have a different column index in different input tables.

Yes, that's the point of this bug, so don't need to clone expr in each row.

@Aiee Aiee dismissed stale reviews from Shylock-Hg and jievince via fe8d003 October 26, 2022 09:40
@Shylock-Hg
Copy link
Contributor

Shylock-Hg commented Oct 26, 2022

I think you better clone in rollUpApply function.

@Aiee
Copy link
Contributor Author

Aiee commented Oct 26, 2022

I think you better clone in rollUpApply function.

Moved the copy into rollUpApply()

@@ -143,25 +144,33 @@ folly::Future<Status> RollUpApplyExecutor::rollUpApply() {
DataSet result;
mv_ = movable(node()->inputVars()[0]);

if (rollUpApplyNode->compareCols().size() == 0) {
auto compareCols = rollUpApplyNode->compareCols();
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, but this copy is useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove this in another bug fix PR.

Copy link
Contributor

@xtcyclist xtcyclist left a comment

Choose a reason for hiding this comment

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

Looks good.

@xtcyclist xtcyclist merged commit d6a3b9e into vesoft-inc:master Oct 27, 2022
@Aiee Aiee deleted the fix-pattern branch October 27, 2022 02:47
@foesa-yang
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-v3.3 PR: need cherry-pick to this version ready for review ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to filter on path pattern
5 participants