spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tejasapatil <...@git.apache.org>
Subject [GitHub] spark pull request #17056: [SPARK-17495] [SQL] Support Decimal type in Hive-...
Date Wed, 01 Mar 2017 06:33:31 GMT
Github user tejasapatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17056#discussion_r103618852
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
---
    @@ -732,6 +743,51 @@ object HiveHashFunction extends InterpretedHashFunction {
         HiveHasher.hashUnsafeBytes(base, offset, len)
       }
     
    +  private val HiveDecimalMaxPrecision = 38
    +  private val HiveDecimalMaxScale = 38
    +
    +  // Mimics normalization done for decimals in Hive at HiveDecimalV1.normalize()
    +  def normalizeDecimal(input: BigDecimal, allowRounding: Boolean): BigDecimal = {
    +    if (input == null) {
    +      return null
    +    }
    +
    +    def trimDecimal(input: BigDecimal) = {
    +      var result = input
    +      if (result.compareTo(BigDecimal.ZERO) == 0) {
    +        // Special case for 0, because java doesn't strip zeros correctly on that number.
    +        result = BigDecimal.ZERO
    +      }
    +      else {
    --- End diff --
    
    changed


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message