You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "caicancai (via GitHub)" <gi...@apache.org> on 2023/12/26 15:17:30 UTC

[PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

caicancai opened a new pull request, #3600:
URL: https://github.com/apache/calcite/pull/3600

   (no comment)


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
macroguo-ghy commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1869889820

   You need to log a JIRA case, because you have added new features.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3600:
URL: https://github.com/apache/calcite/pull/3600#discussion_r1437446175


##########
core/src/test/java/org/apache/calcite/util/format/FormatElementEnumTest.java:
##########
@@ -33,4 +33,130 @@ class FormatElementEnumTest {
     FormatElementEnum.DAY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
     assertThat(ts, hasToString("Tuesday"));
   }
+
+  @Test void testD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.D.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("3"));
+  }
+
+  @Test void testDD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DD.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("30"));
+  }
+
+  @Test void testDDD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DDD.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("273"));
+  }
+
+  @Test void testDY() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("Tue"));
+  }
+
+  @Test void testFF1() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF1.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("0"));
+  }
+
+  @Test void testFF2() {

Review Comment:
   Sorry, I misunderstood the meaning before, but I have corrected it now



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3600:
URL: https://github.com/apache/calcite/pull/3600#discussion_r1436579820


##########
core/src/test/java/org/apache/calcite/util/format/FormatElementEnumTest.java:
##########
@@ -33,4 +33,130 @@ class FormatElementEnumTest {
     FormatElementEnum.DAY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
     assertThat(ts, hasToString("Tuesday"));
   }
+
+  @Test void testD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.D.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));

Review Comment:
   Since the date is the same for all tests maybe you can factor it out in a separate helper function.
   This would also enable extending this testing code for other dates.
   



##########
core/src/test/java/org/apache/calcite/util/format/FormatElementEnumTest.java:
##########
@@ -33,4 +33,130 @@ class FormatElementEnumTest {
     FormatElementEnum.DAY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
     assertThat(ts, hasToString("Tuesday"));
   }
+
+  @Test void testD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.D.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("3"));
+  }
+
+  @Test void testDD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DD.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("30"));
+  }
+
+  @Test void testDDD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DDD.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("273"));
+  }
+
+  @Test void testDY() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("Tue"));
+  }
+
+  @Test void testFF1() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF1.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("0"));
+  }
+
+  @Test void testFF2() {

Review Comment:
   if these are microseconds perhaps you can use a datetime with microseconds?
   Does Java support microseconds in Date?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3600:
URL: https://github.com/apache/calcite/pull/3600#discussion_r1437323645


##########
core/src/test/java/org/apache/calcite/util/format/FormatElementEnumTest.java:
##########
@@ -33,4 +33,130 @@ class FormatElementEnumTest {
     FormatElementEnum.DAY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
     assertThat(ts, hasToString("Tuesday"));
   }
+
+  @Test void testD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.D.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("3"));
+  }
+
+  @Test void testDD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DD.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("30"));
+  }
+
+  @Test void testDDD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DDD.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("273"));
+  }
+
+  @Test void testDY() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("Tue"));
+  }
+
+  @Test void testFF1() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF1.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("0"));
+  }
+
+  @Test void testFF2() {

Review Comment:
   What API didn't you find?
   It looks like Instant.parse supports microseconds and date supports milliseconds.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1871749352

   @macroguo-ghy If you have time, can you help review my code? Thank you.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1869629368

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600) **Quality Gate passed**  
   Kudos, no new issues were introduced!
   
   [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_coverage&view=list)  
   [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
macroguo-ghy commented on code in PR #3600:
URL: https://github.com/apache/calcite/pull/3600#discussion_r1437428098


##########
core/src/main/java/org/apache/calcite/util/format/FormatElementEnum.java:
##########
@@ -201,6 +201,14 @@ public enum FormatElementEnum implements FormatElement {
       // TODO: how to support timezones?
     }
   },
+  W("w", "The week number of the month (Sunday as the first day of the week) as a decimal "

Review Comment:
   I think the javaFormat of `week of month` should be `W` instead of `w`.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1871796593

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600) **Quality Gate passed**  
   Kudos, no new issues were introduced!
   
   [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_coverage&view=list)  
   [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #3600:
URL: https://github.com/apache/calcite/pull/3600


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1869893626

   > You need to log a JIRA case, because you have added new features.
   
   Thank you for your reply


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3600:
URL: https://github.com/apache/calcite/pull/3600#discussion_r1437049603


##########
core/src/test/java/org/apache/calcite/util/format/FormatElementEnumTest.java:
##########
@@ -33,4 +33,130 @@ class FormatElementEnumTest {
     FormatElementEnum.DAY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
     assertThat(ts, hasToString("Tuesday"));
   }
+
+  @Test void testD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.D.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("3"));
+  }
+
+  @Test void testDD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DD.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("30"));
+  }
+
+  @Test void testDDD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DDD.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("273"));
+  }
+
+  @Test void testDY() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("Tue"));
+  }
+
+  @Test void testFF1() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF1.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    assertThat(ts, hasToString("0"));
+  }
+
+  @Test void testFF2() {

Review Comment:
   I didn't find the corresponding API



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1870914492

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600) **Quality Gate passed**  
   Kudos, no new issues were introduced!
   
   [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_coverage&view=list)  
   [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3600:
URL: https://github.com/apache/calcite/pull/3600#discussion_r1436686687


##########
core/src/test/java/org/apache/calcite/util/format/FormatElementEnumTest.java:
##########
@@ -33,4 +33,130 @@ class FormatElementEnumTest {
     FormatElementEnum.DAY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
     assertThat(ts, hasToString("Tuesday"));
   }
+
+  @Test void testD() {
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.D.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));

Review Comment:
   I'm trying, and I seem to have found some problems. If there are too many problems, I will open a Jira and try to fix them in this PR.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
macroguo-ghy commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1871783250

   @caicancai Did you miss my previous comment? I think you should add `week of month` to Format model for PostgreSQL. Please refer org.apache.calcite.util.format.FormatModels#POSTGRESQL and https://www.postgresql.org/docs/current/functions-formatting.html.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1869630329

   Is the result of format affected by the jdk version?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1870375247

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600) **Quality Gate passed**  
   Kudos, no new issues were introduced!
   
   [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_coverage&view=list)  
   [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1871787653

   > @caicancai Did you miss my previous comment? I think you should add `week of month` to Format model for PostgreSQL. Please refer org.apache.calcite.util.format.FormatModels#POSTGRESQL and https://www.postgresql.org/docs/current/functions-formatting.html.
   
   @macroguo-ghy I didn't seem to understand it before, I'm sorry about that, I understand it now, thank you for your reivew


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1872071726

   @macroguo-ghy @mihaibudiu Good to merge?


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "XuQianJin-Stars (via GitHub)" <gi...@apache.org>.
XuQianJin-Stars commented on code in PR #3600:
URL: https://github.com/apache/calcite/pull/3600#discussion_r1439208811


##########
core/src/test/java/org/apache/calcite/util/format/FormatElementEnumTest.java:
##########
@@ -29,8 +29,149 @@
  */
 class FormatElementEnumTest {
   @Test void testDay() {
+    final String date = "2014-09-30T10:00:00Z";
     StringBuilder ts = new StringBuilder();
-    FormatElementEnum.DAY.format(ts, Date.from(Instant.parse("2014-09-30T10:00:00Z")));
+    FormatElementEnum.DAY.format(ts, Date.from(Instant.parse(date)));
     assertThat(ts, hasToString("Tuesday"));
   }
+
+  @Test void testD() {
+    final String date = "2014-09-30T10:00:00Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.D.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("3"));
+  }
+
+  @Test void testDD() {
+    final String date = "2014-09-30T10:00:00Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DD.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("30"));
+  }
+
+  @Test void testDDD() {
+    final String date = "2014-09-30T10:00:00Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DDD.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("273"));
+  }
+
+  @Test void testDY() {
+    final String date = "2014-09-30T10:00:00Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.DY.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("Tue"));
+  }
+
+  @Test void testFF1() {
+    final String date = "2014-09-30T10:00:00.123456Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF1.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("123"));
+  }
+
+  @Test void testFF2() {
+    final String date = "2014-09-30T10:00:00.123456Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF2.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("123"));
+  }
+
+  @Test void testFF3() {
+    final String date = "2014-09-30T10:00:00.123456Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF3.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("123"));
+  }
+
+  @Test void testFF4() {
+    final String date = "2014-09-30T10:00:00.123456Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF4.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("0123"));
+  }
+
+  @Test void testFF5() {
+    final String date = "2014-09-30T10:00:00.123456Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF5.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("00123"));
+  }
+
+  @Test void testFF6() {
+    final String date = "2014-09-30T10:00:00.123456Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.FF6.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("000123"));
+  }
+
+  @Test void testIW() {
+    final String date = "2014-09-30T10:00:00Z";
+    StringBuilder ts = new StringBuilder();
+    FormatElementEnum.IW.format(ts, Date.from(Instant.parse(date)));
+    assertThat(ts, hasToString("40"));
+  }
+

Review Comment:
   There are too many duplicate codes in the test, which can be optimized and merged.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1869647480

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600) **Quality Gate passed**  
   Kudos, no new issues were introduced!
   
   [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_coverage&view=list)  
   [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3600:
URL: https://github.com/apache/calcite/pull/3600#discussion_r1437445754


##########
core/src/main/java/org/apache/calcite/util/format/FormatElementEnum.java:
##########
@@ -201,6 +201,14 @@ public enum FormatElementEnum implements FormatElement {
       // TODO: how to support timezones?
     }
   },
+  W("w", "The week number of the month (Sunday as the first day of the week) as a decimal "

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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add FormatElementEnumTests and add weekofmonth format [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1870337770

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600) **Quality Gate passed**  
   Kudos, no new issues were introduced!
   
   [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3600&resolved=false&inNewCodePeriod=true)  
   [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_coverage&view=list)  
   [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3600&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3600)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6179] Support weekofmonth function format and add test [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3600:
URL: https://github.com/apache/calcite/pull/3600#issuecomment-1872431869

   Thank you for the review


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org