sunchao commented on code in PR #7381:
URL: https://github.com/apache/datafusion-comet/pull/7381#discussion_r4437121055
##########
native/spark-expr/src/struct_funcs/get_struct_field.rs:
##########
@@ -123,6 +125,20 @@ impl PhysicalExpr for GetStructField {
}
}
+/// The scalar that a one-row array holds. A list wraps the array as is:
`try_from_array` rebuilds
+/// a list's element field from its name and nullability, which drops metadata
such as a Variant
+/// element's extension type, so the scalar's type would no longer match
`data_type`.
+fn single_row_scalar(array: ArrayRef) -> DataFusionResult<ScalarValue> {
+ Ok(match array.data_type() {
+ DataType::List(_) =>
ScalarValue::List(Arc::new(array.as_list::<i32>().clone())),
+ DataType::LargeList(_) =>
ScalarValue::LargeList(Arc::new(array.as_list::<i64>().clone())),
+ DataType::FixedSizeList(_, _) => {
+
ScalarValue::FixedSizeList(Arc::new(array.as_fixed_size_list().clone()))
+ }
+ _ => ScalarValue::try_from_array(&array, 0)?,
Review Comment:
**Preserve the element field for `ListView` and `LargeListView` too.** I
evaluated `GetStructField` on a one-row `Literal(Struct)` whose list-view
element had `ARROW:extension:name` metadata. For both offset widths,
`expr.data_type()` retained the metadata but `expr.evaluate()` returned a
scalar without it. The base expression preserved it on the same input.
DataFusion 55.2 rebuilds these two views in `try_from_array` just as it does
the other list types. Wrapping their one-row arrays directly and extending the
existing metadata test to both widths would keep the declared and evaluated
types consistent. I reproduced this through the native `PhysicalExpr` API.
Spark’s standard `ArrayType` maps to `List`, and I found no Spark SQL producer
for this case.
--
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]