diff --git a/core/src/main/java/org/apache/calcite/util/Bug.java b/core/src/main/java/org/apache/calcite/util/Bug.java index b2f14d76efe8..df9c04eec49d 100644 --- a/core/src/main/java/org/apache/calcite/util/Bug.java +++ b/core/src/main/java/org/apache/calcite/util/Bug.java @@ -208,6 +208,12 @@ public abstract class Bug { * MILLISECOND and MICROSECOND units in INTERVAL literal is fixed. */ public static final boolean CALCITE_5422_FIXED = false; + /** Whether + * [CALCITE-5678] + * Calcite should reject date literals not satisfying Gregorian calendar, + * per SQL standard is fixed. */ + public static final boolean CALCITE_5678_FIXED = false; + /** * Use this to flag temporary code. */ 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 c1bfd6dc055d..fb3da2df5497 100644 --- a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java +++ b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java @@ -1241,8 +1241,6 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) { f.checkScalar("cast('1945-02-24 12:42:25' as TIMESTAMP)", "1945-02-24 12:42:25", "TIMESTAMP(0) NOT NULL"); - f.checkScalar("cast('1945-2-2 12:2:5' as TIMESTAMP)", - "1945-02-02 12:02:05", "TIMESTAMP(0) NOT NULL"); f.checkScalar("cast(' 1945-02-24 12:42:25 ' as TIMESTAMP)", "1945-02-24 12:42:25", "TIMESTAMP(0) NOT NULL"); f.checkScalar("cast('1945-02-24 12:42:25.34' as TIMESTAMP)", @@ -1256,6 +1254,10 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) { f.checkScalar("cast('1945-02-24 12:42:25.34' as TIMESTAMP(2))", "1945-02-24 12:42:25.34", "TIMESTAMP(2) NOT NULL"); } + if (Bug.CALCITE_5678_FIXED) { + f.checkFails("cast('1945-2-2 12:2:5' as TIMESTAMP)", + "Invalid DATE value, '1945-2-2 12:2:5'", true); + } f.checkFails("cast('nottime' as TIMESTAMP)", BAD_DATETIME_MESSAGE, true); f.checkScalar("cast('1241241' as TIMESTAMP)", "1241-01-01 00:00:00", "TIMESTAMP(0) NOT NULL");