You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "LucaCappelletti94 (via GitHub)" <gi...@apache.org> on 2026/09/25 07:23:27 UTC
[PR] MySQL: Bind && with the precedence of AND [datafusion-sqlparser-rs]
LucaCappelletti94 opened a new pull request, #2576:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2576
Since #2144, MySQL's `&&` parses as `BinaryOperator::And`, but its precedence still came from the shared group that ranks the PostgreSQL overlap operator above the comparison operators. So `x < 1 && y > 2` parsed as `((x < (1 AND y)) > 2)` and `x = a && c` as `x = (a AND c)`. Both then printed with `AND`, which reads back as a different tree.
MySQL ranks `&&` with `AND`, below every comparison (https://dev.mysql.com/doc/refman/8.4/en/operator-precedence.html). The precedence lookup now gives `Token::Overlap` the `AND` precedence whenever `supports_double_ampersand_operator()` holds, the same check `parse_infix` uses to build the `AND` node. PostgreSQL, Redshift and Generic keep `&&` as the overlap operator at its current precedence. The test added in #2144 now also checks that the comparison cases give the same trees as their `AND` spellings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] MySQL: Bind && with the precedence of AND [datafusion-sqlparser-rs]
Posted by "s5dsn-eqee (via GitHub)" <gi...@apache.org>.
s5dsn-eqee commented on code in PR #2576:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2576#discussion_r4131331555
##########
src/dialect/mod.rs:
##########
@@ -939,6 +939,7 @@ pub trait Dialect: Debug + Any {
| Token::ExclamationMarkDoubleTilde
| Token::ExclamationMarkDoubleTildeAsterisk
| Token::Spaceship => Ok(p!(Eq)),
+ Token::Overlap if self.supports_double_ampersand_operator() => Ok(p!(And)),
Review Comment:
Since it's guarded by supports_double_ampersand_operator(), the change looks reasonable to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] MySQL: Bind && with the precedence of AND [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 commented on PR #2576:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2576#issuecomment-6224881674
Will proceed to merge this one, thanks @s5dsn-eqee for the review!
cc @alamb @iffyio
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] MySQL: Bind && with the precedence of AND [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 merged PR #2576:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2576
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] MySQL: Bind && with the precedence of AND [datafusion-sqlparser-rs]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2576:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2576#issuecomment-5828583424
## [Codecov](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2576?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 81.02%. Comparing base ([`88ffee6`](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/commit/88ffee641a2192f17b44fec658463e2963233ec3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8c30112`](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/commit/8c30112b40a44c759e25406a9d159f35bef6412f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #2576 +/- ##
=======================================
Coverage 81.02% 81.02%
=======================================
Files 42 42
Lines 33436 33437 +1
Branches 33436 33437 +1
=======================================
+ Hits 27090 27091 +1
Misses 2789 2789
Partials 3557 3557
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2576?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] MySQL: Bind && with the precedence of AND [datafusion-sqlparser-rs]
Posted by "s5dsn-eqee (via GitHub)" <gi...@apache.org>.
s5dsn-eqee commented on code in PR #2576:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2576#discussion_r4131331555
##########
src/dialect/mod.rs:
##########
@@ -939,6 +939,7 @@ pub trait Dialect: Debug + Any {
| Token::ExclamationMarkDoubleTilde
| Token::ExclamationMarkDoubleTildeAsterisk
| Token::Spaceship => Ok(p!(Eq)),
+ Token::Overlap if self.supports_double_ampersand_operator() => Ok(p!(And)),
Review Comment:
My bad. After looking into it more, I think overriding get_next_precedence in MySqlDialect would be cleaner, the same way Oracle does for StringConcat:
https://github.com/apache/datafusion-sqlparser-rs/blob/5cad9060d38229ebf22a3b8625c685d5ad8552db/src/dialect/oracle.rs#L88
smt like this
```
fn get_next_precedence(&self, parser: &Parser) -> Option<Result<u8, ParserError>> {
match parser.peek_token_ref().token {
Token::Overlap => Some(Ok(self.prec_value(Precedence::And))),
_ => None,
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] MySQL: Bind && with the precedence of AND [datafusion-sqlparser-rs]
Posted by "s5dsn-eqee (via GitHub)" <gi...@apache.org>.
s5dsn-eqee commented on code in PR #2576:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2576#discussion_r4131774814
##########
src/dialect/mod.rs:
##########
@@ -939,6 +939,7 @@ pub trait Dialect: Debug + Any {
| Token::ExclamationMarkDoubleTilde
| Token::ExclamationMarkDoubleTildeAsterisk
| Token::Spaceship => Ok(p!(Eq)),
+ Token::Overlap if self.supports_double_ampersand_operator() => Ok(p!(And)),
Review Comment:
@LucaCappelletti94
Nit, not for this PR: supports_double_ampersand_operator() reads as "supports &&", while it actually means "&& is boolean AND" (Generic/PG/Redshift support && as overlap with the flag off). A name like supports_double_ampersand_as_and() could be a follow-up; it's a public trait method, so it'd be a breaking change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org