hsyuan commented on a change in pull request #1163: [CALCITE-2995] Add the 
DAYNAME,MONTHNAME function
URL: https://github.com/apache/calcite/pull/1163#discussion_r275166963
 
 

 ##########
 File path: 
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
 ##########
 @@ -5761,6 +5761,88 @@ private void checkNullOperand(SqlTester tester, String 
op) {
     tester.checkNull("last_day(cast(null as timestamp))");
   }
 
+  @Test public void testDayName() {
+    tester.setFor(SqlStdOperatorTable.DAYNAME);
+    // test language for Chinese
+    Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
+    tester.checkScalar("dayname(DATE '2019-02-10')",
+            "星期日", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("dayname(TIMESTAMP '2019-02-10 02:10:12')",
+            "星期日", "VARCHAR(2000) NOT NULL");
+
+    // test language for English
+    Locale.setDefault(Locale.ENGLISH);
+    tester.checkScalar("dayname(DATE '2019-02-10')",
+            "Sunday", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("dayname(TIMESTAMP '2019-02-10 02:10:12')",
+            "Sunday", "VARCHAR(2000) NOT NULL");
+
+    // test language for Japanese
+    Locale.setDefault(Locale.JAPANESE);
+    tester.checkScalar("dayname(DATE '2019-02-10')",
+            "日曜日", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("dayname(TIMESTAMP '2019-02-10 02:10:12')",
+            "日曜日", "VARCHAR(2000) NOT NULL");
+
+    // test language for German
+    Locale.setDefault(Locale.GERMANY);
+    tester.checkScalar("dayname(DATE '2019-02-10')",
+            "Sonntag", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("dayname(TIMESTAMP '2019-02-10 02:10:12')",
+            "Sonntag", "VARCHAR(2000) NOT NULL");
+
+    // test language for French
+    Locale.setDefault(Locale.FRENCH);
+    tester.checkScalar("dayname(DATE '2019-02-10')",
+            "dimanche", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("dayname(TIMESTAMP '2019-02-10 02:10:12')",
+            "dimanche", "VARCHAR(2000) NOT NULL");
+
+    // finally, set the default to Chinese
+    Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
+  }
+
+  @Test public void testMonthName() {
+    tester.setFor(SqlStdOperatorTable.MONTHNAME);
+    // test language for Chinese
+    Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
+    tester.checkScalar("monthname(DATE '2019-02-10')",
+            "二月", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("monthname(TIMESTAMP '2019-02-10 02:10:12')",
+            "二月", "VARCHAR(2000) NOT NULL");
+
+    // test language for English
+    Locale.setDefault(Locale.ENGLISH);
+    tester.checkScalar("monthname(DATE '2019-02-10')",
+            "February", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("monthname(TIMESTAMP '2019-02-10 02:10:12')",
+            "February", "VARCHAR(2000) NOT NULL");
+
+    // test language for Japanese
+    Locale.setDefault(Locale.JAPANESE);
+    tester.checkScalar("monthname(DATE '2019-02-10')",
+            "2月", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("monthname(TIMESTAMP '2019-02-10 02:10:12')",
+            "2月", "VARCHAR(2000) NOT NULL");
+
+    // test language for German
+    Locale.setDefault(Locale.GERMANY);
+    tester.checkScalar("monthname(DATE '2019-02-10')",
+            "Februar", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("monthname(TIMESTAMP '2019-02-10 02:10:12')",
+            "Februar", "VARCHAR(2000) NOT NULL");
+
+    // test language for French
+    Locale.setDefault(Locale.FRENCH);
+    tester.checkScalar("monthname(DATE '2019-02-10')",
+            "février", "VARCHAR(2000) NOT NULL");
+    tester.checkScalar("monthname(TIMESTAMP '2019-02-10 02:10:12')",
+            "février", "VARCHAR(2000) NOT NULL");
+
+    // finally, set the default to Chinese
+    Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
+  }
+
 
 Review comment:
   Can you add test case for date before epoch?

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


With regards,
Apache Git Services

Reply via email to