Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add varchar to date conversion tests with signed year #13563

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ public void testDateLiteral()
// large year
assertInvalidFunction("DATE '5881580-07-12'", INVALID_LITERAL, "line 1:1: '5881580-07-12' is not a valid date literal");
assertInvalidFunction("DATE '392251590-07-12'", INVALID_LITERAL, "line 1:1: '392251590-07-12' is not a valid date literal");
// signed
assertFunction("DATE '+2013-02-02'", DATE, toDate(new DateTime(2013, 2, 2, 0, 0, 0, 0, UTC)));
assertFunction("DATE '-2013-02-02'", DATE, toDate(new DateTime(-2013, 2, 2, 0, 0, 0, 0, UTC)));
// signed with whitespace
assertFunction("DATE ' +2013-02-02'", DATE, toDate(new DateTime(2013, 2, 2, 0, 0, 0, 0, UTC)));
assertInvalidFunction("DATE '+ 2013-02-02'", INVALID_LITERAL, "line 1:1: '+ 2013-02-02' is not a valid date literal");
assertInvalidFunction("DATE ' + 2013-02-02'", INVALID_LITERAL, "line 1:1: ' + 2013-02-02' is not a valid date literal");
assertFunction("DATE ' -2013-02-02'", DATE, toDate(new DateTime(-2013, 2, 2, 0, 0, 0, 0, UTC)));
assertInvalidFunction("DATE '- 2013-02-02'", INVALID_LITERAL, "line 1:1: '- 2013-02-02' is not a valid date literal");
assertInvalidFunction("DATE ' - 2013-02-02'", INVALID_LITERAL, "line 1:1: ' - 2013-02-02' is not a valid date literal");
}

/**
Expand Down Expand Up @@ -314,6 +324,16 @@ public void testDateCastFromVarchar()
// large year
assertInvalidFunction("CAST('5881580-07-12' AS date)", INVALID_CAST_ARGUMENT, "Value cannot be cast to date: 5881580-07-12");
assertInvalidFunction("CAST('392251590-07-12' AS date)", INVALID_CAST_ARGUMENT, "Value cannot be cast to date: 392251590-07-12");
// signed
assertFunction("CAST('+2013-02-02' AS date)", DATE, toDate(new DateTime(2013, 2, 2, 0, 0, 0, 0, UTC)));
assertFunction("CAST('-2013-02-02' AS date)", DATE, toDate(new DateTime(-2013, 2, 2, 0, 0, 0, 0, UTC)));
// signed with whitespace
assertFunction("CAST(' +2013-02-02' AS date)", DATE, toDate(new DateTime(2013, 2, 2, 0, 0, 0, 0, UTC)));
assertInvalidFunction("CAST('+ 2013-02-02' AS date)", INVALID_CAST_ARGUMENT, "Value cannot be cast to date: + 2013-02-02");
assertInvalidFunction("CAST(' + 2013-02-02' AS date)", INVALID_CAST_ARGUMENT, "Value cannot be cast to date: + 2013-02-02");
assertFunction("CAST(' -2013-02-02' AS date)", DATE, toDate(new DateTime(-2013, 2, 2, 0, 0, 0, 0, UTC)));
assertInvalidFunction("CAST('- 2013-02-02' AS date)", INVALID_CAST_ARGUMENT, "Value cannot be cast to date: - 2013-02-02");
assertInvalidFunction("CAST(' - 2013-02-02' AS date)", INVALID_CAST_ARGUMENT, "Value cannot be cast to date: - 2013-02-02");
}

@Test
Expand Down