xuzifu666 commented on code in PR #4986:
URL: https://github.com/apache/calcite/pull/4986#discussion_r3347427727


##########
core/src/test/java/org/apache/calcite/sql/parser/SqlParserUtilTest.java:
##########
@@ -94,6 +95,33 @@ public class SqlParserUtilTest {
     }
   }
 
+  @Test void testTimeWithTimeZone() {

Review Comment:
   You'd better add jira link here which show Jira this test is trying to solve.



##########
core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java:
##########
@@ -371,16 +371,24 @@ public static SqlTimeTzLiteral parseTimeTzLiteral(
       final String timeZone = s.substring(lastSpace + 1);
       final String time = s.substring(0, lastSpace);
 
-      final TimeZone tz = TimeZone.getTimeZone(timeZone);
-      if (tz != null) {
+      try {
+        ZoneId zoneId = ZoneId.of(timeZone);
+        TimeZone tz = TimeZone.getTimeZone(zoneId);
         pt =
             DateTimeUtils.parsePrecisionDateTimeLiteral(time, 
Format.get().time, tz, -1);
+      } catch (DateTimeException e) {
+        String message = e.getMessage();
+        if (message == null) {
+          message = "Error parsing TIME ZONE";

Review Comment:
   Improper capitalization => "Error parsing timezone"



##########
core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java:
##########
@@ -371,16 +371,24 @@ public static SqlTimeTzLiteral parseTimeTzLiteral(
       final String timeZone = s.substring(lastSpace + 1);
       final String time = s.substring(0, lastSpace);
 
-      final TimeZone tz = TimeZone.getTimeZone(timeZone);
-      if (tz != null) {
+      try {
+        ZoneId zoneId = ZoneId.of(timeZone);
+        TimeZone tz = TimeZone.getTimeZone(zoneId);
         pt =
             DateTimeUtils.parsePrecisionDateTimeLiteral(time, 
Format.get().time, tz, -1);
+      } catch (DateTimeException e) {
+        String message = e.getMessage();
+        if (message == null) {
+          message = "Error parsing TIME ZONE";
+        }
+        throw SqlUtil.newContextException(pos,
+            RESOURCE.illegalLiteral("TIME WITH TIME ZONE", s, message));

Review Comment:
   also here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to