-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[FLINK-38087][sql-gateway] Improve OperationExecutor error messages and Java stream usage #26781
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
base: master
Are you sure you want to change the base?
Conversation
@fsk119 Could you take a look? Thanks |
@flinkbot run azure |
@@ -193,6 +194,7 @@ public ResultFetcher configureSession(OperationHandle handle, String statement) | |||
String.format( | |||
"Unsupported statement for configuring session:%s\n" | |||
+ "The configureSession API only supports to execute statement of type " | |||
+ "SET, RESET, " |
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.
nit: the previous line's english is not great. I suggest:
The configureSession API only supports executing statements of type
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.
nit: could we put all of these values into a variable we just iterate. Ideally the variable would be derived from what the API uses to validate.
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.
Currently there is no "operation name" available for operations. There is a asSummaryString
in the interface but it's at instance level which returns the whole clause of the operation with values/properties.
Existing code has separated operation check and error messages. We can try to consolidate them with a variable - a Map of allowed Operations and their names. It would be easier when adding new operations. Let me update the code.
The main difference is, the new way does not group operations by semantics as the existing code does. For e.g. all database related messages are currently placed together, as seen "CREATE DATABASE, DROP DATABASE, ALTER DATABASE, "
. I think that probably is fine if we group by operations.
...ateway/src/main/java/org/apache/flink/table/gateway/service/operation/OperationExecutor.java
Outdated
Show resolved
Hide resolved
...ql-gateway/src/test/java/org/apache/flink/table/gateway/service/SqlGatewayServiceITCase.java
Outdated
Show resolved
Hide resolved
…nd Java stream usage The configureSession() error message does not include SET/RESET. There are also some usages of Java stream which can be improved. This diff fixes them.
+ "LOAD MODULE, UNLOAD MODULE, USE MODULE, " | ||
+ "ADD JAR.", | ||
statement)); | ||
"Unsupported statement for configuring session: %s\n" |
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.
Good catch! Was this PR generated with the AI assistant?
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.
Great question. And thanks for reviewing!
I started with a simple fix of the incomplete error message and later a few ad hoc Java improvements when I read the code for the patch. Those are simple to implement so I didn't use AI tooling.
When addressing the specific comment of putting things in a variable, I found it is not straightforward to automatically "infer" the error message from all supported operations. I asked AI assistant and it gave me a much bigger change by defining "getting operation name" for all operations. I think that is too much for just error message constructing. So I went with the current approach , which is still better than existing code as it couples the supported operations with the error message by a single local variable.
https://issues.apache.org/jira/browse/FLINK-38087
What is the purpose of the change
The configureSession() error message does not include SET/RESET. There are also some usages of Java stream which can be improved.
This diff fixes them.
Brief change log
(for example:)
configureSession()
EnumSet
instead of Arrays->List for set contains operationsCollectors.toUnmodifiableSet
to collect from Java streams instead of wrapping a HashSetOptional.isEmpty
instead of!Optional.isPresent()
Verifying this change
Using existing unit and integration tests.
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (yes / no)Documentation