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

incorrect result for composite index ["name", "age"] , filtering tag.name == "foo" OR tag.age > 41 #3603

Closed
wey-gu opened this issue Dec 30, 2021 · 2 comments · Fixed by #3694
Assignees
Labels
type/bug Type: something is unexpected
Milestone

Comments

@wey-gu
Copy link
Contributor

wey-gu commented Dec 30, 2021

If I understand it correctly, with composite index ["name", "age"] , tag.name == "foo" OR tag.age > 41 should end up no index found due to name's length is not fixed(to enable left scan of "age" field).

While in the build(not the one before merge, but close to) from multi-match PR, the result is incorrect:

  • result returned
  • result is wrong

Your Environments (required)

(root@nebula) [basketballplayer]> show hosts graph
+-----------------+------+----------+---------+--------------+---------+
| Host            | Port | Status   | Role    | Git Info Sha | Version |
+-----------------+------+----------+---------+--------------+---------+
| "192.168.8.128" | 9669 | "ONLINE" | "GRAPH" | "ca04bab"    | ""      |
+-----------------+------+----------+---------+--------------+---------+

How To Reproduce(required)

Steps to reproduce the behavior:

(root@nebula) [basketballplayer]> show tag indexes
+------------------+----------+-----------------+
| Index Name       | By Tag   | Columns         |
+------------------+----------+-----------------+
| "player_index_0" | "player" | []              |
+------------------+----------+-----------------+
| "player_index_1" | "player" | ["name"]        |
+------------------+----------+-----------------+
| "player_index_2" | "player" | ["name", "age"] |
+------------------+----------+-----------------+
Got 3 rows (time spent 2055/39548 us)

(root@nebula) [basketballplayer]> match (p:player)  where p.name == "Tim Duncan" OR p.age > 41 return p
+---------------------------------------------------------------+
| p                                                             |
+---------------------------------------------------------------+
| ("player105" :player{age: 31, name: "Danny Green"})           |
| ("player109" :player{age: 34, name: "Tiago Splitter"})        |
| ("player111" :player{age: 38, name: "David West"})            |
| ("player118" :player{age: 30, name: "Russell Westbrook"})     |
| ("player143" :player{age: 23, name: "Kristaps Porzingis"})    |
| ("player114" :player{age: 39, name: "Tracy McGrady"})         |
| ("player150" :player{age: 20, name: "Luka Doncic"})           |
| ("player103" :player{age: 32, name: "Rudy Gay"})              |
| ("player113" :player{age: 29, name: "Dejounte Murray"})       |
| ("player121" :player{age: 33, name: "Chris Paul"})            |
| ("player128" :player{age: 34, name: "Carmelo Anthony"})       |
| ("player130" :player{age: 25, name: "Joel Embiid"})           |
| ("player136" :player{age: 45, name: "Steve Nash"})            |
| ("player108" :player{age: 36, name: "Boris Diaw"})            |
| ("player122" :player{age: 30, name: "DeAndre Jordan"})        |
| ("player123" :player{age: 28, name: "Ricky Rubio"})           |
| ("player139" :player{age: 34, name: "Marc Gasol"})            |
| ("player142" :player{age: 29, name: "Klay Thompson"})         |
| ("player145" :player{age: 31, name: "JaVale McGee"})          |
| ("player102" :player{age: 33, name: "LaMarcus Aldridge"})     |
| ("player106" :player{age: 25, name: "Kyle Anderson"})         |
| ("player115" :player{age: 40, name: "Kobe Bryant"})           |
| ("player129" :player{age: 37, name: "Dwyane Wade"})           |
| ("player138" :player{age: 38, name: "Paul Gasol"})            |
| ("player127" :player{age: 42, name: "Vince Carter"})          |
| ("player132" :player{age: 24, name: "Giannis Antetokounmpo"}) |
| ("player135" :player{age: 28, name: "Damian Lillard"})        |
| ("player146" :player{age: 33, name: "Dwight Howard"})         |
| ("player147" :player{age: 36, name: "Amar'e Stoudemire"})     |
| ("player148" :player{age: 45, name: "Jason Kidd"})            |
| ("player100" :player{age: 42, name: "Tim Duncan"})            |
| ("player101" :player{age: 36, name: "Tony Parker"})           |
| ("player110" :player{age: 27, name: "Cory Joseph"})           |
| ("player126" :player{age: 26, name: "Kyrie Irving"})          |
| ("player131" :player{age: 28, name: "Paul George"})           |
| ("player133" :player{age: 38, name: "Yao Ming"})              |
| ("player140" :player{age: 46, name: "Grant Hill"})            |
| ("player104" :player{age: 32, name: "Marco Belinelli"})       |
| ("player107" :player{age: 32, name: "Aron Baynes"})           |
| ("player116" :player{age: 34, name: "LeBron James"})          |
| ("player120" :player{age: 29, name: "James Harden"})          |
| ("player125" :player{age: 41, name: "Manu Ginobili"})         |
| ("player137" :player{age: 40, name: "Dirk Nowitzki"})         |
| ("player124" :player{age: 33, name: "Rajon Rondo"})           |
| ("player112" :player{age: 29, name: "Jonathon Simmons"})      |
| ("player117" :player{age: 31, name: "Stephen Curry"})         |
| ("player119" :player{age: 30, name: "Kevin Durant"})          |
| ("player134" :player{age: 30, name: "Blake Griffin"})         |
| ("player141" :player{age: 43, name: "Ray Allen"})             |
| ("player144" :player{age: 47, name: "Shaquille O'Neal"})      |
| ("player149" :player{age: 22, name: "Ben Simmons"})           |
+---------------------------------------------------------------+
Got 51 rows (time spent 7363/78566 us)

Expected behavior


(root@nebula) [basketballplayer]> match (p:player)  where p.name == "Yao Ming" OR p.age > 41 return p
[ERROR (-1005)]: IndexNotFound: No valid index found

Additional context

Found this when I was trying to answer https://discuss.nebula-graph.com.cn/t/topic/7065

@wey-gu wey-gu added the type/bug Type: something is unexpected label Dec 30, 2021
@wey-gu wey-gu changed the title incorrect result for composite index ["name", "age"] , filtering tag.name == "foo" OR tag.age > 41 incorrect result for composite index ["name", "age"] , filtering tag.name == "foo" OR tag.age > 41 Dec 30, 2021
@Sophie-Xie Sophie-Xie added this to the v3.0.0 milestone Dec 30, 2021
@CPWstatic
Copy link
Contributor

Would you please paste the execution plan for us?

@wey-gu
Copy link
Contributor Author

wey-gu commented Jan 6, 2022

Would you please paste the execution plan for us?

Here it is:

(root@nebula) [basketballplayer]> explain match (p:player)  where p.player.name == "Tim Duncan" OR p.player.age > 41 return p
Execution succeeded (time spent 708/5788 us)

Execution Plan (optimize time 157 us)

-----+----------------+--------------+----------------+------------------------------------------
| id | name           | dependencies | profiling data | operator info                           |
-----+----------------+--------------+----------------+------------------------------------------
|  7 | Project        | 3            |                | outputVar: [                            |
|    |                |              |                |   {                                     |
|    |                |              |                |     "colNames": [                       |
|    |                |              |                |       "p"                               |
|    |                |              |                |     ],                                  |
|    |                |              |                |     "type": "DATASET",                  |
|    |                |              |                |     "name": "__Project_5"               |
|    |                |              |                |   }                                     |
|    |                |              |                | ]                                       |
|    |                |              |                | inputVar: __AppendVertices_3            |
|    |                |              |                | columns: [                              |
|    |                |              |                |   "$-.p AS p"                           |
|    |                |              |                | ]                                       |
-----+----------------+--------------+----------------+------------------------------------------
|  3 | AppendVertices | 6            |                | outputVar: [                            |
|    |                |              |                |   {                                     |
|    |                |              |                |     "colNames": [                       |
|    |                |              |                |       "p"                               |
|    |                |              |                |     ],                                  |
|    |                |              |                |     "type": "DATASET",                  |
|    |                |              |                |     "name": "__AppendVertices_3"        |
|    |                |              |                |   }                                     |
|    |                |              |                | ]                                       |
|    |                |              |                | inputVar: __IndexScan_1                 |
|    |                |              |                | space: 1                                |
|    |                |              |                | dedup: true                             |
|    |                |              |                | limit: 0                                |
|    |                |              |                | filter:                                 |
|    |                |              |                | orderBy: []                             |
|    |                |              |                | src: $_vid                              |
|    |                |              |                | props: [                                |
|    |                |              |                |   {                                     |
|    |                |              |                |     "props": [                          |
|    |                |              |                |       "name",                           |
|    |                |              |                |       "age",                            |
|    |                |              |                |       "_tag"                            |
|    |                |              |                |     ],                                  |
|    |                |              |                |     "tagId": 2                          |
|    |                |              |                |   },                                    |
|    |                |              |                |   {                                     |
|    |                |              |                |     "props": [                          |
|    |                |              |                |       "name",                           |
|    |                |              |                |       "_tag"                            |
|    |                |              |                |     ],                                  |
|    |                |              |                |     "tagId": 3                          |
|    |                |              |                |   }                                     |
|    |                |              |                | ]                                       |
|    |                |              |                | exprs:                                  |
|    |                |              |                | vertex_filter: player._tag IS NOT EMPTY |
|    |                |              |                | if_track_previous_path: false           |
-----+----------------+--------------+----------------+------------------------------------------
|  6 | IndexScan      | 2            |                | outputVar: [                            |
|    |                |              |                |   {                                     |
|    |                |              |                |     "colNames": [                       |
|    |                |              |                |       "_vid"                            |
|    |                |              |                |     ],                                  |
|    |                |              |                |     "type": "DATASET",                  |
|    |                |              |                |     "name": "__IndexScan_1"             |
|    |                |              |                |   }                                     |
|    |                |              |                | ]                                       |
|    |                |              |                | inputVar:                               |
|    |                |              |                | space: 1                                |
|    |                |              |                | dedup: false                            |
|    |                |              |                | limit: 9223372036854775807              |
|    |                |              |                | filter:                                 |
|    |                |              |                | orderBy: []                             |
|    |                |              |                | schemaId: 2                             |
|    |                |              |                | isEdge: false                           |
|    |                |              |                | returnCols: [                           |
|    |                |              |                |   "_vid"                                |
|    |                |              |                | ]                                       |
|    |                |              |                | indexCtx: [                             |
|    |                |              |                |   {                                     |
|    |                |              |                |     "columnHints": [                    |
|    |                |              |                |       {                                 |
|    |                |              |                |         "includeEnd": "false",          |
|    |                |              |                |         "includeBegin": "true",         |
|    |                |              |                |         "endValue": "__EMPTY__",        |
|    |                |              |                |         "beginValue": "\"Tim Duncan\"", |
|    |                |              |                |         "scanType": "PREFIX",           |
|    |                |              |                |         "column": "name"                |
|    |                |              |                |       }                                 |
|    |                |              |                |     ],                                  |
|    |                |              |                |     "filter": "",                       |
|    |                |              |                |     "index_id": 7                       |
|    |                |              |                |   },                                    |
|    |                |              |                |   {                                     |
|    |                |              |                |     "columnHints": [],                  |
|    |                |              |                |     "filter": "",                       |
|    |                |              |                |     "index_id": 6                       |
|    |                |              |                |   }                                     |
|    |                |              |                | ]                                       |
-----+----------------+--------------+----------------+------------------------------------------
|  2 | Start          |              |                | outputVar: [                            |
|    |                |              |                |   {                                     |
|    |                |              |                |     "colNames": [],                     |
|    |                |              |                |     "type": "DATASET",                  |
|    |                |              |                |     "name": "__Start_2"                 |
|    |                |              |                |   }                                     |
|    |                |              |                | ]                                       |
-----+----------------+--------------+----------------+------------------------------------------

@jackwener jackwener linked a pull request Jan 13, 2022 that will close this issue
11 tasks
@nevermore3 nevermore3 mentioned this issue Jan 13, 2022
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.

5 participants