suibianwanwank commented on code in PR #3936:
URL: https://github.com/apache/calcite/pull/3936#discussion_r1738134180
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5185,6 +5187,61 @@ void testBitGetFunc(SqlOperatorFixture f, String
functionName) {
}
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6551">[CALCITE-6551]
+ * Add DATE_FORMAT function (enabled in MySQL library)</a>. */
+ @Test void testDateFormat() {
+ final SqlOperatorFixture f = fixture()
+ .withTester(t -> TESTER).withLibrary(SqlLibrary.MYSQL);
+ f.setFor(SqlLibraryOperators.DATE_FORMAT);
+ final Locale originalLocale = Locale.getDefault();
+
+ try {
+ Locale.setDefault(Locale.US);
+ f.checkString("date_format(timestamp '2009-10-04 22:23:00', '%W %M %Y')",
+ "Sunday October 2009",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '2009-10-04 22:23:00', '%H:%i:%s')",
+ "22:23:00",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '1900-10-04 22:23:00', '%D %y %a %d
%m %b %j')",
+ "4th 00 Thu 04 10 Oct 277",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '1997-10-04 22:23:00', '%H %k %I %r
%T %S %w')",
+ "22 22 10 10:23:00 PM 22:23:00 00 6",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '1999-01-01', '%X %V')",
+ "1998 52",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '1997-10-04 22:23:00.000000', '%c
%D %e %f %h')",
+ "10 4th 4 000000 10",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '1997-01-04 22:23:00', '%w %U %u %V
%v %X %x')",
+ "6 00 01 52 01 1996 1997",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '1997-01-05 22:23:00', '%w %U %u %V
%v %X %x')",
+ "0 01 01 01 01 1997 1997",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '1997-01-06 22:23:00', '%w %U %u %V
%v %X %x')",
+ "1 01 02 01 02 1997 1997",
+ "VARCHAR NOT NULL");
+ f.checkString("date_format(timestamp '1997-10-04 22:23:00', '%V %v %X %x
%%')",
+ "39 40 1997 1997 %",
+ "VARCHAR NOT NULL");
Review Comment:
It throws an exception:Illegal TIMESTAMP literal, In the timestamp scenario,
this is consistent with mysql's result.
Yes, I do these tests in mysql . In fact, I write these test cases in mysql
and get the results, and then add them to test to validate
--
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]