lovasoa commented on issue #1634:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/issues/1634#issuecomment-2571399681

   > Specifically, to preserve the original SQL for error messages you could 
also keep the actual original SQL string somewhere and on error construct the 
error message using the orignal SQL (and the locations in that text that are 
now in Spans)
   
   I think there is a misunderstanding. My use case is: the user enters a 
query. I need to parse it, potentially edit the ast, and then stringify it back 
before feeding it to the database. When the database returns an error, the 
error contains position information. This position information references the 
stringified AST we fed to the database, not the original string entered by the 
user. Currently, there is no way to map that position in the output of Display 
back to a position in the original string.
   
   > As you hint in this description, trying to preserve the original 
formatting would likely be a very large undertaking (and thus I suspect 
practically infeasible given the amount of engineering we have available)
   
   That's true. If I'm the only one with that need, then it's probably not 
worth it. But maybe I'm not ? And the work does not have to be exhaustive to be 
useful. I've already done it just for respecting newlines and indentation in 
`UPDATE` statements (because the syntax is simpler than SELECT) in 
https://github.com/apache/datafusion-sqlparser-rs/pull/1636. I think improving 
upon it and doing something similar at least for newlines around keywords and 
identifier lists in SELECT .. FROM ... WHERE would already be quite useful.
   
   Regarding resources: @freshtonic , if this is useful to you, do you think 
this is something cipherstash could dedicate a few engineering hours to ? 


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