Skip to content

Commit

Permalink
Turn off broken CAST test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
herunkang2018 committed Oct 12, 2023
1 parent efb6656 commit 1b79da9
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1255,18 +1255,27 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) {
"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);
if (castType == CastType.CAST) {
f.checkFails("cast('1945-2-2 12:2:5' as TIMESTAMP)",
"Invalid DATE value, '1945-2-2 12:2:5'", true);
f.checkFails("cast('1241241' as TIMESTAMP)",
"Invalid DATE value, '1241241'", true);
f.checkFails("cast('1945-20-24 12:42:25.34' as TIMESTAMP)",
"Invalid DATE value, '1945-20-24 12:42:25.34'", true);
f.checkFails("cast('1945-01-24 25:42:25.34' as TIMESTAMP)",
"Value of HOUR field is out of range in '1945-01-24 25:42:25.34'", true);
f.checkFails("cast('1945-1-24 12:23:34.454' as TIMESTAMP)",
"Invalid DATE value, '1945-1-24 12:23:34.454'", true);
} else {
// test cases for 'SAFE_CAST' and 'TRY_CAST'
f.checkNull("cast('1945-2-2 12:2:5' as TIMESTAMP)");
f.checkNull("cast('1241241' as TIMESTAMP)");
f.checkNull("cast('1945-20-24 12:42:25.34' as TIMESTAMP)");
f.checkNull("cast('1945-01-24 25:42:25.34' as TIMESTAMP)");
f.checkNull("cast('1945-1-24 12:23:34.454' as TIMESTAMP)");
}
}
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");
f.checkScalar("cast('1945-20-24 12:42:25.34' as TIMESTAMP)",
"1946-08-26 12:42:25", "TIMESTAMP(0) NOT NULL");
f.checkScalar("cast('1945-01-24 25:42:25.34' as TIMESTAMP)",
"1945-01-25 01:42:25", "TIMESTAMP(0) NOT NULL");
f.checkScalar("cast('1945-1-24 12:23:34.454' as TIMESTAMP)",
"1945-01-24 12:23:34", "TIMESTAMP(0) NOT NULL");

// date <-> string
f.checkCastToString("DATE '1945-02-24'", null, "1945-02-24", castType);
Expand Down

0 comments on commit 1b79da9

Please sign in to comment.