You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "eliaperantoni (via GitHub)" <gi...@apache.org> on 2025/06/05 08:37:15 UTC
[PR] Fix `CASE` expression spans [datafusion-sqlparser-rs]
eliaperantoni opened a new pull request, #1874:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1874
Previously, a `Expr::Case` implementation of `Spanned` would ignore the `CASE .. END` keywords. ie.
```sql
CASE a WHEN b THEN c ELSE d END
-- ^^^^^^^^^^^^^^^^^^^^^^
-- Only this would be highlighted
```
Because the only stored locations would be those of the `Ident` _inside_ the `CASE` expression.
This PR attaches two `AttachedToken` to the AST node, one for `CASE` and one for `END`, so that `Spanned::span` now returns the whole range. This was done to follow the footsteps of the `SELECT` implementation, which also stores an `AttachedToken` for the `SELECT` keyword. Also added a test for this.
--
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] Fix `CASE` expression spans [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio merged PR #1874:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1874
--
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] Fix `CASE` expression spans [datafusion-sqlparser-rs]
Posted by "eliaperantoni (via GitHub)" <gi...@apache.org>.
eliaperantoni commented on code in PR #1874:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1874#discussion_r2132134424
##########
tests/sqlparser_common.rs:
##########
@@ -14464,6 +14468,16 @@ fn test_case_statement_span() {
);
}
+#[test]
Review Comment:
Absolutely! I moved it and aligned its body with the approach taken in the rest of the tests in `spans.rs`. Thank you for the review 🥰!
--
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] Fix `CASE` expression spans [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #1874:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1874#discussion_r2131646198
##########
tests/sqlparser_common.rs:
##########
@@ -14464,6 +14468,16 @@ fn test_case_statement_span() {
);
}
+#[test]
Review Comment:
Could we move the test case to the [spans.rs](https://github.com/apache/datafusion-sqlparser-rs/blob/6cf531d4951545708a82b208bed8ea596f91a186/src/ast/spans.rs#L2333) tests?
--
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