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

   ### What changes were proposed in this pull request?
   In the PR, I propose to remove the `ILLEGAL_SUBSTRING` error class, and use 
`INVALID_PARAMETER_VALUE` in the case when the `strfmt` parameter of the 
`format_string()` function contains `%0$`. The last value is handled 
differently by JDKs:  _"... Java 8 and Java 11 uses it as "%1$", and Java 17 
throws IllegalFormatArgumentIndexException(Illegal format argument index = 0)"_.
   
   This is a backport of https://github.com/apache/spark/pull/36380.
   
   ### Why are the changes needed?
   To improve code maintenance and user experience with Spark SQL by reducing 
the number of user-facing error classes. 
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, it changes user-facing error message.
   
   Before:
   ```sql
   spark-sql> select format_string('%0$s', 'Hello');
   Error in query: [ILLEGAL_SUBSTRING] The argument_index of string format 
cannot contain position 0$.; line 1 pos 7
   ```
   
   After:
   ```sql
   spark-sql> select format_string('%0$s', 'Hello');
   Error in query: [INVALID_PARAMETER_VALUE] The value of parameter(s) 'strfmt' 
in `format_string` is invalid: expects %1$, %2$ and so on, but got %0$.; line 1 
pos 7
   ```
   
   ### How was this patch tested?
   By running the affected test suites:
   ```
   $ build/sbt "test:testOnly *SparkThrowableSuite"
   $ build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z 
text.sql"
   $ build/sbt "test:testOnly *QueryCompilationErrorsSuite"
   ```
   
   Authored-by: Max Gekk <[email protected]>
   Signed-off-by: Max Gekk <[email protected]>
   (cherry picked from commit 9dcc24c36f6fcdf43bf66fe50415be575f7b2918)
   Signed-off-by: Max Gekk <[email protected]>


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