Omega359 commented on issue #18278:
URL: https://github.com/apache/datafusion/issues/18278#issuecomment-3469325915
I think just a single additional function should work that accepts a
`SQLExprWithAlias`
I would think it would basically be this:
```Rust
/// Creates a datafusion style AST [`Expr`] from a SQL string.
///
/// See example on
[SessionContext::parse_sql_expr](crate::execution::context::SessionContext::parse_sql_expr)
#[cfg(feature = "sql")]
pub fn create_logical_expr(
&self,
sql: &str,
df_schema: &DFSchema,
) -> datafusion_common::Result<Expr> {
let dialect = self.config.options().sql_parser.dialect;
let sql_expr = self.sql_to_expr_with_alias(sql, &dialect)?;
self.create_logical_expr_from_sql_expr(sql_expr, df_schema)
}
/// Creates a datafusion style AST [`Expr`] from a SQL string.
///
/// See example on
[SessionContext::parse_sql_expr](crate::execution::context::SessionContext::parse_sql_expr)
#[cfg(feature = "sql")]
pub fn create_logical_expr_from_sql_expr(
&self,
sql_expr: SQLExprWithAlias,
df_schema: &DFSchema,
) -> datafusion_common::Result<Expr> {
let provider = SessionContextProvider {
state: self,
tables: HashMap::new(),
};
let query = SqlToRel::new_with_options(&provider,
self.get_parser_options());
query.sql_to_expr_with_alias(sql_expr, df_schema, &mut
PlannerContext::new())
}
```
--
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]