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

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.0.0
    • Fix Version/s: None
    • Component/s: SQL
    • Labels:
      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

              • Assignee:
                Unassigned
                Reporter:
                Gengliang.Wang Gengliang Wang
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: