Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-33354 New explicit cast syntax rules in ANSI mode
  3. SPARK-38407

ANSI Cast: loosen the limitation of casting non-null complex types

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.3.0, 3.2.2
    • 3.3.0, 3.2.2
    • SQL
    • None

    Description

      When ANSI mode is off, `ArrayType(DoubleType, containsNull = false)` can't cast as `ArrayType(IntegerType, containsNull = false)` since there can be overflow thus result in null results and breaks the non-null constraint.

       

      When ANSI mode is on, currently Spark SQL has the same behavior. However, this is not correct since the non-null constraint won't be break. Spark SQL can just execute the cast and throw runtime error on overflow, just like casting DoubleType as IntegerType.

       

      This applies to MapType and StructType as well.

       

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: