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 from DISTINCT clause in Gen4 #8581

Closed
GuptaManan100 opened this issue Aug 3, 2021 · 0 comments · Fixed by #8596
Closed

Incorrect result from DISTINCT clause in Gen4 #8581

GuptaManan100 opened this issue Aug 3, 2021 · 0 comments · Fixed by #8596

Comments

@GuptaManan100
Copy link
Member

Overview of the Issue

The following query generates incorrect results -

SELECT DISTINCT order2s.`status` FROM order2s

The result for this query is -

+--------+
| status |
+--------+
|      3 |
|      2 |
|      0 |
|      1 |
|      2 |
|      0 |
|      1 |
|      3 |
+--------+

The problem has been traced back to Gen4 planning. The V3 plan is as follows

{
  "QueryType": "SELECT",
  "Original": "select distinct user.`intcol` from user",
  "Instructions": {
    "OperatorType": "Aggregate",
    "Variant": "Ordered",
    "GroupBy": "0",
    "Inputs": [
      {
        "OperatorType": "Route",
        "Variant": "SelectScatter",
        "Keyspace": {
          "Name": "user",
          "Sharded": true
        },
        "FieldQuery": "select `user`.intcol from `user` where 1 != 1",
        "OrderBy": "0 ASC",
        "Query": "select distinct `user`.intcol from `user` order by intcol asc",
        "Table": "`user`"
      }
    ]
  }
}

The difference between V3 and Gen4 is as follows

- 	        "OrderBy": "0 ASC",
- 	        "Query": "select distinct `user`.intcol from `user` order by intcol asc",
+ 	        "Query": "select distinct `user`.intcol from `user`",

Reproduction Steps

Steps to reproduce this issue, example:

  1. Add the query to onecase.txt
  2. Run the test TestOneCase

Binary version

  • main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant