attilapiros commented on code in PR #36585:
URL: https://github.com/apache/spark/pull/36585#discussion_r875357337


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala:
##########
@@ -392,10 +390,9 @@ object QueryParsingErrors extends QueryErrorsBase {
 
   def unexpectedFormatForResetConfigurationError(ctx: 
ResetConfigurationContext): Throwable = {
     new ParseException(
-      s"""
-         |Expected format is 'RESET' or 'RESET key'. If you want to include 
special characters
-         |in key, please use quotes, e.g., RESET `ke y`.
-       """.stripMargin.replaceAll("\n", " "), ctx)
+      s"""Expected format is 'RESET' or 'RESET key'. If you want to include 
special characters
+         |in key, please use quotes, e.g., RESET 
`key`.""".stripMargin.replaceAll("\n", " "),

Review Comment:
   As I see now this the same string as was used in 
`unexpectedFormatForSetConfigurationError`.
   I think we can introduce a `val` for it (in `QueryParsingErrors`) and reuse 
it. 



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala:
##########
@@ -369,13 +369,11 @@ object QueryParsingErrors extends QueryErrorsBase {
     new ParseException(errorClass = "DUPLICATE_KEY", messageParameters = 
Array(toSQLId(key)), ctx)
   }
 
-  def unexpectedFomatForSetConfigurationError(ctx: ParserRuleContext): 
Throwable = {
+  def unexpectedFormatForSetConfigurationError(ctx: ParserRuleContext): 
Throwable = {
     new ParseException(
-      s"""
-         |Expected format is 'SET', 'SET key', or 'SET key=value'. If you want 
to include
+      s"""Expected format is 'SET', 'SET key', or 'SET key=value'. If you want 
to include

Review Comment:
   This is definitely an improvement over the previous state but I think we can 
go a bit further:
   - The string interpolation is not needed as there is no outer val/var used 
inside.
   - I do not get why replaceAll was used in the first place but a simple 
string concat would do especially as there is no `"` within the content.
   
   So I would just simply:
   ```
   "Expected format is 'RESET' or 'RESET key'. If you want to include special 
characters " + 
   "in key, please use quotes, e.g., RESET `key`."
   ```
   So no `s"""`, no `stripMargin` and no `replaceAll("\n", " ")`
   
   
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to