zstan commented on code in PR #4363:
URL: https://github.com/apache/calcite/pull/4363#discussion_r2084414375
##########
core/src/test/java/org/apache/calcite/test/SqlFunctionsTest.java:
##########
@@ -1836,6 +1838,44 @@ private void thereAndBack(byte[] bytes) {
assertThat(toLongOptional(null), is(nullValue()));
}
+ /**
+ * Test date after 0001-01-01 required by ANSI SQL - is passed.
+ * Test date before 0001-01-01 and malformed date time literal - is failed.
+ */
+ @Test void testToTimestampWithLocalTimeZone() {
+ Long ret = toTimestampWithLocalTimeZone("1970-01-01 00:00:01",
TimeZone.getTimeZone("UTC"));
+ assertThat(ret, is(1000L));
+
+ ret = toTimestampWithLocalTimeZone("1970-01-01 00:00:01.010",
TimeZone.getTimeZone("UTC"));
+ assertThat(ret, is(1010L));
+
+ ret = toTimestampWithLocalTimeZone("1970-01-01 00:00:01 "
+ + TimeZone.getTimeZone("UTC").getID());
+ assertThat(ret, is(1000L));
+
+ // exceptional scenarios
+ try {
+ ret = toTimestampWithLocalTimeZone("malformed", TimeZone.getDefault());
+ fail("expected error, got " + ret);
+ } catch (RuntimeException e) {
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]