iffyio commented on code in PR #1826: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1826#discussion_r2071613898
########## src/parser/mod.rs: ########## @@ -5199,13 +5199,20 @@ impl<'a> Parser<'a> { // parse: [ argname ] argtype let mut name = None; + let next_token = self.peek_token(); Review Comment: Ah I see that makes sense! Maybe something like this we can do to restrict the cloning to only when necessary? ```rust let data_type_idx = self.get_current_index(); if let Some(next_data_type) = self.maybe_parse(|parser| { name = parser.token_at(data_type_idx).to_string(); // ... }) ``` Coming to think about it, would we not need to sanity check that the first token is actually a `Token::Word` variant? current code seems to assume that to be the case which might not necessarily be true. For example following how the following sql would be parsed, we can probably have a test case it ```rust function(struct<a,b> int64) ``` we would call `to_string()` on only the first token which would be `struct` even though this query is technically invalid? -- 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-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org