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

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

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



##########
File path: 
serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java
##########
@@ -1254,9 +1260,13 @@ public static Timestamp getTimestampFromString(String s) 
{
     s = s.trim();
     s = trimNanoTimestamp(s);
 
+    if(StringUtils.isEmpty(s))
+      return null;
+
     try {
       return TimestampUtils.stringToTimestamp(s);
-    } catch (IllegalArgumentException e) {
+    } catch (IllegalArgumentException | DateTimeException e) {
+      LOG.info("cannot parse datetime : {}", s);

Review comment:
       Removed

##########
File path: common/src/java/org/apache/hive/common/util/TimestampParser.java
##########
@@ -191,7 +190,13 @@ public Timestamp parseTimestamp(final String text)
         LOG.debug("Could not parse timestamp text: {}", text);
       }
     }
-    return Timestamp.valueOf(text);
+    Timestamp timestamp = null;
+    try {
+      timestamp = Timestamp.valueOf(text);
+    } catch (IllegalArgumentException e) {
+      LOG.info(e.getMessage());

Review comment:
       Removed

##########
File path: common/src/test/org/apache/hive/common/util/TestTimestampParser.java
##########
@@ -47,12 +47,18 @@ public void testDefault() {
 
     Assert.assertEquals(Timestamp.valueOf("1945-12-31T23:59:59"),
         tsp.parseTimestamp("1945-12-31 23:59:59"));
+
   }
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void testDefaultInvalid() {
     final TimestampParser tsp = new TimestampParser();
-    tsp.parseTimestamp("12345");
+    Assert.assertEquals(null, tsp.parseTimestamp("12345"));
+    Assert.assertEquals(null, tsp.parseTimestamp("1945-12-45 23:59:59"));
+    Assert.assertEquals(null, tsp.parseTimestamp("1945-15-20 23:59:59"));
+    Assert.assertEquals(null, tsp.parseTimestamp("0000-00-00 00:00:00"));
+    Assert.assertEquals(null, tsp.parseTimestamp(""));
+    Assert.assertEquals(null, tsp.parseTimestamp("null"));

Review comment:
       Done

##########
File path: common/src/test/org/apache/hive/common/util/TestTimestampParser.java
##########
@@ -25,7 +25,7 @@
 /**
  * Test suite for parsing timestamps.
  */
-public class TestTimestampParser {
+public class  TestTimestampParser {

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

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


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

    Worklog Id:     (was: 626222)
    Time Spent: 2h 40m  (was: 2.5h)

> Move Date and Timestamp parsing from ResolverStyle.LENIENT to 
> ResolverStyle.STRICT
> ----------------------------------------------------------------------------------
>
>                 Key: HIVE-25306
>                 URL: https://issues.apache.org/jira/browse/HIVE-25306
>             Project: Hive
>          Issue Type: Bug
>          Components: Query Planning, UDF
>            Reporter: Ashish Sharma
>            Assignee: Ashish Sharma
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: DB_compare.JPG
>
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> Description - 
> Currently Date.java and Timestamp.java use DateTimeFormatter for parsing to 
> convert the date/timpstamp from int,string,char etc to Date or Timestamp. 
> Default DateTimeFormatter which use ResolverStyle.LENIENT which mean date 
> like "1992-13-12" is converted to "2000-01-12", 
> Moving DateTimeFormatter which use ResolverStyle.STRICT which mean date like 
> "1992-13-12" is not be converted instead NULL is return.
> https://docs.google.com/document/d/1YTTPlNq3qyzlKfYVkSl3EFhVQ6-wa9WFRdkdIeCoc1Y/edit?usp=sharing
>  



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

Reply via email to