belugabehr commented on a change in pull request #2007:
URL: https://github.com/apache/hive/pull/2007#discussion_r581086539
##########
File path:
serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java
##########
@@ -1124,33 +1125,25 @@ public static Date getDate(Object o,
PrimitiveObjectInspector oi) {
case STRING:
StringObjectInspector soi = (StringObjectInspector) oi;
String s = soi.getPrimitiveJavaObject(o).trim();
- try {
- if (s.length() == DATE_LENGTH) {
- result = Date.valueOf(s);
- } else {
- Timestamp ts = getTimestampFromString(s);
- if (ts != null) {
- result = Date.ofEpochMilli(ts.toEpochMilli());
- }
+ if (s.length() == DATE_LENGTH) {
+ result = DateParser.parseDate(s);
+ } else {
+ Timestamp ts = getTimestampFromString(s);
+ if (ts != null) {
+ result = Date.ofEpochMilli(ts.toEpochMilli());
}
- } catch (IllegalArgumentException e) {
- // Do nothing
Review comment:
The net effect here for `Do nothing` is to return a `null` value.
`DateParser#parseDate` returns a `null` value instead of an Exception, so can
remove this confusing try/catch block.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]