alamb opened a new issue, #9495:
URL: https://github.com/apache/arrow-datafusion/issues/9495

   ### Is your feature request related to a problem or challenge?
   
   Sometimes people want to export DataFusion expressions as SQL strings, I 
think to use in other systems (e.g. to push predicates down to postgres)
   
   Most recently this came up  in discord: 
https://discord.com/channels/885562378132000778/1166447479609376850/1215387800715919390
   
   But I am pretty sure I remember it coming up elsewhere 
   
   ### Describe the solution you'd like
   
   I would like a way to convert from `Expr` --> SQL string, something like:
   
   ```rust
   // make a > 1 expr
   let expr: Expr = col("a").gt(lit(1));
   // convert to a string
   let sql_string = to_sql(&expr, &schema)?;
   assert_eq!(sql_string, "a > 1")
   ```
   
   ### Describe alternatives you've considered
   
   I think the easiest way to do this might be to use the [`Display` impl of 
`sqlparser::AST`](https://docs.rs/sqlparser/latest/sqlparser/ast/struct.Array.html#impl-Display-for-Array)
   
   So that would look something like:
   1. write a transform of `Expr` --> `sqlparser::A
   
   ### Additional context
   
   https://github.com/apache/arrow-datafusion/issues/8661 covers the feature 
for converting entire LogicalPlans back to `Expr`
   
   https://github.com/apache/arrow-datafusion/issues/8736 covers the converse 
converting `SQL strings` to `Expr`


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

Reply via email to