mihaibudiu commented on code in PR #3761:
URL: https://github.com/apache/calcite/pull/3761#discussion_r1566225540


##########
core/src/test/resources/sql/cast-with-format.iq:
##########
@@ -1155,7 +1108,7 @@ EXPR$0
 !ok
 
 !if (false) {
-### disabled until Bug.CALCITE_6269_FIXED ###
+### unsupported format model/elements, test disabled ###

Review Comment:
   this seems the same as the test in the change above on line 1091 above which 
is enabled



##########
core/src/test/resources/sql/cast-with-format.iq:
##########
@@ -361,7 +351,7 @@ EXPR$0
 select cast('2017-05-31' as
     timestamp FORMAT 'RRRR-MM-DD');
 EXPR$0
-2017-05-31 00:00:00
+0017-05-31 00:00:00

Review Comment:
   why is this correct?



##########
core/src/test/resources/sql/cast-with-format.iq:
##########
@@ -32,8 +32,15 @@ EXPR$0
 2017-05-01 01:23:45
 !ok
 
+# Input that contains shuffled date without time
+select cast('12-2010-05' as timestamp format
+    'DD-YYYY-MM');
+EXPR$0
+2010-05-12 00:00:00
+!ok
+
 !if (false) {
-### disabled until Bug.CALCITE_6269_FIXED ###
+### unsupported format model/elements, test disabled ###

Review Comment:
   There is a way in Quidem tests to refer to a Bug, why don't we use that one?
   The good thing about the previous version of this string is that you can 
grep for it, here it is not clear which bug tracks the problem.



##########
core/src/test/resources/sql/cast-with-format.iq:
##########
@@ -979,7 +939,7 @@ EXPR$0
 select cast(date'2019-01-07' as varchar
     FORMAT 'WW');
 EXPR$0
-01
+02

Review Comment:
   what is happening here?



##########
core/src/main/java/org/apache/calcite/util/format/FormatElementEnum.java:
##########
@@ -253,12 +373,27 @@ public enum FormatElementEnum implements FormatElement {
       sb.append(String.format(Locale.ROOT, "%02d", 
calendar.get(Calendar.WEEK_OF_YEAR)));
     }
   },
+  Y("y", "Last digit of year") {
+    @Override public void format(StringBuilder sb, Date date) {
+      final Work work = Work.get();
+      String formattedYear = work.yyFormat.format(date);
+      sb.append(formattedYear.substring(formattedYear.length() - 1));
+    }
+  },
   YY("yy", "Last 2 digits of year") {
     @Override public void format(StringBuilder sb, Date date) {
       final Work work = Work.get();
       sb.append(work.yyFormat.format(date));
     }
   },
+  YYY("yyy", "Last 3 digits of year") {
+    @Override public void format(StringBuilder sb, Date date) {
+      final Calendar calendar = Work.get().calendar;
+      calendar.setTime(date);
+      String formattedYear = String.format(Locale.ROOT, "%d", 
calendar.get(Calendar.YEAR));
+      sb.append(formattedYear.substring(formattedYear.length() - 3));

Review Comment:
   what happens for a year like 50?



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

Reply via email to