normanj-bitquill commented on code in PR #3753:
URL: https://github.com/apache/calcite/pull/3753#discussion_r1558284201
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -4465,44 +4465,35 @@ void testBitGetFunc(SqlOperatorFixture f, String
functionName) {
f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'YYYY-MM-DD
HH24:MI:SS.MS TZ')",
"2022-06-03 12:15:48.678",
"VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'Day')",
- "Friday",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '0001-01-01 00:00:00.000', 'Day')",
- "Monday",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'DY')",
- "Fri",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '0001-01-01 00:00:00.000', 'DY')",
- "Mon",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'CC')",
- "21",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'HH12')",
- "01",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'HH24')",
- "13",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'MI')",
- "15",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'MS')",
- "678",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'Q')",
- "2",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'IW')",
- "23",
- "VARCHAR NOT NULL");
f.checkNull("to_char(timestamp '2022-06-03 12:15:48.678', NULL)");
f.checkNull("to_char(cast(NULL as timestamp), NULL)");
f.checkNull("to_char(cast(NULL as timestamp), 'Day')");
}
+ @Test void testToDate() {
+ final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.POSTGRESQL);
+ f.setFor(SqlLibraryOperators.TO_DATE);
+
+ f.checkString("to_date('2022-06-03', 'YYYY-MM-DD')",
+ "2022-06-03",
+ "DATE NOT NULL");
+ f.checkFails("to_date('ABCD', 'YYYY-MM-DD')",
+ "java.sql.SQLException: Invalid format: 'YYYY-MM-DD' for datetime
string: 'ABCD'.",
+ true);
+ }
+
+ @Test void testToTimestamp() {
+ final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.POSTGRESQL);
+ f.setFor(SqlLibraryOperators.TO_TIMESTAMP);
+
+ f.checkString("to_timestamp('2022-06-03 18:34:56', 'YYYY-MM-DD
HH24:MI:SS')",
+ "2022-06-03 18:34:56",
+ "TIMESTAMP(0) NOT NULL");
+ f.checkFails("to_timestamp('ABCD', 'YYYY-MM-DD HH24:MI:SS')",
Review Comment:
Added more tests for both `TO_DATE` and `TO_TIMESTAMP`.
--
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]