Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-33772 Build and Run Spark on Java 17
  3. SPARK-37013

`select format_string('%0$s', 'Hello')` has different behavior when using java 8 and Java 17

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.3.0
    • 3.3.0
    • SQL
    • Hide
      Since Spark 3.3, the `strfmt` in `format_string(strfmt, obj, ...)` and `printf(strfmt, obj, ...)` will no longer support to use "0$" to specify the first argument, the first argument should always reference by "1$" when use argument index to indicating the position of the argument in the argument list.
      Show
      Since Spark 3.3, the `strfmt` in `format_string(strfmt, obj, ...)` and `printf(strfmt, obj, ...)` will no longer support to use "0$" to specify the first argument, the first argument should always reference by "1$" when use argument index to indicating the position of the argument in the argument list.

    Description

      --PostgreSQL throw ERROR:  format specifies argument 0, but arguments are numbered from 1
      select format_string('%0$s', 'Hello');
      

      Execute with Java 8

      -- !query
      select format_string('%0$s', 'Hello')
      -- !query schema
      struct<format_string(%0$s, Hello):string>
      -- !query output
      Hello
      

      Execute with Java 17

      -- !query
      select format_string('%0$s', 'Hello')
      -- !query schema
      struct<>
      -- !query output
      java.util.IllegalFormatArgumentIndexException
      Illegal format argument index = 0
      

       

      Attachments

        Activity

          People

            LuciferYang Yang Jie
            LuciferYang Yang Jie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: