Repository navigation
fix: preserve field metadata through arrays_zip - #7845
Draft
james-willis wants to merge 1 commit into
Draft
james-willis wants to merge 1 commit into
james-willis wants to merge 1 commit into
Conversation
james-willis
marked this pull request as ready for review
December 3, 2026 23:51
james-willis
force-pushed
the
arrays-zip-field-metadata
branch
from
December 4, 2026 07:10
9e4d7e2 to
06018b8
Compare
james-willis
marked this pull request as draft
December 4, 2026 18:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #7844
Rationale for this change
SparkArraysZipFuncbuilt the struct fields of the zipped element from each input's element type, once indata_typeand again inarrays_zip_inner, so the metadata of the inputs' item fields was lost. That includes Arrow extension types:arrays_zipover an array ofgeoarrow.wkb-tagged WKB and an array ofarrow.jsondocuments handed the JVM anarray<struct<...>>whose children were plain binary. The FFI export keeps field metadata, so the loss was in the expression.What changes are included in this PR?
SparkArraysZipFunc::fieldstakes each input's item field fromreturn_fieldand uses it whole under its Spark name, nullable as before.data_typebuilds the struct from those fields, so the defaultreturn_fieldreports the children's metadata.arrays_zip_innertakes the same fields from the input arrays' list types instead of rebuilding them from element types, so the array it returns has the typedata_typedeclares. The metadata of nested fields is part of the Arrow type, and a projection checks its output arrays against the declared type.Null-typed argument stays a nullableNullchild, as before.How are these changes tested?
New unit test
zipped_struct_keeps_the_item_fieldsinarrays_zip.rs: two list columns whose item fields carry different extension names. It checks that the children ofreturn_fieldcarry each name under the Spark names and are nullable, and that the evaluated array has exactly the declared type. The metadata assertions and the type check fail without the change.cargo test -p datafusion-comet-spark-expr,cargo clippy -p datafusion-comet-spark-expr --all-targets -- -D warningsandcargo fmt --all -- --checkpass locally.There is no new Spark SQL test because no Spark type that Comet ships carries Arrow extension metadata. The types, names and nullability of the zipped struct are unchanged, which the existing
sql-tests/expressions/array/arrays_zip.sqlcases andCometDecimalPromotionSuitecover.