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

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

                Author: ASF GitHub Bot
            Created on: 01/Jul/21 11:11
            Start Date: 01/Jul/21 11:11
    Worklog Time Spent: 10m 
      Work Description: ashish-kumar-sharma commented on a change in pull 
request #2437:
URL: https://github.com/apache/hive/pull/2437#discussion_r662174416



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDateDiff.java
##########
@@ -64,121 +66,46 @@
         + "  1")
 @VectorizedExpressions({VectorUDFDateDiffColScalar.class, 
VectorUDFDateDiffColCol.class, VectorUDFDateDiffScalarCol.class})
 public class GenericUDFDateDiff extends GenericUDF {
-  private transient Converter inputConverter1;
-  private transient Converter inputConverter2;
+  private final transient Converter[] tsConverters = new Converter[2];
   private IntWritable output = new IntWritable();
-  private transient PrimitiveCategory inputType1;
-  private transient PrimitiveCategory inputType2;
-  private IntWritable result = new IntWritable();
+  private final transient PrimitiveCategory[] tsInputTypes = new 
PrimitiveCategory[2];
+
 
   public GenericUDFDateDiff() {
   }
 
   @Override
   public ObjectInspector initialize(ObjectInspector[] arguments) throws 
UDFArgumentException {
-    if (arguments.length != 2) {
-      throw new UDFArgumentLengthException(
-        "datediff() requires 2 argument, got " + arguments.length);
-    }
-    inputConverter1 = checkArguments(arguments, 0);
-    inputConverter2 = checkArguments(arguments, 1);
-    inputType1 = ((PrimitiveObjectInspector) 
arguments[0]).getPrimitiveCategory();
-    inputType2 = ((PrimitiveObjectInspector) 
arguments[1]).getPrimitiveCategory();
-    ObjectInspector outputOI = 
PrimitiveObjectInspectorFactory.writableIntObjectInspector;
-    return outputOI;
+    checkArgsSize(arguments,2,2);
+    checkArgPrimitive(arguments, 0);
+    checkArgPrimitive(arguments, 1);
+    checkArgGroups(arguments, 0, tsInputTypes, STRING_GROUP, DATE_GROUP);
+    checkArgGroups(arguments, 1, tsInputTypes, STRING_GROUP, DATE_GROUP);
+    obtainTimestampConverter(arguments,0, tsInputTypes, tsConverters);
+    obtainTimestampConverter(arguments,1, tsInputTypes, tsConverters);

Review comment:
       Done




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 617521)
    Time Spent: 1.5h  (was: 1h 20m)

> Refactor GenericUDFDateDiff
> ---------------------------
>
>                 Key: HIVE-25297
>                 URL: https://issues.apache.org/jira/browse/HIVE-25297
>             Project: Hive
>          Issue Type: Task
>          Components: UDF
>    Affects Versions: All Versions
>            Reporter: Ashish Sharma
>            Assignee: Ashish Sharma
>            Priority: Trivial
>              Labels: pull-request-available
>             Fix For: 4.0.0
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Description
> Remove redundant code and refactor entire GenericUDFDateDiff.class code



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

Reply via email to