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 bug #1337 from ent #4740

Merged
merged 19 commits into from
Oct 24, 2022
Merged

Fix bug #1337 from ent #4740

merged 19 commits into from
Oct 24, 2022

Conversation

xtcyclist
Copy link
Contributor

@xtcyclist xtcyclist commented Oct 18, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

https://github.com/vesoft-inc/nebula-ent/issues/1337

(root@nebula) [nba]> create tag if not exists t1(name string);
Execution succeeded (time spent 557/783 us)

Mon, 26 Sep 2022 18:38:44 CST

(root@nebula) [nba]> create tag if not exists t2(name string);
Execution succeeded (time spent 564/798 us)

Mon, 26 Sep 2022 18:38:55 CST

(root@nebula) [nba]> insert vertex t1(name) values "kk":("hello");
Execution succeeded (time spent 701/932 us)

Mon, 26 Sep 2022 18:39:04 CST

(root@nebula) [nba]> insert vertex t2(name) values "kk":("world");
Execution succeeded (time spent 1113/1327 us)

Mon, 26 Sep 2022 18:39:11 CST

(root@nebula) [nba]> insert edge like(likeness) values "kk"->"kk"@1:(1)
Execution succeeded (time spent 1082/1288 us)

Mon, 26 Sep 2022 18:39:16 CST

(root@nebula) [nba]> match p = (v{name: "hello"})-->(v1{name: "hello"}) where id(v) == "kk" return p limit 1;
+----------------------------------------------------------------------------------------------------------------------+
| p                                                                                                                    |
+----------------------------------------------------------------------------------------------------------------------+
| <("kk" :t1{name: "hello"} :t2{name: "world"})-[:like@1 {likeness: 1}]->("kk" :t1{name: "hello"} :t2{name: "world"})> |
+----------------------------------------------------------------------------------------------------------------------+
Got 1 rows (time spent 2307/2652 us)

Mon, 26 Sep 2022 18:39:26 CST

(root@nebula) [nba]> match p = (v{name: "hello"})-->(v1{name: "world"}) where id(v) == "kk" return p limit 1;
+---+
| p |
+---+
+---+
Empty set (time spent 5376/6211 us)

Mon, 26 Sep 2022 18:39:31 CST

(root@nebula) [nba]>

Description:

Unexpected results returned by tag-less properties in the match clause.

How do you solve it?

All properties shall have tags. Return a semantic error message when there is none.

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

In addition to report errors on tag-less properties, I also commented out the previous if branch that is responsible for makeNodeSubFilter() for tag-less properties.

I tested other clauses like lookup and go. The vertex.tag.property pattern seems good. Errors are reported if the tag part is ommitted.

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • TCK

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

The enterprise version.

Release notes:

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

ex. Fixed the bug .....

@xtcyclist xtcyclist added the ready-for-testing PR: ready for the CI test label Oct 18, 2022
@Sophie-Xie Sophie-Xie added the cherry-pick-v3.3 PR: need cherry-pick to this version label Oct 18, 2022
@Shylock-Hg
Copy link
Contributor

May need discuss with PD

critical27
critical27 previously approved these changes Oct 20, 2022
@Shylock-Hg
Copy link
Contributor

I think you should delete the syntax in parser too.

@xtcyclist
Copy link
Contributor Author

xtcyclist commented Oct 21, 2022

I think you should delete the syntax in parser too.

match_node
    : L_PAREN match_alias R_PAREN {
        $$ = new MatchNode(*$2, nullptr, nullptr);
        delete $2;
    }
    | L_PAREN match_alias match_node_label_list R_PAREN {
        $$ = new MatchNode(*$2, $3, nullptr);
        delete $2;
    }
//    | L_PAREN match_alias map_expression R_PAREN {
//        $$ = new MatchNode(*$2, nullptr, $3);
//        delete $2;
//    }
    ;

I tried. With the above syntax removed in parser.yy, the error message would become this:

(root@nebula) [nba]> match (v{name:"Boris Johson"}) return v limit 1;
[ERROR (-1004)]: SyntaxError: syntax error near `{name:"B'

I think it's better to report "No tag found for property". That would guide the user to add a tag to a specific property in the query. With only a syntax error, the user may be confused about what exaclty the error is.

@Shylock-Hg

@Shylock-Hg
Copy link
Contributor

I think you should delete the syntax in parser too.

match_node
    : L_PAREN match_alias R_PAREN {
        $$ = new MatchNode(*$2, nullptr, nullptr);
        delete $2;
    }
    | L_PAREN match_alias match_node_label_list R_PAREN {
        $$ = new MatchNode(*$2, $3, nullptr);
        delete $2;
    }
//    | L_PAREN match_alias map_expression R_PAREN {
//        $$ = new MatchNode(*$2, nullptr, $3);
//        delete $2;
//    }
    ;

I tried. With the above syntax removed in parser.yy, the error message would become this:

(root@nebula) [nba]> match (v{name:"Boris Johson"}) return v limit 1;
[ERROR (-1004)]: SyntaxError: syntax error near `{name:"B'

I think it's better to report "No tag found for property". That would guide the user to add a tag to a specific property in the query. With only a syntax error, the user may be confused about what exaclty the error is.

@Shylock-Hg
OK.

@Shylock-Hg Shylock-Hg added the doc affected PR: improvements or additions to documentation label Oct 24, 2022
@@ -192,6 +192,12 @@ Status MatchValidator::buildNodeInfo(const MatchPath *path,
auto alias = node->alias();
auto *props = node->props();
auto anonymous = false;
// if there exists some property with no tag, return a semantic error
if (node->labels() == nullptr && props != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Directly props != nullptr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems ok to remove node->labels() == nullptr. Removed.

"""
MATCH (v{name: "Tim Duncan"}) return v
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not delete test cases. Modify it if the test case behavior changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Relocated this case to a new scenario match_with_wrong_syntax in Base.feature.

@@ -137,7 +137,7 @@ Feature: Basic match
| "serve" | "Cavaliers" |
When executing query:
"""
MATCH (v1:player{name: "LeBron James"}) -[r:serve]-> (v2 {name: "Cavaliers"})
MATCH (v1:player{name: "LeBron James"}) -[r:serve]-> (v2:team{name: "Cavaliers"})
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI. Since all property names must be attached to a tag name, isn't this more intuitive to design the syntax:

MATCH (v1:player{player.name: "LeBron James"}) -[r:serve]-> (v2{team.name: "Cavaliers"})

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 see. This seems like a request for a new alternative for writing match patterns. May need to discuss with PD (and check with GQL standards).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe open an issue on this?

@@ -310,7 +310,7 @@ Feature: Variable length Pattern match (m to n)
Scenario: multi-steps and filter by node properties
When executing query:
"""
MATCH (v:player{name: 'Tim Duncan'})-[e1:like*1..2]-(v2{name: 'Tony Parker'})-[e2:serve]-(v3{name: 'Spurs'})
MATCH (v:player{name: 'Tim Duncan'})-[e1:like*1..2]-(v2:player{name: 'Tony Parker'})-[e2:serve]-(v3:team{name: 'Spurs'})
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix similar issue related to properties(v).tag.name, nodes(p)[0].tag.name, etc.

Copy link
Contributor Author

@xtcyclist xtcyclist Oct 24, 2022

Choose a reason for hiding this comment

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

If I understood what you mean correctly, all tck cases calling the 'properties' function runs as expected for the time being. I didn't find any abnormal case, at least. Let me know if any tck case needs to be updated.

If we want to force all properties returned by this function to report tag information, we probabaly need to check with PD and open a new issue to refactor this function.

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 these tck cases, I added tags into them, otherwise errors would be reported.

Copy link
Contributor

@czpmango czpmango Oct 24, 2022

Choose a reason for hiding this comment

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

Essentially, it's all the same issue, that is, the tag must be specified to get the property.
"all tck cases calling the 'properties' function runs as expected for the time being." just because the test case is not covered the exception scenario.

@Sophie-Xie Sophie-Xie merged commit 0d5d063 into vesoft-inc:master Oct 24, 2022
Sophie-Xie added a commit that referenced this pull request Oct 24, 2022
* Return an semantic error if no tag is found for a property while validating a match.

* Return an semantic error if no tag is found for a property while validating a match.

* Add a tck case for the fixed bug.

* commented out unused codes.

* add tag in tck cases

* fixing tck

* updated tck cases to add missing cases that are supposed to be there.

* Return an semantic error if no tag is found for a property while validating a match.

* Add a tck case for the fixed bug.

* commented out unused codes.

* add tag in tck cases

* fixing tck

* updated tck cases to add missing cases that are supposed to be there.

* update

* update tck case.

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
Shinji-IkariG pushed a commit that referenced this pull request Oct 25, 2022
* Fix/find start error (#4771)

* Fix find start error.

* Fix test.

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>

* Introduce JSON_EXTRACT function (#4743)

* Introduce JSON_EXTRACT function

close: #3513
Note, we don't support the path argument in this phase

* address jievince's review commit

removed the unecessary interface of construct Map from Value

* Type handling

Only primitive types are supported

* Support depth1 nested

* lint: fmt

* ut: ctest, fixed wrong expression of Map

* fix ut errors

* tck: case for json_extract added

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>

* Fix bug #1337 from ent (#4740)

* Return an semantic error if no tag is found for a property while validating a match.

* Return an semantic error if no tag is found for a property while validating a match.

* Add a tck case for the fixed bug.

* commented out unused codes.

* add tag in tck cases

* fixing tck

* updated tck cases to add missing cases that are supposed to be there.

* Return an semantic error if no tag is found for a property while validating a match.

* Add a tck case for the fixed bug.

* commented out unused codes.

* add tag in tck cases

* fixing tck

* updated tck cases to add missing cases that are supposed to be there.

* update

* update tck case.

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>

* Fix RollUpApplyExecutor (#4778)

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>

* Fix mutil-match crash in optimization phase (#4780)

fmt

small fix

small fix

* fix subgraph step (#4776)

* fix subgraph step

* forbid function call in where clause

* fix error

Co-authored-by: shylock <33566796+Shylock-Hg@users.noreply.github.com>
Co-authored-by: Wey Gu <weyl.gu@gmail.com>
Co-authored-by: Cheng Xuntao <7731943+xtcyclist@users.noreply.github.com>
Co-authored-by: Yichen Wang <18348405+Aiee@users.noreply.github.com>
Co-authored-by: kyle.cao <kyle.cao@vesoft.com>
Co-authored-by: jimingquan <mingquan.ji@vesoft.com>
@abby-cyber abby-cyber self-assigned this Jan 18, 2023
@abby-cyber
Copy link
Contributor

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 doc affected PR: improvements or additions to documentation 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.

None yet

6 participants