alamb commented on code in PR #10183:
URL: https://github.com/apache/datafusion/pull/10183#discussion_r1575378141
##########
datafusion-examples/examples/expr_api.rs:
##########
@@ -248,18 +296,35 @@ fn make_ts_field(name: &str) -> Field {
make_field(name, DataType::Timestamp(TimeUnit::Nanosecond, tz))
}
-/// Build a physical expression from a logical one, after applying
simplification and type coercion
+/// Build a physical expression from a logical one, after applying
+/// simplification, type coercion, and applying function rewrites
pub fn physical_expr(schema: &Schema, expr: Expr) -> Result<Arc<dyn
PhysicalExpr>> {
let df_schema = schema.clone().to_dfschema_ref()?;
- // Simplify
+ // register the standard DataFusion function library
let props = ExecutionProps::new();
let simplifier =
ExprSimplifier::new(SimplifyContext::new(&props).with_schema(df_schema.clone()));
// apply type coercion here to ensure types match
let expr = simplifier.coerce(expr, df_schema.clone())?;
+ // Support Expr::struct by rewriting expressions
+ let expr = expr
+ .transform_up(&|expr| {
+ Ok(match expr {
+ Expr::GetIndexedField(GetIndexedField {
Review Comment:
This basically inlines the necessary code from
https://github.com/apache/datafusion/blob/95607325410d6bdd4461c66b1e6ffe01fcbd736f/datafusion/functions-array/src/rewrite.rs#L151-L157
--
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]