novartole commented on code in PR #2184:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2184#discussion_r2733668678
##########
src/tokenizer.rs:
##########
@@ -2577,6 +2631,39 @@ mod tests {
compare(expected, tokens);
}
+ #[test]
+ fn tokenize_iterator_map() {
+ let sql = String::from("SELECT $1");
+ let dialect = GenericDialect {};
+ let mut param_num = 1;
+
+ let tokens = Tokenizer::new(&dialect, &sql)
+ .iter()
+ .map(|token| {
+ let token = token?;
+ Ok(match token.token {
+ Token::Placeholder(n) => Token::Placeholder(if n == "?" {
+ let ret = format!("${}", param_num);
+ param_num += 1;
+ ret
+ } else {
+ n
+ }),
+ _ => token.token,
+ })
+ })
+ .collect::<Result<Vec<_>, TokenizerError>>()
+ .unwrap();
Review Comment:
Manual parsing doesn't seem to be the source of truth. I guess you mean the
following:
```suggestion
let tokens = Tokenizer::new(&dialect, &sql).tokenize().unwrap();
```
--
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]