Skip to content
Merged
Show file tree
Hide file tree
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 @@ -68,7 +68,7 @@ public TimestampWithTimeZoneString(String v) {

if (pos == -1) {
throw RESOURCE.illegalLiteral("TIMESTAMP WITH LOCAL TIME ZONE", v,
RESOURCE.badFormat(TIMESTAMP_FORMAT_STRING).str()).ex();
RESOURCE.badFormat(TIMESTAMP_FORMAT_STRING + " zone").str()).ex();
}

String tsStr = v.substring(0, pos);
Expand Down
14 changes: 14 additions & 0 deletions core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3413,6 +3413,20 @@ private SqlOperator getNoDeterministicOperator() {
assertThat(timestampLTZChar1.equals(timestampLTZChar4), is(true));
}

/** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-7526">[CALCITE-7526]
* Incorrect TIMESTAMP WITH TIME ZONE produces wrong error message</a>. */
@Test void testMalformedTimezone() {
try {
new TimestampWithTimeZoneString("2011-07-20T10:34:56America/Los_Angeles");
} catch (Exception ex) {
assertThat(
ex.getMessage(), is("Illegal TIMESTAMP WITH LOCAL TIME ZONE literal "
+ "'2011-07-20T10:34:56America/Los_Angeles': not in format 'yyyy-MM-dd HH:mm:ss zone'"));
return;
}
fail("Should not be reached");
}

@Test void testSimplifyLiterals() {
final RexLiteral literalAbc = rexBuilder.makeLiteral("abc");
final RexLiteral literalDef = rexBuilder.makeLiteral("def");
Expand Down
Loading