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 expression rewrite #3614

Merged
merged 13 commits into from
Jan 11, 2022
Merged

Fix expression rewrite #3614

merged 13 commits into from
Jan 11, 2022

Conversation

Aiee
Copy link
Contributor

@Aiee Aiee commented Dec 31, 2021

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem does this PR solve?

Issue(s) number:
Fix #3248

Description:
This PR fixes filterTransform() and adds cases.

How do you slove it?

  1. Do not transfer the filter expression if it contains 2 different tagProp expressions i.e. v.player.name =="abc" && v.player.age == 30
  2. Fix expression overflow check. Do not rewrite the expression if it would cause an overflow.
  3. Refactor rewriteRelExpr()
  4. Return semantic error when the non-addition arithmetic expression contains strings.

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

(root@nebula) [nba]> match (v:player) where v.player.name+'n'=="Tim Duncann" return v
+-----------------------------------------------------+
| v                                                   |
+-----------------------------------------------------+
| ("Tim Duncan" :player{age: 42, name: "Tim Duncan"}) |
+-----------------------------------------------------+
Got 1 rows (time spent 5509/5861 us)

Fri, 31 Dec 2021 22:51:01 CST

(root@nebula) [NBA]> match (v:player) where v.player.name-'n'=="Tim Duncann" return v
`(v.player.name-"n")' is not a valid expression, can not apply `-' to `__EMPTY__' and `STRING'.

Fri, 31 Dec 2021 22:51:08 CST

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Perfomance 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 type/bug Type: something is unexpected wip Solution: work in progress and removed wip Solution: work in progress labels Dec 31, 2021
@Sophie-Xie Sophie-Xie added the cherry-pick-v3.0 PR: need cherry-pick to this version label Jan 4, 2022
src/graph/util/ExpressionUtils.cpp Outdated Show resolved Hide resolved
src/graph/util/ExpressionUtils.cpp Outdated Show resolved Hide resolved
src/graph/util/ExpressionUtils.cpp Show resolved Hide resolved
@Aiee Aiee force-pushed the fix-filter-expr branch from 9f86ed7 to 8942631 Compare January 4, 2022 08:21
@Aiee Aiee requested review from Shylock-Hg and czpmango January 4, 2022 09:25
@Aiee Aiee force-pushed the fix-filter-expr branch 3 times, most recently from dc327b5 to 6b1f478 Compare January 6, 2022 04:46
@Aiee Aiee requested a review from nevermore3 January 6, 2022 06:05
nevermore3
nevermore3 previously approved these changes Jan 6, 2022
@@ -84,8 +84,9 @@
# System memory high watermark ratio, cancel the memory checking when the ratio greater than 1.0
--system_memory_high_watermark_ratio=0.8

########## metrics ##########
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to do it in separate PR, don't modify unrelated code.

Copy link
Contributor

Choose a reason for hiding this comment

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

emm, just a format change

Comment on lines +423 to +424
auto lExpr = const_cast<Expression *>(arithmExpr->left());
auto rExpr = const_cast<Expression *>(arithmExpr->right());
Copy link
Contributor

Choose a reason for hiding this comment

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

For constant expression, you could call its method value() directly, so that you don't need to call const_cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we are still not sure about the type of arithmExpr->left() and arithmExpr->right()

Copy link
Contributor

@CPWstatic CPWstatic left a comment

Choose a reason for hiding this comment

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

Do we fix the bug that i meet in ldbc test cases?

        WHERE toInteger(message1.creationDate)/10000000000000   == year1
          AND toInteger(message1.creationDate)/100000000000%100 == month1

@Aiee
Copy link
Contributor Author

Aiee commented Jan 11, 2022

Do we fix the bug that i meet in ldbc test cases?

        WHERE toInteger(message1.creationDate)/10000000000000   == year1
          AND toInteger(message1.creationDate)/100000000000%100 == month1

Yes the case you mentioned earlier has been fixed:

(root@nebula) [nba]> MATCH (v:player) WHERE toInteger(v.player.age)/10000000000000 == 10 AND toInteger(v.player.age)/10000000000000%100 == 1100000 RETURN v
+---+
| v |
+---+
+---+
Empty set (time spent 10065/10403 us)

@Aiee Aiee requested review from CPWstatic and jievince January 11, 2022 03:41
Copy link
Contributor

@CPWstatic CPWstatic left a comment

Choose a reason for hiding this comment

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

LGTM.

src/graph/util/ExpressionUtils.cpp Outdated Show resolved Hide resolved
src/graph/util/ExpressionUtils.cpp Outdated Show resolved Hide resolved
@Aiee Aiee requested a review from CPWstatic January 11, 2022 06:24
"""
MATCH (v:player) WHERE v.player.name-'n'=="Tim Duncann" RETURN v
"""
Then a SemanticError should be raised at runtime: `(v.player.name-"n")' is not a valid expression, can not apply `-' to `__EMPTY__' and `STRING'.
Copy link
Contributor

Choose a reason for hiding this comment

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

This error message is confusing. Where is the __EMPTY__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error message will try to evaluate the expression and print its type in the message. This is to unify the error messages we currently using.

@CPWstatic CPWstatic merged commit 32394f4 into vesoft-inc:master Jan 11, 2022
@Aiee Aiee deleted the fix-filter-expr branch January 11, 2022 09:17
Sophie-Xie pushed a commit that referenced this pull request Jan 15, 2022
* Do not transfer the filter expression if it contains 2 lableAttribute exprs

* Fix expression overflow check

* Fix rewriteRelExpr

* Refactor rewriteRelExpr

* Fix log usage

* Check whether the minus expression contains string

* Add tck cases

* Address comments

* Fix conflicts

* Address comments

* modify metrics in conf files

* Address comments
CPWstatic added a commit that referenced this pull request Jan 17, 2022
* add LogMonitor to check log disk freeBytes and change log level when space is almost full (#3576)

* add LogMonitor to check the log disk is full

* fix comments

* add comments for default flags

Co-authored-by: yaphet <4414314+darionyaphet@users.noreply.github.com>

* Ldbc test cases. (#3537)

* Add ldbc test/

* Add all cases.

* Fix some test cases.

* Fix ldbc cases.

* Fix pytest.

Co-authored-by: Yee <2520865+yixinglu@users.noreply.github.com>

* fix issue 3675 (#3678)

* Fix expression rewrite (#3614)

* Do not transfer the filter expression if it contains 2 lableAttribute exprs

* Fix expression overflow check

* Fix rewriteRelExpr

* Refactor rewriteRelExpr

* Fix log usage

* Check whether the minus expression contains string

* Add tck cases

* Address comments

* Fix conflicts

* Address comments

* modify metrics in conf files

* Address comments

* fix divide zone should be failed if two zones use the same host (#3699)

* Support more check about merge zone arguments (#3703)

* fix match index (#3694)

* check scheam

* add test case

* fix graph crash

* address comment'
'

* add test case

* fix error

* fix vid select error

* fix unit test error

* address comment

* fix issue 3601 (#3666)

Co-authored-by: Nivras <12605142+Nivras@users.noreply.github.com>
Co-authored-by: yaphet <4414314+darionyaphet@users.noreply.github.com>
Co-authored-by: cpw <13495049+CPWstatic@users.noreply.github.com>
Co-authored-by: Yee <2520865+yixinglu@users.noreply.github.com>
Co-authored-by: Yichen Wang <18348405+Aiee@users.noreply.github.com>
Co-authored-by: jimingquan <mingquan.ji@vesoft.com>
Co-authored-by: hs.zhang <22708345+cangfengzhs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-v3.0 PR: need cherry-pick to this version ready for review ready-for-testing PR: ready for the CI test type/bug Type: something is unexpected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected result of match statement with addition of string type
7 participants