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

Support plan for AVG for scatter queries in Gen4 #8582

Closed
GuptaManan100 opened this issue Aug 3, 2021 · 2 comments
Closed

Support plan for AVG for scatter queries in Gen4 #8582

GuptaManan100 opened this issue Aug 3, 2021 · 2 comments

Comments

@GuptaManan100
Copy link
Member

Overview of the Issue

The following query returns incorrect result -

SELECT AVG(book6s.price) FROM book6s

The plan created from Gen4 is as follows -

{
  "QueryType": "SELECT",
  "Original": "select AVG(user.intcol) from user",
  "Instructions": {
    "OperatorType": "Aggregate",
    "Variant": "Ordered",
    "Aggregates": "count(0)",
    "Inputs": [
      {
        "OperatorType": "Route",
        "Variant": "SelectScatter",
        "Keyspace": {
          "Name": "user",
          "Sharded": true
        },
        "FieldQuery": "select AVG(`user`.intcol) from `user` where 1 != 1",
        "Query": "select AVG(`user`.intcol) from `user`",
        "Table": "`user`"
      }
    ]
  }
}

The plan is incorrect since we are running an AVG in SelectScatter. For an AVG query, we have to get all the rows from the shards and take the average on vtgate.

Reproduction Steps

Steps to reproduce this issue, example:

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

Binary version

  • main
@harshit-gangal
Copy link
Member

It does not add support for it. But it blocks from producing wrong plans.

#8593

@harshit-gangal harshit-gangal changed the title Incorrect plan for AVG for scatter queries in Gen4 Support plan for AVG for scatter queries in Gen4 Aug 9, 2021
@harshit-gangal
Copy link
Member

PR: #14419

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

No branches or pull requests

2 participants