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


##########
ql/src/test/queries/clientpositive/test_unixtimestamp_for_invaild_dates.q:
##########
@@ -0,0 +1,20 @@
+DESCRIBE FUNCTION UNIX_TIMESTAMP;

Review Comment:
   Instead of qtests better opt for unit tests. They are much faster and in 
this case they offer the exact same code coverage. Please add any new tests 
under `TestGenericUDFToUnixTimestampEvaluateStringString` and include also the 
output and result for `SIMPLE` formatter.
   
   IF the results between SIMPLE and DATETIME formatter are different explain 
why and clarify if it is desired.



##########
ql/src/test/queries/clientpositive/test_unixtimestamp_for_invaild_dates.q:
##########
@@ -0,0 +1,20 @@
+DESCRIBE FUNCTION UNIX_TIMESTAMP;

Review Comment:
   Please add or point to tests (preferably unit tests) with unix_timestamp, 
invalid dates, and no pattern. 
   
   For instance:
   ```
   unix_timestamp('2001-02-31')
   ```
   Is the behavior of the function inline with the variant that accepts a 
pattern?



##########
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/InstantDateTimeFormatter.java:
##########
@@ -25,15 +25,20 @@
 import java.time.LocalDate;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
+import java.time.chrono.IsoEra;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
+import java.time.format.ResolverStyle;
+import java.time.temporal.ChronoField;
 import java.util.Objects;
 
 final class InstantDateTimeFormatter extends 
InstantFormatterCache<DateTimeFormatter> {
 
   InstantDateTimeFormatter(final ZoneId zoneId) {
     super(zoneId,
-        s -> new 
DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern(s).toFormatter().withZone(zoneId));
+        s -> new DateTimeFormatterBuilder().parseCaseInsensitive()
+            .parseDefaulting(ChronoField.ERA, IsoEra.CE.getValue())

Review Comment:
   Why are we setting defaults? This is the first time that I see this method 
been used in Hive repo. Is there a risk of creating inconsistencies with other 
parts of the code?



##########
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/InstantDateTimeFormatter.java:
##########
@@ -49,7 +54,7 @@ public Instant parse(String text, String pattern) {
     Objects.requireNonNull(text);
     Objects.requireNonNull(pattern);
     Timestamp timestamp;
-    DateTimeFormatter formatter = getFormatter(pattern);
+    DateTimeFormatter formatter = 
getFormatter(pattern).withResolverStyle(ResolverStyle.STRICT);

Review Comment:
   This is going to create a copy of the `DateTimeFormatter` for every call to 
`parse` beating the purpose of the cache. Why we can't set the style in the 
constructor?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to