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

store assignable if there exists an appropriate user-defined cast function

    XMLWordPrintableJSON

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 3.0.0
    • Fix Version/s: None
    • Component/s: SQL
    • Labels:
      None

      Description

      9.2 Store assignment

      Syntax Rules

      1) Let T be the TARGET and let V be the VALUE in an application of the Syntax Rules of this Subclause.
      2) Let TD and SD be the declared types of T and V, respectively.
      3) If TD is character string, binary string, numeric, boolean, datetime, interval, or a user-defined type, then
      either SD shall be assignable to TD or there shall exist an appropriate user-defined cast function UDCF
      from SD to TD.
      NOTE 319 — “Appropriate user-defined cast function” is defined in Subclause 4.11, “Data conversions”

       4.11 Data conversions

      Implicit type conversion can occur in expressions, fetch operations, single row select operations, inserts, deletes,
      and updates. Explicit type conversions can be specified by the use of the CAST operator.

       

      The current implementation for ANSI store assignment is totally out of context. 

      According to this rule, `there shall exist an appropriate user-defined cast function UDCF`, the spark legacy store assignment is just fine because we do have appropriate cast functions.

      At least according to the ansi cast rule, the current ANSI assignment policy is too strict to the ANSI cast rules

       

      * (SD) --------------------- (TD) -------------------------
      *     | EN  AN  C  D  T  TS  YM  DT  BO  UDT  B  RT  CT  RW
      * EN  |  Y   Y  Y  N  N   N   M   M   N   M   N   M   N   N
      * AN  |  Y   Y  Y  N  N   N   N   N   N   M   N   M   N   N
      *  C  |  Y   Y  Y  Y  Y   Y   Y   Y   Y   M   N   M   N   N
      *  D  |  N   N  Y  Y  N   Y   N   N   N   M   N   M   N   N
      *  T  |  N   N  Y  N  Y   Y   N   N   N   M   N   M   N   N
      * TS  |  N   N  Y  Y  Y   Y   N   N   N   M   N   M   N   N
      * YM  |  M   N  Y  N  N   N   Y   N   N   M   N   M   N   N
      * DT  |  M   N  Y  N  N   N   N   Y   N   M   N   M   N   N
      * BO  |  N   N  Y  N  N   N   N   N   Y   M   N   M   N   N
      * UDT |  M   M  M  M  M   M   M   M   M   M   M   M   M   N
      *  B  |  N   N  N  N  N   N   N   N   N   M   Y   M   N   N
      * RT  |  M   M  M  M  M   M   M   M   M   M   M   M   N   N
      * CT  |  N   N  N  N  N   N   N   N   N   M   N   N   M   N
      * RW  |  N   N  N  N  N   N   N   N   N   N   N   N   N   M
      *
      * Where:
      * EN = Exact Numeric
      * AN = Approximate Numeric
      * C = Character (Fixed- or Variable-Length, or Character Large Object)
      * D = Date
      * T = Time
      * TS = Timestamp
      * YM = Year-Month Interval
      * DT = Day-Time Interval
      * BO = Boolean
      * UDT = User-Defined Type
      * B = Binary (Fixed- or Variable-Length or Binary Large Object)
      * RT = Reference type
      * CT = Collection type
      * RW = Row type
      

       

       

      cc Wenchen Fan Gengliang Wang Takeshi Yamamuro 

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Qin Yao Kent Yao
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: