Vladsz83 commented on code in PR #11822: URL: https://github.com/apache/ignite/pull/11822#discussion_r1993525343
########## modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DateTimeTest.java: ########## @@ -202,6 +203,67 @@ public void testDstShift() throws Exception { } } + /** */ + @Test + public void testOldDateLiterals() { + assertQuery("SELECT DATE '1582-10-20'").returns(java.sql.Date.valueOf("1582-10-20")).check(); + assertQuery("SELECT DATE '1582-10-15'").returns(java.sql.Date.valueOf("1582-10-15")).check(); + assertQuery("SELECT DATE '1582-10-01'").returns(java.sql.Date.valueOf("1582-10-01")).check(); + assertQuery("SELECT DATE '1582-09-30'").returns(java.sql.Date.valueOf("1582-09-30")).check(); + assertQuery("SELECT DATE '1000-01-01'").returns(java.sql.Date.valueOf("1000-01-01")).check(); + assertQuery("SELECT DATE '0550-05-05'").returns(java.sql.Date.valueOf("0550-05-05")).check(); + + assertQuery("SELECT ?").returns(java.sql.Date.valueOf("1582-10-20")).withParams(java.sql.Date.valueOf("1582-10-20")).check(); + assertQuery("SELECT ?").returns(java.sql.Date.valueOf("1582-10-01")).withParams(java.sql.Date.valueOf("1582-10-01")).check(); + assertQuery("SELECT ?").returns(java.sql.Date.valueOf("1000-01-01")).withParams(java.sql.Date.valueOf("1000-01-01")).check(); + + assertQuery("SELECT TIMESTAMP '1582-10-20 17:12:47.111'").returns(Timestamp.valueOf("1582-10-20 17:12:47.111")) + .check(); + assertQuery("SELECT TIMESTAMP '1582-10-15 00:00:00.001'").returns(Timestamp.valueOf("1582-10-15 00:00:00.001")) + .check(); + assertQuery("SELECT TIMESTAMP '1582-10-01 01:01:15.555'").returns(Timestamp.valueOf("1582-10-01 01:01:15.555")) + .check(); + assertQuery("SELECT TIMESTAMP '1582-09-30 23:23:59.999'").returns(Timestamp.valueOf("1582-09-30 23:23:59.999")) + .check(); + assertQuery("SELECT TIMESTAMP '1000-01-01 23:23:59.999'").returns(Timestamp.valueOf("1000-01-01 23:23:59.999")) + .check(); + assertQuery("SELECT TIMESTAMP '0550-05-05 04:04:31.015'").returns(Timestamp.valueOf("0550-05-05 04:04:31.015")) + .check(); + + assertQuery("SELECT ?").withParams(Timestamp.valueOf("1582-10-20 17:12:47.111")) + .returns(Timestamp.valueOf("1582-10-20 17:12:47.111")).check(); + assertQuery("SELECT ?").withParams(Timestamp.valueOf("1582-10-15 00:00:00.001")) + .returns(Timestamp.valueOf("1582-10-15 00:00:00.001")).check(); + assertQuery("SELECT ?").withParams(Timestamp.valueOf("0550-05-05 04:04:31.015")) + .returns(Timestamp.valueOf("0550-05-05 04:04:31.015")).check(); + } + + /** */ + @Test + public void testOldDateLiteralsWithTable() { + assumeTrue(sqlTxMode == SqlTransactionMode.NONE); + + sql(client, "CREATE TABLE T1(ID INTEGER PRIMARY KEY, DT DATE, TS TIMESTAMP)"); + + sql(client, "INSERT INTO T1 VALUES(?, ?, ? )", 1, java.sql.Date.valueOf("1582-10-04"), + java.sql.Timestamp.valueOf("1582-10-04 15:31:47.381")); + sql(client, "INSERT INTO T1 VALUES(2, DATE '1582-10-04', TIMESTAMP '1582-10-04 15:31:47.381')"); + + assertQuery("SELECT DT from T1 WHERE ID=1").returns(java.sql.Date.valueOf("1582-10-04")).check(); + assertQuery("SELECT DT from T1 WHERE ID=2").returns(java.sql.Date.valueOf("1582-10-04")).check(); + assertQuery("SELECT DT + INTERVAL 1 DAYS from T1 WHERE ID=1").returns(java.sql.Date.valueOf("1582-10-05")) Review Comment: Yes, you are right. But the _Date_ also produces exactly '1582-10-15' with input '1582-10-05'. However, fixed with more correct variant. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org