Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-38929

Improve error messages for cast failures in ANSI

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.3.0
    • 3.3.0, 3.4.0
    • SQL
    • None

    Description

      Improve several error messages for cast failures in ANSI.

      Cast to numeric types

      java.lang.NumberFormatException: invalid input syntax for type numeric: 1.0. To return NULL instead, use 'try_cast'. ...

      This is confusing as 1.0 is numeric to an average user. Need to mention the specific target type (integer in this case) and put 1.0 in single quotes. If we can mention this is a cast from string to an integer that’s even better.

      Proposed change

      Invalid `int` literal: '1.0'. To return NULL instead, use 'try_cast'.

      Cast to date types

      java.time.DateTimeException: Cannot cast 2021-09- 2 to DateType.

      Can align with the above change.

      Proposed change

      Invalid `date` literal: '2021-09- 2'. To return NULL instead, use 'try_cast'.

      Attachments

        There are no Sub-Tasks for this issue.

        Activity

          People

            xyyu Xinyi Yu
            xyyu Xinyi Yu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: