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

Unexpected result of match statement with addition of string type #3248

Closed
czpmango opened this issue Nov 2, 2021 · 7 comments · Fixed by #3614
Closed

Unexpected result of match statement with addition of string type #3248

czpmango opened this issue Nov 2, 2021 · 7 comments · Fixed by #3614
Assignees
Labels
type/bug Type: something is unexpected
Milestone

Comments

@czpmango
Copy link
Contributor

czpmango commented Nov 2, 2021

test:

(czp@nebula) [nba]> match (v:player) where v.name+'n'=="Tim Duncann" return v
+---+
| v |
+---+
+---+
Empty set (time spent 18251/19363 us)

(czp@nebula) [nba]> return "Tim Duncan"+'n'
+--------------------+
| ("Tim Duncan"+"n") |
+--------------------+
| "Tim Duncann"      |
+--------------------+
Got 1 rows (time spent 1733/2835 us)

(czp@nebula) [nba]> match (v:player) where v.name-'n'=="Tim Dunca" return v
+-------------------------------------------------------------------------------------------------------------+
| v                                                                                                           |
+-------------------------------------------------------------------------------------------------------------+
| ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) |
+-------------------------------------------------------------------------------------------------------------+
Got 1 rows (time spent 30993/32324 us)

The expected result is an error because the string type does not allow subtraction.

@czpmango czpmango added the type/bug Type: something is unexpected label Nov 2, 2021
@czpmango czpmango assigned czpmango and unassigned czpmango Nov 2, 2021
@Sophie-Xie Sophie-Xie added this to the v3.0.0 milestone Nov 2, 2021
@Shylock-Hg
Copy link
Contributor

Shylock-Hg commented Nov 2, 2021

What's the meaning of string subtraction? I think we should report Semantic Error or evaluate Null.

@cangfengzhs
Copy link
Contributor

I guess when doing expression rewriting or expression folding, rewrite name+'n'=='Tim Ducann' to name='Tim Ducann'-'n', the latter is the calculation of string subtraction, Value does not support this calculation.

@czpmango
Copy link
Contributor Author

czpmango commented Nov 3, 2021

What's the meaning of string subtraction? I think we should report Semantic Error or evaluate Null.

ACK.

@czpmango
Copy link
Contributor Author

czpmango commented Nov 3, 2021

I guess when doing expression rewriting or expression folding, rewrite name+'n'=='Tim Ducann' to name='Tim Ducann'-'n', the latter is the calculation of string subtraction, Value does not support this calculation.

NCK. The subtraction of string type is invalid. We should modify the related index selection logic.

For match (v:player) where v.name+'n'=="Tim Duncann" return v, just do FullTagScan. The addition of string is just
runtime behavior of + expression.
For match (v:player) where v.name-'n'=="Tim Dunca" return v, throw a Semantic error.

@CPWstatic
Copy link
Contributor

I looks fine to me, maybe i don't figure out what you are trying to tell.

v.name+'n'=="TIm Duncann"
equal to ?
v.name=="Tim Duncann"-'n'
v.name-'n'=="Tim Dunca"
euqal to ?
v.name=="Tim Dunca"+'n'

@czpmango
Copy link
Contributor Author

I looks fine to me, maybe i don't figure out what you are trying to tell.

v.name+'n'=="TIm Duncann"
equal to ?
v.name=="Tim Duncann"-'n'
v.name-'n'=="Tim Dunca"
euqal to ?
v.name=="Tim Dunca"+'n'

Just like implementation of std::string, which supports only addition(operator+/operator+=) but not subtraction(operator-) operations.
Indeed, as you say, "Tim Duncan" - 'n' and "Tim Dunca" are equivalent. You can define any addition but can not necessarily define subtraction such as "Tim Duncan" - 'a'.

@czpmango
Copy link
Contributor Author

I guess when doing expression rewriting or expression folding, rewrite name+'n'=='Tim Ducann' to name='Tim Ducann'-'n', the latter is the calculation of string subtraction, Value does not support this calculation.

NCK. The subtraction of string type is invalid. We should modify the related index selection logic.

For match (v:player) where v.name+'n'=="Tim Duncann" return v, just do FullTagScan. The addition of string is just runtime behavior of + expression. For match (v:player) where v.name-'n'=="Tim Dunca" return v, throw a Semantic error.

Fwiw, that is only the testing behavior of Neo4j, which is not specified by cypher standard.

@Shylock-Hg Shylock-Hg linked a pull request Dec 8, 2021 that will close this issue
7 tasks
@Shylock-Hg Shylock-Hg removed a link to a pull request Dec 8, 2021
7 tasks
@czpmango czpmango assigned czpmango and CPWstatic and unassigned CPWstatic Dec 17, 2021
@Sophie-Xie Sophie-Xie assigned Aiee and unassigned czpmango Dec 29, 2021
@Aiee Aiee mentioned this issue Dec 31, 2021
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Type: something is unexpected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants