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

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

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



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTimestamp.java
##########
@@ -63,61 +71,44 @@
    * otherwise, it's interpreted as timestamp in seconds.
    */
   private boolean intToTimestampInSeconds = false;
+  private boolean strict = true;
 
   @Override
   public ObjectInspector initialize(ObjectInspector[] arguments) throws 
UDFArgumentException {
-    if (arguments.length < 1) {
-      throw new UDFArgumentLengthException(
-          "The function TIMESTAMP requires at least one argument, got "
-          + arguments.length);
-    }
-
-    SessionState ss = SessionState.get();
-    if (ss != null) {
-      intToTimestampInSeconds = 
ss.getConf().getBoolVar(ConfVars.HIVE_INT_TIMESTAMP_CONVERSION_IN_SECONDS);
-    }
+    checkArgsSize(arguments, 1, 1);
+    checkArgPrimitive(arguments, 0);
+    checkArgGroups(arguments, 0, tsInputTypes, STRING_GROUP, DATE_GROUP, 
NUMERIC_GROUP, VOID_GROUP, BOOLEAN_GROUP);
 
-    try {
-      argumentOI = (PrimitiveObjectInspector) arguments[0];
-    } catch (ClassCastException e) {
-      throw new UDFArgumentException(
-          "The function TIMESTAMP takes only primitive types");
-    }
+    strict = SessionState.get() != null ? SessionState.get().getConf()
+        .getBoolVar(ConfVars.HIVE_STRICT_TIMESTAMP_CONVERSION) : new HiveConf()
+        .getBoolVar(ConfVars.HIVE_STRICT_TIMESTAMP_CONVERSION);
+    intToTimestampInSeconds = SessionState.get() != null ? 
SessionState.get().getConf()
+        .getBoolVar(ConfVars.HIVE_INT_TIMESTAMP_CONVERSION_IN_SECONDS) : new 
HiveConf()
+        .getBoolVar(ConfVars.HIVE_INT_TIMESTAMP_CONVERSION_IN_SECONDS);
 
-    if (ss != null && 
ss.getConf().getBoolVar(ConfVars.HIVE_STRICT_TIMESTAMP_CONVERSION)) {
-      PrimitiveCategory category = argumentOI.getPrimitiveCategory();
-      PrimitiveGrouping group = 
PrimitiveObjectInspectorUtils.getPrimitiveGrouping(category);
-      if (group == PrimitiveGrouping.NUMERIC_GROUP) {
+    if (strict) {

Review comment:
       @adesh-rao this is right sequence of validation check. All methods 
called  with in the initialize() methods throw exception. 




-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

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

> Refactor UDF CAST(<Date string> as TIMESTAMP)
> ---------------------------------------------
>
>                 Key: HIVE-25334
>                 URL: https://issues.apache.org/jira/browse/HIVE-25334
>             Project: Hive
>          Issue Type: Sub-task
>            Reporter: Ashish Sharma
>            Assignee: Ashish Sharma
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Description 
> Refactor GenericUDFTimestamp.class 
> DOD
> Refactor 



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

Reply via email to