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

Consistent formatting of multiline strings #23958

Conversation

losipiuk
Copy link
Member

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:

@cla-bot cla-bot bot added the cla-signed label Oct 29, 2024
@github-actions github-actions bot added docs iceberg Iceberg connector delta-lake Delta Lake connector hive Hive connector bigquery BigQuery connector labels Oct 29, 2024
@losipiuk losipiuk marked this pull request as ready for review October 29, 2024 15:49
@losipiuk losipiuk requested a review from martint October 29, 2024 15:49
@losipiuk
Copy link
Member Author

Not sure if that is really nicer? But @martint you requested changes like this on on PR so thought i would make sense to just use common formatting every where.

@losipiuk losipiuk requested a review from wendigo October 29, 2024 15:51
@@ -238,31 +238,35 @@ public void testRemoveRedundantTableFunction()
assertPlan("SELECT * FROM TABLE(mock.system.pass_through_function(input => TABLE(SELECT 1, true WHERE false) t(a, b) PRUNE WHEN EMPTY))",
output(values(ImmutableList.of("x", "a", "b"))));

assertPlan("""
assertPlan(
"""
Copy link
Member

Choose a reason for hiding this comment

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

Indentation seems wrong here and in the ones below, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah - but to be honest I am not sure how should it be.
Also no matter what I do automatic reformat in intellij breaks it anyway to:

        assertPlan(
                """
                        SELECT *
                        FROM TABLE(mock.system.two_table_arguments_function(
                                        input1 => TABLE(SELECT 1, true WHERE false) t1(a, b) PRUNE WHEN EMPTY,
                                        input2 => TABLE(SELECT 2, false) t2(c, d) KEEP WHEN EMPTY))
                        """,

This PR brings back the discussion about automatic code reformatting. IMO it would be great to have. One less thing to think of - even if not optimal from time to time.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah - this is a mess.
I really think we should commit on using Intellij formatter and plug it in as a headless verifier in CI pipeline to verify if checked in code matches the formatting

@martint
Copy link
Member

martint commented Oct 29, 2024

Not sure if that is really nicer?

It's needed to make the auto-formatter in the IDE not mess things up.

@losipiuk losipiuk force-pushed the lukaszos/consistent-formatting-of-multiline-strings-f88f9b branch from e1841ec to 332a755 Compare October 30, 2024 12:13
" (2, 2)," +
" (2, 2)," +
" (3, 3)" +
") t(x, y)",
"VALUES (1.0, 1.0, 4)");

assertQuery(
"SELECT corr(DISTINCT x, y), corr(DISTINCT y, x), count(DISTINCT x) FROM " +
Copy link
Contributor

Choose a reason for hiding this comment

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

make it a multiline string instead

@losipiuk losipiuk force-pushed the lukaszos/consistent-formatting-of-multiline-strings-f88f9b branch from 332a755 to 49e98d4 Compare October 30, 2024 12:28
@losipiuk losipiuk requested a review from wendigo October 30, 2024 12:28
@github-actions github-actions bot added jdbc Relates to Trino JDBC driver hudi Hudi connector mongodb MongoDB connector labels Oct 30, 2024
@losipiuk losipiuk force-pushed the lukaszos/consistent-formatting-of-multiline-strings-f88f9b branch from cf3f669 to 40f2840 Compare October 30, 2024 16:15
@@ -175,6 +176,7 @@ private static String preprocessQueryInternal(Optional<String> catalog, Optional
message = "\n===\n" + message + "\n===";
}
catch (Exception ignored) {
// ignore
Copy link
Member

Choose a reason for hiding this comment

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

All these "// ignore" comments are noisy and unnecessary. It is clear from the exception name and the empty body that the exception is being ignored.

Copy link
Member Author

@losipiuk losipiuk Oct 30, 2024

Choose a reason for hiding this comment

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

I wanted {} - but checkStyle complains.
Will do

{ 
}

@losipiuk losipiuk force-pushed the lukaszos/consistent-formatting-of-multiline-strings-f88f9b branch 3 times, most recently from 3f66eea to 1ddbc64 Compare October 31, 2024 10:35
@losipiuk losipiuk force-pushed the lukaszos/consistent-formatting-of-multiline-strings-f88f9b branch from 1ddbc64 to 4417f07 Compare October 31, 2024 12:23
@losipiuk losipiuk merged commit b58e505 into trinodb:master Oct 31, 2024
94 of 95 checks passed
@github-actions github-actions bot added this to the 465 milestone Oct 31, 2024
@mosabua
Copy link
Member

mosabua commented Oct 31, 2024

I recently played with the spotless plugin .. its MUCH nicer than checkstyle .. we should migrate to it .. upon request from @losipiuk I added this to the agenda for next maintainer meeting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bigquery BigQuery connector cla-signed delta-lake Delta Lake connector docs hive Hive connector hudi Hudi connector iceberg Iceberg connector jdbc Relates to Trino JDBC driver mongodb MongoDB connector
Development

Successfully merging this pull request may close these issues.

4 participants