You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/05/17 23:14:58 UTC

[GitHub] [spark] wypoon opened a new pull request, #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

wypoon opened a new pull request, #36585:
URL: https://github.com/apache/spark/pull/36585

   ### What changes were proposed in this pull request?
   1. Fix some typos in query parsing error messages.
   2. Remove extraneous whitespace in some messages. Add a space before "(line <number>, position <index>)" to improve readability.
   3. Fix a typo in a function name.
   
   ### Why are the changes needed?
   To improve usability.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. E.g., before this change, we may have an error
   ```
   scala> spark.sql("SET non-existent-key")
   org.apache.spark.sql.catalyst.parser.ParseException:
    Expected format is 'SET', 'SET key', or 'SET key=value'. If you want to include special characters in key, or include semicolon in value, please use quotes, e.g., SET `ke y`=`v;alue`.        (line 1, pos 0)
   
   == SQL ==
   SET non-existent-key
   ^^^
   
   ```
   After this change, the error message becomes
   ```
   org.apache.spark.sql.catalyst.parser.ParseException:
   Expected format is 'SET', 'SET key', or 'SET key=value'. If you want to include special characters in key, or include semicolon in value, please use quotes, e.g., SET `key`=`v;alue`. (line 1, pos 0)
   ```
   
   ### How was this patch tested?
   No tests needed, as the change is straightforward and simply to text formatting.
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] wypoon commented on a diff in pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
wypoon commented on code in PR #36585:
URL: https://github.com/apache/spark/pull/36585#discussion_r875345718


##########
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)

Review Comment:
   Besides the typo in "key", this way of formatting causes an extraneous space at the beginning and 7 extraneous spaces at the end.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] wypoon commented on a diff in pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
wypoon commented on code in PR #36585:
URL: https://github.com/apache/spark/pull/36585#discussion_r875380471


##########
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:
   It's very similar but not the same string. One is about SET and the other about RESET.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] attilapiros commented on a diff in pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] attilapiros commented on a diff in pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
attilapiros commented on code in PR #36585:
URL: https://github.com/apache/spark/pull/36585#discussion_r875386684


##########
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:
   Oh, my mistake. In this case we can do the same refactoring twice. 



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] wypoon commented on a diff in pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
wypoon commented on code in PR #36585:
URL: https://github.com/apache/spark/pull/36585#discussion_r875380133


##########
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:
   The `s` in `s"""` is not needed, as you point out. I believe the original author used `replaceAll` to avoid line breaks and make the message a single line.
   
   Sure, I can change to using simple concatenation of two strings.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] wypoon commented on a diff in pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
wypoon commented on code in PR #36585:
URL: https://github.com/apache/spark/pull/36585#discussion_r875347864


##########
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)

Review Comment:
   Note that other messages in this file besides the ones I changed do not end with any spaces.
   For this reason, I add a space in `ParseException#getMessage` before the `(line $l, pos $p)`.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] srowen commented on pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
srowen commented on PR #36585:
URL: https://github.com/apache/spark/pull/36585#issuecomment-1130654083

   Merged to master


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] wypoon commented on pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
wypoon commented on PR #36585:
URL: https://github.com/apache/spark/pull/36585#issuecomment-1129536896

   I'm going to roll back the change where I add a space before "(line `<number>`, position `<index>`)" as there are many tests that would need to be updated otherwise. 


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] wypoon commented on a diff in pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
wypoon commented on code in PR #36585:
URL: https://github.com/apache/spark/pull/36585#discussion_r875345718


##########
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)

Review Comment:
   Besides the typo in "key", this way of formatting causes an extraneous space at the beginning and 8 extraneous spaces at the end.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] srowen closed pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages

Posted by GitBox <gi...@apache.org>.
srowen closed pull request #36585: [MINOR][SQL] Fix typos and formatting in query parsing error messages
URL: https://github.com/apache/spark/pull/36585


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org