Blizzara commented on code in PR #731:
URL: https://github.com/apache/datafusion-comet/pull/731#discussion_r1694873288
##########
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:
FWIW, if it's possible to implement these as ScalarUDFImpl instead of
PhysicalExpr, that makes reusing them elsewhere easier (at least for me, but
maybe for otheres too, since I think going from ScalarUDF -> PhysicalExpr is
easier than the other way around) :)
--
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]