[ 
https://issues.apache.org/jira/browse/HIVE-22515?focusedWorklogId=377961&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-377961
 ]

ASF GitHub Bot logged work on HIVE-22515:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Jan/20 01:14
            Start Date: 28/Jan/20 01:14
    Worklog Time Spent: 10m 
      Work Description: ramesh0201 commented on pull request #880: HIVE-22515 
Support cast to decimal64 in Vectorization
URL: https://github.com/apache/hive/pull/880#discussion_r371568274
 
 

 ##########
 File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/FuncLongToDecimal64.java
 ##########
 @@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.exec.vector.expressions;
+
+import java.util.Arrays;
+
+import org.apache.hadoop.hive.ql.exec.vector.Decimal64ColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import 
org.apache.hadoop.hive.ql.exec.vector.VectorizedExpressionsSupportDecimal64;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
+
+/**
+ * This is a superclass for unary long functions and expressions returning 
decimals that
+ * operate directly on the input and set the output.
+ */
+@VectorizedExpressionsSupportDecimal64()
+public abstract class FuncLongToDecimal64 extends VectorExpression {
+  private static final long serialVersionUID = 1L;
+  private final int inputColumn;
+
+  private static final long[] powerOfTenTable = {
+    1L,                   // 0
+    10L,
+    100L,
+    1_000L,
+    10_000L,
+    100_000L,
+    1_000_000L,
+    10_000_000L,
+    100_000_000L,           // 8
+    1_000_000_000L,
+    10_000_000_000L,
+    100_000_000_000L,
+    1_000_000_000_000L,
+    10_000_000_000_000L,
+    100_000_000_000_000L,
+    1_000_000_000_000_000L,
+    10_000_000_000_000_000L,   // 16
+    100_000_000_000_000_000L,
+    1_000_000_000_000_000_000L, // 18
+  };
+
+  public FuncLongToDecimal64(int inputColumn, int outputColumnNum) {
+    super(outputColumnNum);
+    this.inputColumn = inputColumn;
+  }
+
+  public FuncLongToDecimal64() {
+    super();
+
+    // Dummy final assignments.
+    inputColumn = -1;
+  }
+
+  abstract protected void func(Decimal64ColumnVector outputColVector, 
LongColumnVector inputColVector, int i,
+      long scaleFactor);
+
+  @Override
+  public void evaluate(VectorizedRowBatch batch) throws HiveException {
+
+    if (childExpressions != null) {
+      super.evaluateChildren(batch);
+    }
+
+    LongColumnVector inputColVector = (LongColumnVector) 
batch.cols[inputColumn];
+    int[] sel = batch.selected;
+    int n = batch.size;
+    Decimal64ColumnVector outputColVector = (Decimal64ColumnVector) 
batch.cols[outputColumnNum];
+    int outputScale = ((DecimalTypeInfo) outputTypeInfo).scale();
+    final long scaleFactor = powerOfTenTable[outputScale];
 
 Review comment:
   Yes, before we create cast expression, we verify if the output.precision + 
output.scale <= 18(to avoid intermediate overflow) and hence implicitly 
outputscale will be less than or equal to 18.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 377961)
    Time Spent: 40m  (was: 0.5h)

> Support cast to decimal64 in Vectorization
> ------------------------------------------
>
>                 Key: HIVE-22515
>                 URL: https://issues.apache.org/jira/browse/HIVE-22515
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Ramesh Kumar Thangarajan
>            Assignee: Ramesh Kumar Thangarajan
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-22515.5.patch, HIVE-22515.8.patch, 
> HIVE-22515.9.patch
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Support cast to decimal64 in Vectorization



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to