Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-28589 Introduce a new type coercion mode by following PostgreSQL
  3. SPARK-28503

Return null result on cast an out-of-range value to a integral type

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 3.0.0
    • None
    • SQL
    • None

    Description

      Currently, when we convert an out-of-range value to a numeric type, the value is unexpected
      scala> spark.sql("select cast(327689 as short)").show()
      ------------------------

      CAST(327689 AS SMALLINT)

      ------------------------

      9

      ------------------------

      The result is actually 327689.toShort (327689 & 0xffff).
      For such cases, I think we should return null.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Gengliang.Wang Gengliang Wang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: