zabetak commented on code in PR #4545:
URL: https://github.com/apache/hive/pull/4545#discussion_r1289753952


##########
common/src/java/org/apache/hadoop/hive/common/type/Date.java:
##########
@@ -175,22 +178,16 @@ public void setTimeInMillis(long epochMilli) {
    */
   public static Date valueOf(final String text) {
     String s = Objects.requireNonNull(text).trim();
-    int idx = s.indexOf(" ");
-    if (idx != -1) {
-      s = s.substring(0, idx);
-    } else {
-      idx = s.indexOf('T');
-      if (idx != -1) {
-        s = s.substring(0, idx);
-      }
-    }
-    LocalDate localDate;
+    ParsePosition pos = new ParsePosition(0);
     try {
-      localDate = LocalDate.parse(s, PARSE_FORMATTER);
+      TemporalAccessor t = PARSE_FORMATTER.parseUnresolved(s, pos);
+      if (pos.getErrorIndex() >= 0) {
+        throw new DateTimeParseException("Text could not be parsed to date", 
s, pos.getErrorIndex());

Review Comment:
   Originally, I removed the entire try-catch block to let the 
`DateTimeException` propagate but this had side-effects since some consumers 
and tests were expecting the `IllegalArgumentException` to function properly. 
Then, I decided to not touch the `IllegalArgumentException` as part of this 
change to minimize such side-effects and unwanted changes in behavior.
   
   I plan to remove the IllegalArgumentException altogether in a follow-up 
patch.



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

Reply via email to