XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 3.0.0, 3.1.0
    • 3.0.0
    • SQL
    • None

    Description

      spark-sql> select from_unixtime(1, 'yyyyyyyyyyy-MM-dd');
      NULL
      spark-sql> set spark.sql.legacy.timeParserPolicy=legacy;
      spark.sql.legacy.timeParserPolicy	legacy
      spark-sql> select from_unixtime(1, 'yyyyyyyyyyy-MM-dd');
      00000001970-01-01
      spark-sql>
      

      For patterns that support `SignStyle.EXCEEDS_PAD`, e.g. `y..y`(len >=4), when using the `NumberPrinterParser` to format it

      switch (signStyle) {
        case EXCEEDS_PAD:
          if (minWidth < 19 && value >= EXCEED_POINTS[minWidth]) {
            buf.append(decimalStyle.getPositiveSign());
          }
          break;
         
                 ....
      

      the `minWidth` == `len(y..y)`
      the `EXCEED_POINTS` is

      /**
               * Array of 10 to the power of n.
               */
              static final long[] EXCEED_POINTS = new long[] {
                  0L,
                  10L,
                  100L,
                  1000L,
                  10000L,
                  100000L,
                  1000000L,
                  10000000L,
                  100000000L,
                  1000000000L,
                  10000000000L,
              };
      

      So when the `len(y..y)` is greater than 10, ` ArrayIndexOutOfBoundsException` will be raised.

      And at the caller side, for `from_unixtime`, the exception will be suppressed and silent data change occurs. for `date_format`, the `ArrayIndexOutOfBoundsException` will continue.

      Attachments

        Activity

          People

            Qin Yao Kent Yao
            Qin Yao Kent Yao
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: