From c774c313a81d01c4e3e77cf296d04839c5ab04c0 Mon Sep 17 00:00:00 2001 From: Mihai Budiu Date: Mon, 12 Feb 2024 14:44:47 -0800 Subject: [PATCH] [CALCITE-6248] Illegal dates are accepted by casts Signed-off-by: Mihai Budiu --- core/src/test/java/org/apache/calcite/test/JdbcTest.java | 2 +- .../src/main/java/org/apache/calcite/test/SqlOperatorTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java index a547053462b..2edb52a93c4 100644 --- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java +++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java @@ -8203,7 +8203,7 @@ private void checkGetTimestamp(Connection con) throws SQLException { * TIMESTAMP elements. */ @Test void testArrayOfDates() { CalciteAssert.that() - .query("select array[cast('1900-1-1' as date)]") + .query("select array[cast('1900-01-01' as date)]") .returns("EXPR$0=[1900-01-01]\n"); } diff --git a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java index 047232b1d5d..2ff72a16978 100644 --- a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java +++ b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java @@ -1320,7 +1320,7 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) { f.checkCastToString("DATE '1945-2-24'", null, "1945-02-24", castType); f.checkScalar("cast('1945-02-24' as DATE)", "1945-02-24", "DATE NOT NULL"); - f.checkScalar("cast(' 1945-2-4 ' as DATE)", "1945-02-04", "DATE NOT NULL"); + f.checkScalar("cast(' 1945-02-04 ' as DATE)", "1945-02-04", "DATE NOT NULL"); f.checkScalar("cast(' 1945-02-24 ' as DATE)", "1945-02-24", "DATE NOT NULL"); if (castType == CastType.CAST) {