-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fixes formatting issue for negated SQL subqueries #27678
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
Fixes formatting issue for negated SQL subqueries #27678
Conversation
|
Could you please add a test? |
|
@ebyhr I meant to ask where a good place to add the test would be. I know Trino typically leans hard on integration tests, but this seems much better suited for a unit test. I see that there's a |
testing/trino-tests/src/test/java/io/trino/tests/TestSqlFormatter.java
Outdated
Show resolved
Hide resolved
testing/trino-tests/src/test/java/io/trino/tests/TestSqlFormatter.java
Outdated
Show resolved
Hide resolved
testing/trino-tests/src/test/java/io/trino/tests/TestSqlFormatter.java
Outdated
Show resolved
Hide resolved
ffef46f to
18ab834
Compare
| private static Stream<String> sqlQueries() | ||
| { | ||
| return Stream.of( | ||
| "SELECT +1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious if the following would be a valid case:
(SELECT 1) + SELECT
(SELECT 1) - SELECT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SqlFormatter seems to correctly throw a syntax error for these cases
testing/trino-tests/src/test/java/io/trino/tests/TestSqlFormatter.java
Outdated
Show resolved
Hide resolved
18ab834 to
1468546
Compare
082289b to
aa33639
Compare
aa33639 to
1a3faec
Compare
Description
Fixes #19695 . Addresses issues with round-trips for negated subqueries. Specifically, the formatter adds parentheses around negative unary arithmetic expressions, even if the value being negated already has parentheses around it (i.e. for SQL subqueries).
This change just checks whether the value being negated is already wrapped in parentheses.
Additional context and related issues
Release notes
(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: