andygrove commented on code in PR #731: URL: https://github.com/apache/datafusion-comet/pull/731#discussion_r1695452495
########## native/spark-expr/src/structs.rs: ########## @@ -125,3 +125,103 @@ impl PartialEq<dyn Any> for CreateNamedStruct { .unwrap_or(false) } } + +#[derive(Debug, Hash)] +pub struct GetStructField { + child: Arc<dyn PhysicalExpr>, + ordinal: usize, +} + +impl GetStructField { + pub fn new(child: Arc<dyn PhysicalExpr>, ordinal: usize) -> Self { + Self { child, ordinal } + } + + fn child_field(&self, input_schema: &Schema) -> DataFusionResult<Arc<Field>> { + match self.child.data_type(input_schema)? { + DataType::Struct(fields) => Ok(fields[self.ordinal].clone()), + data_type => Err(DataFusionError::Plan(format!( + "Expect struct field, got {:?}", + data_type + ))), + } + } +} + +impl PhysicalExpr for GetStructField { Review Comment: I agree that we should start implementing functions as ScalarUDFImpl instead of PhysicalExpr. I think it would be fine to convert this one as a follow on PR. -- 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-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org