iffyio commented on code in PR #2223:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2223#discussion_r2882554040


##########
src/parser/mod.rs:
##########
@@ -12309,7 +12309,7 @@ impl<'a> Parser<'a> {
     }
 
     /// Optionally parses an alias for a select list item
-    fn maybe_parse_select_item_alias(&mut self) -> Result<Option<Ident>, 
ParserError> {
+    pub fn maybe_parse_select_item_alias(&mut self) -> Result<Option<Ident>, 
ParserError> {

Review Comment:
   ```suggestion
       pub(crate) fn maybe_parse_select_item_alias(&mut self) -> 
Result<Option<Ident>, ParserError> {
   ```



##########
src/dialect/snowflake.rs:
##########
@@ -1503,29 +1502,21 @@ fn parse_select_item_for_data_load(
         }?;
     }
 
-    // try extracting optional element
-    match parser.next_token().token {
-        Token::Colon => {
-            // parse element
-            element = Some(Ident::new(match parser.next_token().token {
-                Token::Word(w) => Ok(w.value),
-                _ => parser.expected_ref("file_col_num", 
parser.peek_token_ref()),
-            }?));
-        }
-        _ => {
-            // element not present move back
-            parser.prev_token();
+    // try extracting optional element path (e.g. :UsageMetrics:hh)
+    let mut elements = Vec::new();
+    while parser.next_token().token == Token::Colon {
+        match parser.next_token().token {
+            Token::Word(w) => elements.push(Ident::new(w.value)),
+            _ => return parser.expected_ref("element name", 
parser.peek_token_ref()),
         }
     }
-
-    // as
-    if parser.parse_keyword(Keyword::AS) {
-        item_as = Some(match parser.next_token().token {
-            Token::Word(w) => Ok(Ident::new(w.value)),
-            _ => parser.expected_ref("column item alias", 
parser.peek_token_ref()),
-        }?);
+    parser.prev_token();

Review Comment:
   would it be possible to rewrite the code so that it `peeks` the expected 
`Token::Colon` before entering the loop? if that would let us avoid this call 
to `prev_token()`



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to