GitHub user tejasapatil opened a pull request:

    https://github.com/apache/spark/pull/17056

    [SPARK-17495] [SQL] Support Decimal type in Hive-hash

    ## What changes were proposed in this pull request?
    
    Hive hash to support Decimal datatype. [Hive internally normalises 
decimals](https://github.com/apache/hive/blob/4ba713ccd85c3706d195aeef9476e6e6363f1c21/storage-api/src/java/org/apache/hadoop/hive/common/type/HiveDecimalV1.java#L307)
 and I have ported that logic as-is to HiveHash.
    
    Generated code (in case any reviewer wants to examine):
    
    ```
    /* 031 */   protected void processNext() throws java.io.IOException {
    /* 032 */     while (inputadapter_input.hasNext() && !stopEarly()) {
    /* 033 */       InternalRow inputadapter_row = (InternalRow) 
inputadapter_input.next();
    /* 034 */       project_value = 0;
    /* 035 */
    /* 036 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 037 */       Decimal inputadapter_value = inputadapter_isNull ? null : 
(inputadapter_row.getDecimal(0, 38, 0));
    /* 038 */       if (!inputadapter_isNull) {
    /* 039 */         project_childHash = 
org.apache.spark.sql.catalyst.expressions.HiveHashFunction.normalizeDecimal(
    /* 040 */           inputadapter_value.toJavaBigDecimal(), true).hashCode();
    /* 041 */       }
    /* 042 */       project_value = (31 * project_value) + project_childHash;
    /* 043 */       project_childHash = 0;
    /* 044 */       project_rowWriter.write(0, project_value);
    /* 045 */       append(project_result);
    /* 046 */       if (shouldStop()) return;
    /* 047 */     }
    /* 048 */   }
    ```
    
    ## How was this patch tested?
    
    Added unit tests

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tejasapatil/spark SPARK-17495_decimal

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/17056.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #17056
    
----
commit a378b3ef08cead4c915096f11de5bd371a405fef
Author: Tejas Patil <[email protected]>
Date:   2017-02-24T07:35:16Z

    [SPARK-17495] [SQL] Support Decimal type

----


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to