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

[SPARK-48168][SQL][FOLLOWUP] Fix bitwise shifting operator's precedence #46753

Closed
wants to merge 1 commit into from

Conversation

yaooqinn
Copy link
Member

@yaooqinn yaooqinn commented May 27, 2024

What changes were proposed in this pull request?

After referencing both C, MySQL's doc,
https://en.cppreference.com/w/c/language/operator_precedence
https://dev.mysql.com/doc/refman/8.0/en/operator-precedence.html

And doing some experiments on scala-shell

scala> 1 & 2 >> 1
val res0: Int = 1

scala> 2 >> 1 << 1
val res1: Int = 2

scala> 1 << 1 + 2
val res2: Int = 8

The suitable precedence for << >> >>> is between '+/-' and '&' with a left-to-right associativity.

Why are the changes needed?

bugfix

Does this PR introduce any user-facing change?

now, unreleased yet

How was this patch tested?

new tests

Was this patch authored or co-authored using generative AI tooling?

no

@github-actions github-actions bot added the SQL label May 27, 2024
@yaooqinn yaooqinn changed the title [SPARK-48168][SQL][FOLLOWUP] Fix bitwise shifting operator precedence [SPARK-48168][SQL][FOLLOWUP] Fix bitwise shifting operator's precedence May 27, 2024
@yaooqinn
Copy link
Member Author

cc @ulysses-you @cloud-fan thanks

@yaooqinn yaooqinn closed this in b526456 May 27, 2024
@yaooqinn
Copy link
Member Author

Merged to master. Thank you @ulysses-you

@yaooqinn yaooqinn deleted the SPARK-48168-F branch May 27, 2024 09:56
@cloud-fan
Copy link
Contributor

late LGTM. also cc @srielau

riyaverm-db pushed a commit to riyaverm-db/spark that referenced this pull request Jun 7, 2024
### What changes were proposed in this pull request?

After referencing both `C`, `MySQL`'s doc,
https://en.cppreference.com/w/c/language/operator_precedence
https://dev.mysql.com/doc/refman/8.0/en/operator-precedence.html

And doing some experiments on scala-shell

```scala
scala> 1 & 2 >> 1
val res0: Int = 1

scala> 2 >> 1 << 1
val res1: Int = 2

scala> 1 << 1 + 2
val res2: Int = 8
```

The suitable precedence for `<< >> >>>` is between '+/-' and '&' with a left-to-right associativity.
### Why are the changes needed?

bugfix

### Does this PR introduce _any_ user-facing change?

now, unreleased yet

### How was this patch tested?

new tests

### Was this patch authored or co-authored using generative AI tooling?
no

Closes apache#46753 from yaooqinn/SPARK-48168-F.

Authored-by: Kent Yao <yao@apache.org>
Signed-off-by: Kent Yao <yao@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants