Skip to content

Annotate semanticException factories as format methods#15963

Closed
ksobolew wants to merge 3 commits intotrinodb:masterfrom
ksobolew:kudi/error-prone-format-method-semantic-exception
Closed

Annotate semanticException factories as format methods#15963
ksobolew wants to merge 3 commits intotrinodb:masterfrom
ksobolew:kudi/error-prone-format-method-semantic-exception

Conversation

@ksobolew
Copy link
Copy Markdown
Contributor

@ksobolew ksobolew commented Feb 3, 2023

Description

This annotation allows more cases to be checked by the FormatStringAnnotation checker. Fixes up all the trivial cases where they can be used as a format methods but weren't.

Additional context and related issues

Extracted from #14933.

Release notes

(x) This is not user-visible or 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:

# Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot Bot added the cla-signed label Feb 3, 2023
@ksobolew ksobolew changed the title Kudi/error prone format method semantic exception Annotate semanticException factories as format methods Feb 3, 2023
Comment thread core/trino-main/src/main/java/io/trino/execution/SetSessionTask.java Outdated
Comment thread core/trino-main/src/main/java/io/trino/sql/analyzer/AggregationAnalyzer.java Outdated
Comment thread core/trino-main/src/main/java/io/trino/sql/analyzer/AggregationAnalyzer.java Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it because one @FormatMethod cannot delegate to other @FormatMethod?
if so, seems like error-prone's bug to me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It can, but looks like it gets confused by them being different types. I wasn't sure if this is a bug or a weird corner case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it doesn't look like we were doing anything wrong here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The actual message is:

java: [FormatStringAnnotation] The format argument types passed with an @FormatString must match the types of the format arguments in the @FormatMethod header where the format string was declared.
  	Format arg types passed: [io.trino.spi.type.Type, io.trino.spi.type.Type]
  	Format arg types expected: [io.trino.sql.tree.Expression, io.trino.sql.tree.Expression]

Thing is, the message is the same but the message arguments passed to semanticException are not the same as the parameters of the enclosing method. So it kinda sorta makes sense?

@ksobolew ksobolew force-pushed the kudi/error-prone-format-method-semantic-exception branch 3 times, most recently from e085a75 to 96fec41 Compare February 6, 2023 10:29
@ksobolew
Copy link
Copy Markdown
Contributor Author

ksobolew commented Feb 6, 2023

maven-checks failed because Ubuntu is flaky:

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease  Could not connect to archive.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.36), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.39), connection timed out [IP: 185.125.190.36 80]

@ksobolew ksobolew force-pushed the kudi/error-prone-format-method-semantic-exception branch from 96fec41 to 024dee9 Compare February 20, 2023 12:26
@github-actions
Copy link
Copy Markdown

This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua

This method is unusual in that it takes a error message as a format
string and exactly two arguments; the annotation will make sure that the
format string will also be valid for exactly two arguments.
This makes it consistent with the rest of the method, where all the
error messages have the property name.
This annotation allows more cases to be checked by the
`FormatStringAnnotation` checker. Fixes up all the trivial cases where
they can be used as a format methods but weren't.
@ksobolew ksobolew force-pushed the kudi/error-prone-format-method-semantic-exception branch from 024dee9 to cc1c2ce Compare October 25, 2023 09:21
@ksobolew
Copy link
Copy Markdown
Contributor Author

Pushed an update with some fresh specimens from a recent large merge.

@github-actions github-actions Bot added the hive Hive connector label Oct 25, 2023
@ksobolew
Copy link
Copy Markdown
Contributor Author

Obsoleted by #19899, specifically f3c803e

@ksobolew ksobolew closed this Nov 27, 2023
@ksobolew ksobolew deleted the kudi/error-prone-format-method-semantic-exception branch November 27, 2023 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed hive Hive connector

Development

Successfully merging this pull request may close these issues.

2 participants