grorge123 opened a new pull request, #7381: URL: https://github.com/apache/datafusion-comet/pull/7381
## Which issue does this PR close? Closes #7380. ## Rationale for this change When the input of `GetStructField` is a scalar struct, the native kernel returns the field as a one-row array. Beside a column, that array does not match the batch's row count and the query fails. The scalar arm has done this since the expression was added, but a scalar struct rarely reached it until #5452 made `CreateNamedStruct` return a scalar when every field value is a scalar. A DataFusion scalar UDF would have its one-row result turned back into a scalar by `ScalarFunctionExpr`, but `GetStructField` is a `PhysicalExpr` and gets no such conversion. Split out of #5526. ## What changes are included in this PR? `GetStructField` returns a scalar when its input is a scalar struct. The field still goes through `child_with_parent_nulls`, so the field of a null struct is null. A list field is wrapped as a list scalar directly rather than through `ScalarValue::try_from_array`, which rebuilds the element field without its metadata (such as a Variant element's extension type), so the scalar's type would no longer match the declared type. ## How are these changes tested? - A query at the end of `struct/get_struct_field.sql` reads a field of a cast `named_struct` over a scalar subquery, once with a value and once with NULL, over four rows in one batch. It fails on `main` with `Array length 1 does not match expected length 4`. - Rust unit tests evaluate `GetStructField` over a scalar struct and check that it returns a scalar, for a present struct, a null struct, and a null struct whose child still holds a value, and for a typed and a Null-typed field. Another checks that a list field whose element field carries metadata keeps the declared type. Each test fails without its part of the fix. Assisted-by: Claude Code (claude-opus-5-5) -- 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]
