You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/27 19:16:26 UTC

[GitHub] [arrow-datafusion] andygrove commented on issue #2360: Cannot group by `substr` expression

andygrove commented on issue #2360:
URL: https://github.com/apache/arrow-datafusion/issues/2360#issuecomment-1111385381

   I experiemented a bit and was able to work around it with this ugly hack in `to_arrays` only to see the same error occur later on during physical planning. I will come back to this later and review how we are generally dealing with this type of logic and find a better solution.
   
   ```
   -            let data_type = e.get_type(input.schema())?;
   +            // ugly hack for https://github.com/apache/arrow-datafusion/issues/2360
   +            let input_schema = input.schema();
   +            let data_type = match e {
   +                Expr::Sort { expr, .. } => {
   +                    let name = expr.name(input_schema.as_ref()).unwrap();
   +                    match input_schema.field_with_name(None, &name) {
   +                        Ok(x) => x.data_type().clone(),
   +                        _ => e.get_type(input_schema)?,
   +                    }
   +                }
   +                _ => e.get_type(input_schema)?
   +            };
   ```


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org