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

fix(sqlparser): align operator precedence with PostgreSQL #8174

Merged
merged 7 commits into from
Feb 25, 2023

Conversation

xiangjinwu
Copy link
Contributor

@xiangjinwu xiangjinwu commented Feb 24, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Follow the operator precedence specified by PostgreSQL:
https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-PRECEDENCE

  • No more magic number for precedence.
  • Some operators in upstream are for non-PG dialects or old PG version, they are not removed to keep this PR focused and short: xor, ==, <=>, !
  • See test cases for operations / expressions affected.

Fixes #8140
Related: #7665

Checklist For Contributors

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR DOES NOT contain user-facing changes.

@github-actions github-actions bot added the type/fix Bug fix label Feb 24, 2023
@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Merging #8174 (0e05fe6) into main (7f237d7) will decrease coverage by 0.01%.
The diff coverage is 98.00%.

@@            Coverage Diff             @@
##             main    #8174      +/-   ##
==========================================
- Coverage   71.85%   71.84%   -0.01%     
==========================================
  Files        1129     1129              
  Lines      181263   181272       +9     
==========================================
+ Hits       130239   130241       +2     
- Misses      51024    51031       +7     
Flag Coverage Δ
rust 71.84% <98.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/sqlparser/src/parser.rs 91.52% <98.00%> (+0.06%) ⬆️
...torage/src/hummock/local_version/pinned_version.rs 88.75% <0.00%> (-0.63%) ⬇️
src/meta/src/hummock/mock_hummock_meta_client.rs 65.46% <0.00%> (-0.52%) ⬇️
src/object_store/src/object/mod.rs 48.45% <0.00%> (-0.42%) ⬇️
src/object_store/src/object/mem.rs 86.87% <0.00%> (-0.39%) ⬇️
src/storage/src/hummock/sstable_store.rs 64.62% <0.00%> (-0.32%) ⬇️
src/common/src/cache.rs 97.15% <0.00%> (-0.11%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@xxchan xxchan left a comment

Choose a reason for hiding this comment

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

nice work 🤯

@mergify
Copy link
Contributor

mergify bot commented Feb 25, 2023

Hey @xiangjinwu, this pull request failed to merge and has been dequeued from the merge train. If you believe your PR failed in the merge train because of a flaky test, requeue it by clicking "Update branch" or pushing an empty commit with git commit --allow-empty -m "rerun" && git push.

@xxchan xxchan added this pull request to the merge queue Feb 25, 2023
Merged via the queue into main with commit 9d866a1 Feb 25, 2023
@xxchan xxchan deleted the fix-8140-sqlparser-precedence branch February 25, 2023 19:12
Copy link
Contributor

@kwannoel kwannoel left a comment

Choose a reason for hiding this comment

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

This approach is much more clear 👍 thanks for this!

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

Successfully merging this pull request may close these issues.

bug(sqlparser): precedence of ^ (power) should be higher than +-*/
4 participants