Skip to content

Commit 4a8380e

Browse files
committed
Add STRING to allowed first parameter of convert_tz as it returns null for malformatted date
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 9f95ae4 commit 4a8380e

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunctions.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import org.opensearch.sql.data.model.ExprValue;
7171
import org.opensearch.sql.data.type.ExprCoreType;
7272
import org.opensearch.sql.exception.ExpressionEvaluationException;
73-
import org.opensearch.sql.exception.SemanticCheckException;
7473
import org.opensearch.sql.expression.function.BuiltinFunctionName;
7574
import org.opensearch.sql.expression.function.BuiltinFunctionRepository;
7675
import org.opensearch.sql.expression.function.DefaultFunctionResolver;
@@ -1282,7 +1281,7 @@ public static ExprValue exprConvertTZ(
12821281
if (startingDateTime.type() == ExprCoreType.STRING) {
12831282
try {
12841283
startingDateTime = new ExprTimestampValue(startingDateTime.stringValue());
1285-
} catch (SemanticCheckException e) {
1284+
} catch (ExpressionEvaluationException e) {
12861285
return ExprNullValue.of();
12871286
}
12881287
}

docs/user/ppl/functions/datetime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Description
118118

119119
Usage: convert_tz(timestamp, from_timezone, to_timezone) constructs a local timestamp converted from the from_timezone to the to_timezone. CONVERT_TZ returns null when any of the three function arguments are invalid, i.e. timestamp is not in the format yyyy-MM-dd HH:mm:ss or the timeszone is not in (+/-)HH:mm. It also is invalid for invalid dates, such as February 30th and invalid timezones, which are ones outside of -13:59 and +14:00.
120120

121-
Argument type: TIMESTAMP, STRING, STRING
121+
Argument type: TIMESTAMP/STRING, STRING, STRING
122122

123123
Return type: TIMESTAMP
124124

0 commit comments

Comments
 (0)