waitingkuo commented on code in PR #5914:
URL: https://github.com/apache/arrow-datafusion/pull/5914#discussion_r1160650735


##########
datafusion/sql/src/expr/arrow_cast.rs:
##########
@@ -167,6 +167,34 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parses the next timezone
+    fn parse_timezone(&mut self, context: &str) -> Result<Option<String>> {
+        match self.next_token()? {
+            Token::None => Ok(None),
+            Token::Some => {
+                self.expect_token(Token::LParen)?;
+                let timezone = self.parse_double_quoted_string("Timezone")?;
+                self.expect_token(Token::RParen)?;
+                Ok(Some(timezone))
+            }
+            tok => Err(make_error(
+                self.val,
+                &format!("finding Timezone for {context}, got {tok}"),
+            )),
+        }
+    }
+
+    /// Parses the next double quoted string
+    fn parse_double_quoted_string(&mut self, context: &str) -> Result<String> {
+        match self.next_token()? {
+            Token::DoubleQuotedString(s) => Ok(s),
+            tok => Err(make_error(
+                self.val,
+                &format!("finding double quoted string for {context}, got 
'{tok}'"),
+            )),
+        }
+    }
+

Review Comment:
   add parser to parse the double quoted string e.g. "+00:00"



##########
datafusion/sql/src/expr/arrow_cast.rs:
##########
@@ -167,6 +167,34 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parses the next timezone
+    fn parse_timezone(&mut self, context: &str) -> Result<Option<String>> {
+        match self.next_token()? {
+            Token::None => Ok(None),
+            Token::Some => {
+                self.expect_token(Token::LParen)?;
+                let timezone = self.parse_double_quoted_string("Timezone")?;
+                self.expect_token(Token::RParen)?;
+                Ok(Some(timezone))
+            }
+            tok => Err(make_error(
+                self.val,
+                &format!("finding Timezone for {context}, got {tok}"),
+            )),
+        }
+    }

Review Comment:
   add a parser to parse timezone `Option<String>`
   either `None`, or `Some("SomeTimezone")`



-- 
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