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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]