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

Missing prediccate in standalone optional match #4745

Closed
nebula-bots opened this issue Oct 19, 2022 · 3 comments
Closed

Missing prediccate in standalone optional match #4745

nebula-bots opened this issue Oct 19, 2022 · 3 comments
Assignees
Labels
affects/none PR/issue: this bug affects none version. auto-sync need to discuss Solution: issue or PR without a clear conclusion on whether to handle it process/done Process of bug severity/minor Severity of bug type/bug/compatibility Bugs related to compatibility with other languages like openCypher. type/bug Type: something is unexpected wontfix Solution: this will not be worked on recently
Milestone

Comments

@nebula-bots
Copy link
Contributor

Please check the FAQ documentation before raising an issue

Describe the bug (required)

Your Environments (required)

  • OS: uname -a
  • Compiler: g++ --version or clang++ --version
  • CPU: lscpu
  • Commit id (e.g. a3ffc7d8) 318f10d

How To Reproduce(required)

(root@nebula) [nba]> match (v) where v.player.name == "ggg" return v limit 10;
+---+
| v |
+---+
+---+
Empty set (time spent 2562/2875 us)

Tue, 18 Oct 2022 17:50:20 CST

(root@nebula) [nba]>  optional match (v) where v.player.name == "ggg" return v limit 10;
+---------------------------------------------------------------+
| v                                                             |
+---------------------------------------------------------------+
| ("Dirk Nowitzki" :player{age: 40, name: "Dirk Nowitzki"})     |
| ("Chris Paul" :player{age: 33, name: "Chris Paul"})           |
| ("Dejounte Murray" :player{age: 29, name: "Dejounte Murray"}) |
| ("Grizzlies" :team{name: "Grizzlies"})                        |
| ("Klay Thompson" :player{age: 29, name: "Klay Thompson"})     |
| ("Nuggets" :team{name: "Nuggets"})                            |
| ("Suns" :team{name: "Suns"})                                  |
| ("Bulls" :team{name: "Bulls"})                                |
| ("Kings" :team{name: "Kings"})                                |
| ("Nobody" :player{age: 0, name: "Nobody"})                    |
+---------------------------------------------------------------+
Got 10 rows (time spent 2873/3254 us)

Tue, 18 Oct 2022 17:50:22 CST

(root@nebula) [nba]>
(root@nebula) [nba]> profile match (v) where v.player.name == "ggg" return v limit 10;
+---+
| v |
+---+
+---+
Empty set (time spent 1888/2217 us)

Execution Plan (optimize time 207 us)

-----+----------------+--------------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------
| id | name           | dependencies | profiling data                                      | operator info                                                                                                         |
-----+----------------+--------------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------
| 12 | Project        | 18           | ver: 0, rows: 0, execTime: 3us, totalTime: 4us      | outputVar: {                                                                                                          |
|    |                |              |                                                     |   "colNames": [                                                                                                       |
|    |                |              |                                                     |     "v"                                                                                                               |
|    |                |              |                                                     |   ],                                                                                                                  |
|    |                |              |                                                     |   "type": "DATASET",                                                                                                  |
|    |                |              |                                                     |   "name": "__Limit_8"                                                                                                 |
|    |                |              |                                                     | }                                                                                                                     |
|    |                |              |                                                     | inputVar: __Limit_11                                                                                                  |
|    |                |              |                                                     | columns: [                                                                                                            |
|    |                |              |                                                     |   "$v"                                                                                                                |
|    |                |              |                                                     | ]                                                                                                                     |
-----+----------------+--------------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------
| 18 | Limit          | 19           | ver: 0, rows: 0, execTime: 6us, totalTime: 7us      | outputVar: {                                                                                                          |
|    |                |              |                                                     |   "colNames": [                                                                                                       |
|    |                |              |                                                     |     "v"                                                                                                               |
|    |                |              |                                                     |   ],                                                                                                                  |
|    |                |              |                                                     |   "type": "DATASET",                                                                                                  |
|    |                |              |                                                     |   "name": "__Limit_11"                                                                                                |
|    |                |              |                                                     | }                                                                                                                     |
|    |                |              |                                                     | inputVar: __AppendVertices_19                                                                                         |
|    |                |              |                                                     | offset: 0                                                                                                             |
|    |                |              |                                                     | count: 10                                                                                                             |
-----+----------------+--------------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------
| 19 | AppendVertices | 20           | ver: 0, rows: 0, execTime: 7us, totalTime: 8us      | outputVar: {                                                                                                          |
|    |                |              |                                                     |   "colNames": [                                                                                                       |
|    |                |              |                                                     |     "v"                                                                                                               |
|    |                |              |                                                     |   ],                                                                                                                  |
|    |                |              |                                                     |   "type": "DATASET",                                                                                                  |
|    |                |              |                                                     |   "name": "__AppendVertices_19"                                                                                       |
|    |                |              |                                                     | }                                                                                                                     |
|    |                |              |                                                     | inputVar: __ScanVertices_20                                                                                           |
|    |                |              |                                                     | space: 2                                                                                                              |
|    |                |              |                                                     | dedup: true                                                                                                           |
|    |                |              |                                                     | limit: 10                                                                                                             |
|    |                |              |                                                     | filter:                                                                                                               |
|    |                |              |                                                     | orderBy: []                                                                                                           |
|    |                |              |                                                     | src: $-._vid                                                                                                          |
|    |                |              |                                                     | props: [                                                                                                              |
|    |                |              |                                                     |   {                                                                                                                   |
|    |                |              |                                                     |     "props": [                                                                                                        |
|    |                |              |                                                     |       "name",                                                                                                         |
|    |                |              |                                                     |       "age",                                                                                                          |
|    |                |              |                                                     |       "_tag"                                                                                                          |
|    |                |              |                                                     |     ],                                                                                                                |
|    |                |              |                                                     |     "tagId": 3                                                                                                        |
|    |                |              |                                                     |   },                                                                                                                  |
|    |                |              |                                                     |   {                                                                                                                   |
|    |                |              |                                                     |     "props": [                                                                                                        |
|    |                |              |                                                     |       "name",                                                                                                         |
|    |                |              |                                                     |       "speciality",                                                                                                   |
|    |                |              |                                                     |       "_tag"                                                                                                          |
|    |                |              |                                                     |     ],                                                                                                                |
|    |                |              |                                                     |     "tagId": 5                                                                                                        |
|    |                |              |                                                     |   },                                                                                                                  |
|    |                |              |                                                     |   {                                                                                                                   |
|    |                |              |                                                     |     "props": [                                                                                                        |
|    |                |              |                                                     |       "name",                                                                                                         |
|    |                |              |                                                     |       "_tag"                                                                                                          |
|    |                |              |                                                     |     ],                                                                                                                |
|    |                |              |                                                     |     "tagId": 4                                                                                                        |
|    |                |              |                                                     |   }                                                                                                                   |
|    |                |              |                                                     | ]                                                                                                                     |
|    |                |              |                                                     | exprs:                                                                                                                |
|    |                |              |                                                     | vertex_filter:                                                                                                        |
|    |                |              |                                                     | if_track_previous_path: false                                                                                         |
-----+----------------+--------------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------
| 20 | ScanVertices   | 3            | {                                                   | outputVar: {                                                                                                          |
|    |                |              | ver: 0, rows: 0, execTime: 203us, totalTime: 1331us |   "colNames": [                                                                                                       |
|    |                |              | "store7":9779 exec/total: 285(us)/1034(us)          |     "_vid",                                                                                                           |
|    |                |              | "store4":9779 exec/total: 328(us)/1081(us)          |     "team._tag",                                                                                                      |
|    |                |              | "store1":9779 exec/total: 291(us)/1026(us)          |     "player._tag",                                                                                                    |
|    |                |              | total_rpc: 1298(us)                                 |     "bachelor._tag"                                                                                                   |
|    |                |              | "store5":9779 exec/total: 317(us)/1067(us)          |   ],                                                                                                                  |
|    |                |              | "store6":9779 exec/total: 321(us)/1054(us)          |   "type": "DATASET",                                                                                                  |
|    |                |              | "store3":9779 exec/total: 342(us)/1189(us)          |   "name": "__ScanVertices_20"                                                                                         |
|    |                |              | "store2":9779 exec/total: 344(us)/1137(us)          | }                                                                                                                     |
|    |                |              | }                                                   | inputVar:                                                                                                             |
|    |                |              |                                                     | space: 2                                                                                                              |
|    |                |              |                                                     | dedup: false                                                                                                          |
|    |                |              |                                                     | limit: 10                                                                                                             |
|    |                |              |                                                     | filter: ((player.name=="ggg") AND (team._tag IS NOT EMPTY OR player._tag IS NOT EMPTY OR bachelor._tag IS NOT EMPTY)) |
|    |                |              |                                                     | orderBy: []                                                                                                           |
|    |                |              |                                                     | props: [                                                                                                              |
|    |                |              |                                                     |   {                                                                                                                   |
|    |                |              |                                                     |     "props": [                                                                                                        |
|    |                |              |                                                     |       "_tag"                                                                                                          |
|    |                |              |                                                     |     ],                                                                                                                |
|    |                |              |                                                     |     "tagId": 4                                                                                                        |
|    |                |              |                                                     |   },                                                                                                                  |
|    |                |              |                                                     |   {                                                                                                                   |
|    |                |              |                                                     |     "props": [                                                                                                        |
|    |                |              |                                                     |       "_tag"                                                                                                          |
|    |                |              |                                                     |     ],                                                                                                                |
|    |                |              |                                                     |     "tagId": 3                                                                                                        |
|    |                |              |                                                     |   },                                                                                                                  |
|    |                |              |                                                     |   {                                                                                                                   |
|    |                |              |                                                     |     "props": [                                                                                                        |
|    |                |              |                                                     |       "_tag"                                                                                                          |
|    |                |              |                                                     |     ],                                                                                                                |
|    |                |              |                                                     |     "tagId": 5                                                                                                        |
|    |                |              |                                                     |   }                                                                                                                   |
|    |                |              |                                                     | ]                                                                                                                     |
|    |                |              |                                                     | exprs:                                                                                                                |
-----+----------------+--------------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------
|  3 | Start          |              | ver: 0, rows: 0, execTime: 0us, totalTime: 8us      | outputVar: {                                                                                                          |
|    |                |              |                                                     |   "colNames": [],                                                                                                     |
|    |                |              |                                                     |   "type": "DATASET",                                                                                                  |
|    |                |              |                                                     |   "name": "__Start_3"                                                                                                 |
|    |                |              |                                                     | }                                                                                                                     |
-----+----------------+--------------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------

Tue, 18 Oct 2022 17:50:53 CST
(root@nebula) [nba]> profile optional match (v) where v.player.name == "ggg" return v limit 10;
+---------------------------------------------------------------+
| v                                                             |
+---------------------------------------------------------------+
| ("Dirk Nowitzki" :player{age: 40, name: "Dirk Nowitzki"})     |
| ("Chris Paul" :player{age: 33, name: "Chris Paul"})           |
| ("Dejounte Murray" :player{age: 29, name: "Dejounte Murray"}) |
| ("Grizzlies" :team{name: "Grizzlies"})                        |
| ("Klay Thompson" :player{age: 29, name: "Klay Thompson"})     |
| ("Nuggets" :team{name: "Nuggets"})                            |
| ("Suns" :team{name: "Suns"})                                  |
| ("Bulls" :team{name: "Bulls"})                                |
| ("Kings" :team{name: "Kings"})                                |
| ("Nobody" :player{age: 0, name: "Nobody"})                    |
+---------------------------------------------------------------+
Got 10 rows (time spent 3039/3483 us)

Execution Plan (optimize time 153 us)

-----+----------------+--------------+------------------------------------------------------+---------------------------------------------------------------------------------------------
| id | name           | dependencies | profiling data                                       | operator info                                                                              |
-----+----------------+--------------+------------------------------------------------------+---------------------------------------------------------------------------------------------
| 14 | Limit          | 15           | ver: 0, rows: 10, execTime: 24us, totalTime: 25us    | outputVar: {                                                                               |
|    |                |              |                                                      |   "colNames": [                                                                            |
|    |                |              |                                                      |     "v"                                                                                    |
|    |                |              |                                                      |   ],                                                                                       |
|    |                |              |                                                      |   "type": "DATASET",                                                                       |
|    |                |              |                                                      |   "name": "__Limit_7"                                                                      |
|    |                |              |                                                      | }                                                                                          |
|    |                |              |                                                      | inputVar: __AppendVertices_15                                                              |
|    |                |              |                                                      | offset: 0                                                                                  |
|    |                |              |                                                      | count: 10                                                                                  |
-----+----------------+--------------+------------------------------------------------------+---------------------------------------------------------------------------------------------
| 15 | AppendVertices | 13           | {                                                    | outputVar: {                                                                               |
|    |                |              | ver: 0, rows: 86, execTime: 378us, totalTime: 1148us |   "colNames": [                                                                            |
|    |                |              | "store1":9779 exec/total: 175(us)/785(us)            |     "v"                                                                                    |
|    |                |              | "store4":9779 exec/total: 163(us)/712(us)            |   ],                                                                                       |
|    |                |              | "store7":9779 exec/total: 148(us)/771(us)            |   "type": "DATASET",                                                                       |
|    |                |              | "store3":9779 exec/total: 153(us)/728(us)            |   "name": "__AppendVertices_15"                                                            |
|    |                |              | "store2":9779 exec/total: 169(us)/768(us)            | }                                                                                          |
|    |                |              | "store6":9779 exec/total: 191(us)/860(us)            | inputVar: __ScanVertices_13                                                                |
|    |                |              | "store5":9779 exec/total: 193(us)/759(us)            | space: 2                                                                                   |
|    |                |              | total_rpc: 953(us)                                   | dedup: true                                                                                |
|    |                |              | }                                                    | limit: 10                                                                                  |
|    |                |              |                                                      | filter:                                                                                    |
|    |                |              |                                                      | orderBy: []                                                                                |
|    |                |              |                                                      | src: $-._vid                                                                               |
|    |                |              |                                                      | props: [                                                                                   |
|    |                |              |                                                      |   {                                                                                        |
|    |                |              |                                                      |     "props": [                                                                             |
|    |                |              |                                                      |       "name",                                                                              |
|    |                |              |                                                      |       "age",                                                                               |
|    |                |              |                                                      |       "_tag"                                                                               |
|    |                |              |                                                      |     ],                                                                                     |
|    |                |              |                                                      |     "tagId": 3                                                                             |
|    |                |              |                                                      |   },                                                                                       |
|    |                |              |                                                      |   {                                                                                        |
|    |                |              |                                                      |     "props": [                                                                             |
|    |                |              |                                                      |       "name",                                                                              |
|    |                |              |                                                      |       "speciality",                                                                        |
|    |                |              |                                                      |       "_tag"                                                                               |
|    |                |              |                                                      |     ],                                                                                     |
|    |                |              |                                                      |     "tagId": 5                                                                             |
|    |                |              |                                                      |   },                                                                                       |
|    |                |              |                                                      |   {                                                                                        |
|    |                |              |                                                      |     "props": [                                                                             |
|    |                |              |                                                      |       "name",                                                                              |
|    |                |              |                                                      |       "_tag"                                                                               |
|    |                |              |                                                      |     ],                                                                                     |
|    |                |              |                                                      |     "tagId": 4                                                                             |
|    |                |              |                                                      |   }                                                                                        |
|    |                |              |                                                      | ]                                                                                          |
|    |                |              |                                                      | exprs:                                                                                     |
|    |                |              |                                                      | vertex_filter:                                                                             |
|    |                |              |                                                      | if_track_previous_path: false                                                              |
-----+----------------+--------------+------------------------------------------------------+---------------------------------------------------------------------------------------------
| 13 | ScanVertices   | 3            | {                                                    | outputVar: {                                                                               |
|    |                |              | ver: 0, rows: 86, execTime: 236us, totalTime: 1406us |   "colNames": [                                                                            |
|    |                |              | total_rpc: 1338(us)                                  |     "_vid",                                                                                |
|    |                |              | "store5":9779 exec/total: 337(us)/1128(us)           |     "team._tag",                                                                           |
|    |                |              | "store6":9779 exec/total: 389(us)/1116(us)           |     "player._tag",                                                                         |
|    |                |              | "store3":9779 exec/total: 370(us)/1236(us)           |     "bachelor._tag"                                                                        |
|    |                |              | "store2":9779 exec/total: 314(us)/1120(us)           |   ],                                                                                       |
|    |                |              | "store7":9779 exec/total: 339(us)/1055(us)           |   "type": "DATASET",                                                                       |
|    |                |              | "store4":9779 exec/total: 330(us)/1117(us)           |   "name": "__ScanVertices_13"                                                              |
|    |                |              | "store1":9779 exec/total: 333(us)/1069(us)           | }                                                                                          |
|    |                |              | }                                                    | inputVar:                                                                                  |
|    |                |              |                                                      | space: 2                                                                                   |
|    |                |              |                                                      | dedup: false                                                                               |
|    |                |              |                                                      | limit: 10                                                                                  |
|    |                |              |                                                      | filter: (team._tag IS NOT EMPTY OR player._tag IS NOT EMPTY OR bachelor._tag IS NOT EMPTY) |
|    |                |              |                                                      | orderBy: []                                                                                |
|    |                |              |                                                      | props: [                                                                                   |
|    |                |              |                                                      |   {                                                                                        |
|    |                |              |                                                      |     "props": [                                                                             |
|    |                |              |                                                      |       "_tag"                                                                               |
|    |                |              |                                                      |     ],                                                                                     |
|    |                |              |                                                      |     "tagId": 4                                                                             |
|    |                |              |                                                      |   },                                                                                       |
|    |                |              |                                                      |   {                                                                                        |
|    |                |              |                                                      |     "props": [                                                                             |
|    |                |              |                                                      |       "_tag"                                                                               |
|    |                |              |                                                      |     ],                                                                                     |
|    |                |              |                                                      |     "tagId": 3                                                                             |
|    |                |              |                                                      |   },                                                                                       |
|    |                |              |                                                      |   {                                                                                        |
|    |                |              |                                                      |     "props": [                                                                             |
|    |                |              |                                                      |       "_tag"                                                                               |
|    |                |              |                                                      |     ],                                                                                     |
|    |                |              |                                                      |     "tagId": 5                                                                             |
|    |                |              |                                                      |   }                                                                                        |
|    |                |              |                                                      | ]                                                                                          |
|    |                |              |                                                      | exprs:                                                                                     |
-----+----------------+--------------+------------------------------------------------------+---------------------------------------------------------------------------------------------
|  3 | Start          |              | ver: 0, rows: 0, execTime: 0us, totalTime: 8us       | outputVar: {                                                                               |
|    |                |              |                                                      |   "colNames": [],                                                                          |
|    |                |              |                                                      |   "type": "DATASET",                                                                       |
|    |                |              |                                                      |   "name": "__Start_3"                                                                      |
|    |                |              |                                                      | }                                                                                          |
-----+----------------+--------------+------------------------------------------------------+---------------------------------------------------------------------------------------------

Tue, 18 Oct 2022 17:51:45 CST

Expected behavior

Additional context

@nebula-bots nebula-bots added auto-sync severity/none Severity of bug type/bug Type: something is unexpected labels Oct 19, 2022
@Sophie-Xie Sophie-Xie added this to the v3.3.0 milestone Oct 19, 2022
@xtcyclist
Copy link
Contributor

xtcyclist commented Oct 20, 2022

This bug is exposed in the above case where the where predicate goes missing, causing the query to run some random lookups in the graph and return some random records after limit. After investigations, there are more problems into it.

The current implementation has missed to support the case in which there is only a single optional match, with or without a where predicate. In such cases, if no valid result is found, the query shall return a NULL in the result set, instead of an empty set.

Quite complicated. Need to revise the design of optional match. Potentially needs a medium-size PR.

Considering adding a minor fix first.

@Sophie-Xie
Copy link
Contributor

Discussed it offline with PD, RD, QA: will be fixed in next version

@nebula-bots nebula-bots added type/bug/compatibility Bugs related to compatibility with other languages like openCypher. severity/minor Severity of bug and removed severity/none Severity of bug labels Nov 9, 2022
@xtcyclist xtcyclist assigned czpmango and unassigned xtcyclist Nov 29, 2022
@Sophie-Xie Sophie-Xie assigned MuYiYong and unassigned czpmango Dec 1, 2022
@HarrisChu HarrisChu added the affects/none PR/issue: this bug affects none version. label Dec 1, 2022
@Sophie-Xie Sophie-Xie added the need to discuss Solution: issue or PR without a clear conclusion on whether to handle it label Dec 5, 2022
@xtcyclist
Copy link
Contributor

Close optional match related issues.

@github-actions github-actions bot removed the process/fixed Process of bug label Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects/none PR/issue: this bug affects none version. auto-sync need to discuss Solution: issue or PR without a clear conclusion on whether to handle it process/done Process of bug severity/minor Severity of bug type/bug/compatibility Bugs related to compatibility with other languages like openCypher. type/bug Type: something is unexpected wontfix Solution: this will not be worked on recently
Projects
None yet
Development

No branches or pull requests

7 participants