yaooqinn opened a new pull request #26833: [WIP][SPARK-30203][SQL] store 
assignable if there is an appropriate user-defined cast function
URL: https://github.com/apache/spark/pull/26833
 
 
   …
   
   
   ### What changes were proposed in this pull request?
   #### 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
   
    
   ```scala
   * (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
    ```
   
   
   ### Why are the changes needed?
   
   the current ansi store assignment rule is not ansi.
   
   
   ### Does this PR introduce any user-facing change?
   
   yes, pending 
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some 
test cases that check the changes thoroughly including negative and positive 
cases if possible.
   If it was tested in a way different from regular unit tests, please clarify 
how you tested step by step, ideally copy and paste-able, so that other 
reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why 
it was difficult to add.
   -->
   add uts.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to