Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4004#discussion_r22815717
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
 ---
    @@ -154,6 +165,15 @@ trait HiveTypeCoercion {
        *
        * Additionally, all types when UNION-ed with strings will be promoted 
to strings.
        * Other string conversions are handled by PromoteStrings.
    +   * when mixing non-decimal types with decimals, we use the following 
rules:
    +   *   - BYTE gets turned into DECIMAL(3, 0)
    +   *   - SHORT gets turned into DECIMAL(5, 0)
    +   *   - INT gets turned into DECIMAL(10, 0)
    +   *   - LONG gets turned into DECIMAL(20, 0)
    +   *   - Fixed union decimals with precision/scale p1/s2 and p2/s2  will 
be promoted to
    +   *   DecimalType(max(p1, p2), max(s1, s2))
    --- End diff --
    
    Can you add the reference of this rule (the rule for union)? I checked 
http://msdn.microsoft.com/en-us/library/ms190476.aspx (I believe that Hive is 
based on this one). Seems the type will be 
    ```
    DecimalType(max(s1, s2) + max(p1-s1, p2-s2), max(s1, s2))
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to