You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "waitingkuo (via GitHub)" <gi...@apache.org> on 2023/04/07 11:53:07 UTC

[GitHub] [arrow-datafusion] waitingkuo commented on a diff in pull request #5914: arrow_cast to cast to timestamptz

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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org