From 25031b053bdc2767f9285466f11926b419abd96c Mon Sep 17 00:00:00 2001 From: yanxiangqin <54396288+everypp@users.noreply.github.com> Date: Tue, 9 Jan 2024 16:33:27 +0800 Subject: [PATCH] Fix cast time tz exception message Fix cast time tz exception message --- .../scalar/timetz/VarcharToTimeWithTimeZoneCast.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/operator/scalar/timetz/VarcharToTimeWithTimeZoneCast.java b/core/trino-main/src/main/java/io/trino/operator/scalar/timetz/VarcharToTimeWithTimeZoneCast.java index b778ef6135ac..17f6a3956803 100644 --- a/core/trino-main/src/main/java/io/trino/operator/scalar/timetz/VarcharToTimeWithTimeZoneCast.java +++ b/core/trino-main/src/main/java/io/trino/operator/scalar/timetz/VarcharToTimeWithTimeZoneCast.java @@ -51,11 +51,11 @@ private VarcharToTimeWithTimeZoneCast() {} @SqlType("time(p) with time zone") public static long castToShort(@LiteralParameter("p") long precision, ConnectorSession session, @SqlType("varchar(x)") Slice value) { - checkArgument((int) precision <= MAX_SHORT_PRECISION, "precision must be less than max short timestamp precision"); + checkArgument((int) precision <= MAX_SHORT_PRECISION, "precision must be less than max short time with time zone precision"); Matcher matcher = DateTimes.TIME_PATTERN.matcher(trim(value).toStringUtf8()); if (!matcher.matches()) { - throw new TrinoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to timestamp: " + value.toStringUtf8()); + throw new TrinoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to time with time zone: " + value.toStringUtf8()); } try { @@ -67,7 +67,7 @@ public static long castToShort(@LiteralParameter("p") long precision, ConnectorS return packTimeWithTimeZone(nanos, offsetMinutes); } catch (IllegalArgumentException e) { - throw new TrinoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to timestamp: " + value.toStringUtf8(), e); + throw new TrinoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to time with time zone: " + value.toStringUtf8(), e); } } @@ -79,7 +79,7 @@ public static LongTimeWithTimeZone castToLong(@LiteralParameter("p") long precis Matcher matcher = DateTimes.TIME_PATTERN.matcher(trim(value).toStringUtf8()); if (!matcher.matches()) { - throw new TrinoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to timestamp: " + value.toStringUtf8()); + throw new TrinoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to time with time zone: " + value.toStringUtf8()); } try { @@ -91,7 +91,7 @@ public static LongTimeWithTimeZone castToLong(@LiteralParameter("p") long precis return new LongTimeWithTimeZone(picos, offsetMinutes); } catch (IllegalArgumentException e) { - throw new TrinoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to timestamp: " + value.toStringUtf8(), e); + throw new TrinoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to time with time zone: " + value.toStringUtf8(), e); } }