xitep commented on issue #2065:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/issues/2065#issuecomment-3566349938

   ah, i'm sorry for being misleading :-/ i'll try to explain in more details:
   
   in my proof-of-concept program i do have a `fn find_between(&self, start: 
Location, end: Location) -> impl Iterator<Item = &CommentWithSpan>` method (i 
just added it to the proposal above) allowing me to ask for comments between 
two locations. for example between the end location of one statement (ie. the 
statement's span's end) and the beginning of the next one (the statement's 
span's start.) 
   
   ```
   -- doc for statement one
   select * from dual;
   
   -- doc for statement two
   select * from dual;
   ```
   
   this works nicely since those locations (statements' spans) are being part 
of the AST (or are going to be there in soon future.) but some tokens are 
simply _not_ part of the AST (and will likely never be), in particular a comma 
(but also many others, eg. keywords.)
   
   so, in the `select a /* one */ , /* two */ b from dual` example, i would 
fail to associate `/* one */` to `a` (and only to `a`) and/or `/* two */` to 
`b` (and only to `b`) without knowing that there was a comma between the two 
comments. Unfortunately, the AST does not contain the location of the comma 
(and/or many more keywords.) Another example would be: `SELECT ... GROUP /* 
here i am */ BY ...`
   
   Unfortunately, i can't think of a good solution at the moment. (The litmus 
test being the reproduction of the original SQL's structure including its 
comments.)


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