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

Bugfix: GROUP BY/HAVING alias resolution #15344

Merged
merged 15 commits into from
Feb 28, 2024

Conversation

systay
Copy link
Collaborator

@systay systay commented Feb 23, 2024

Description

Following up on #15302, this PR does the same fix for GROUP BY and HAVING.

Related Issue(s)

#15302 (fix for ORDER BY)
#14935 (pr that introduced some bad rewrites)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Copy link
Contributor

vitess-bot bot commented Feb 23, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Feb 23, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone Feb 23, 2024
@systay systay force-pushed the group-by-resolution branch from 44dca2d to 7a0834e Compare February 23, 2024 14:47
@systay systay force-pushed the group-by-resolution branch from a74875d to 032275f Compare February 26, 2024 07:43
Signed-off-by: Andres Taylor <[email protected]>
@systay systay force-pushed the group-by-resolution branch from 689f3c2 to 1f8838f Compare February 26, 2024 16:15
@@ -1041,32 +1073,6 @@
]
}
},
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this since it fails on mysql. a is not the same as a collate utf8_general_ci, so if full_group_by is enabled, this query would fail

@@ -2113,71 +2119,6 @@
]
}
},
{
"comment": "aggregation filtering by having on a route with no group by with non-unique vindex filter",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this query fails on both mysql and vitess. name is not accessible on the having clause

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This query does not fail anymore, we should bring the test back.

Copy link

codecov bot commented Feb 26, 2024

Codecov Report

Attention: Patch coverage is 88.25758% with 31 lines in your changes are missing coverage. Please review.

Project coverage is 65.43%. Comparing base (696fe0e) to head (9eb1dc8).
Report is 65 commits behind head on main.

Files Patch % Lines
go/vt/vtgate/semantics/binder.go 86.04% 12 Missing ⚠️
go/vt/vtgate/semantics/errors.go 33.33% 10 Missing ⚠️
go/vt/vtgate/semantics/early_rewriter.go 95.68% 5 Missing ⚠️
go/vt/vtgate/semantics/analyzer.go 85.71% 2 Missing ⚠️
go/vt/vtgate/semantics/dependencies.go 66.66% 1 Missing ⚠️
go/vt/vtgate/semantics/scoper.go 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15344      +/-   ##
==========================================
- Coverage   67.41%   65.43%   -1.98%     
==========================================
  Files        1560     1562       +2     
  Lines      192752   193863    +1111     
==========================================
- Hits       129952   126863    -3089     
- Misses      62800    67000    +4200     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@systay systay added Backport to: release-18.0 Backport to: release-19.0 Needs to be back ported to release-19.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Feb 27, 2024
@systay systay marked this pull request as ready for review February 27, 2024 06:51
Copy link
Member

@GuptaManan100 GuptaManan100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

go/vt/vtgate/semantics/early_rewriter.go Outdated Show resolved Hide resolved
@systay
Copy link
Collaborator Author

systay commented Feb 27, 2024

does this mean we will start failing queries for group by/ having if the schema tracking is not enabled?

your comment was not connected to anything I could see, so I'm not sure what the question is about. Generally - if you are grouping by an alias introduced in the SELECT expression, and we have to do some or most of the aggregating on the vtgate, queries might start having issues if you are running without schema tracking

@systay systay force-pushed the group-by-resolution branch from 56e4696 to 70348a3 Compare February 28, 2024 15:39
Signed-off-by: Andres Taylor <[email protected]>
@systay systay removed the Backport to: release-19.0 Needs to be back ported to release-19.0 label Feb 28, 2024
@systay systay merged commit 15f5886 into vitessio:main Feb 28, 2024
103 checks passed
@systay systay deleted the group-by-resolution branch February 28, 2024 20:52
systay added a commit to planetscale/vitess that referenced this pull request Feb 29, 2024
systay added a commit that referenced this pull request Feb 29, 2024
GuptaManan100 added a commit that referenced this pull request Feb 29, 2024
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Co-authored-by: Manan Gupta <[email protected]>
deepthi pushed a commit that referenced this pull request Feb 29, 2024
)

Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Co-authored-by: Andrés Taylor <[email protected]>
Co-authored-by: Manan Gupta <[email protected]>
JiekerTime pushed a commit to JiekerTime/vitess that referenced this pull request Mar 8, 2024
* fix test cases

* Merge branch 'master' into split-table-merge-master0306

* fix ci test

* Bugfix: GROUP BY/HAVING alias resolution (vitessio#15344) (vitessio#15381

* add params for proxy support ddl operations

* merge origin

* fix client_found_row (vitessio#203)

* merge origin to a2c986c

* fix client found rows

* Use GetTabletsByCell in healthcheck

* delete start params:track_schema_versions.

* auto delete logs from three days ago

* 解决跨cell获取节点失败和SQL权限没有正确拦截的问题

* merge origin 3a35dd

* 支持MySQL8.0编译... (vitessio#185)

* 修改show vitess_shards|vitess_tables和 show variables (vitessio#175)

* fix binaryhash

* fix: container restart ,programs restart failed

* add start params

* merge origin with laster pr:f39ada

* fix vttablet startup

* fix openEuler dockerfile

* merge origin bugfix

* fix master ci

* Bugfix: fix pinned table for splitclone (vitessio#141)
JiekerTime pushed a commit to JiekerTime/vitess that referenced this pull request Mar 8, 2024
* Merge branch 'master' into split-table-merge-master0306

* 修复agent容器无法跨容器恢复MySQL数据的问题

* fix test cases

* fix ci test

* Bugfix: GROUP BY/HAVING alias resolution (vitessio#15344) (vitessio#15381

* add params for proxy support ddl operations

* merge origin

* fix client_found_row (vitessio#203)

* merge origin to a2c986c

* fix client found rows

* Use GetTabletsByCell in healthcheck

* delete start params:track_schema_versions.

* auto delete logs from three days ago

* 解决跨cell获取节点失败和SQL权限没有正确拦截的问题

* merge origin 3a35dd

* 支持MySQL8.0编译... (vitessio#185)

* 修改show vitess_shards|vitess_tables和 show variables (vitessio#175)

* fix binaryhash

* fix: container restart ,programs restart failed

* add start params

* merge origin with laster pr:f39ada

* fix vttablet startup

* fix openEuler dockerfile

* merge origin bugfix

* fix master ci

* Bugfix: fix pinned table for splitclone (vitessio#141)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants