Yicong-Huang opened a new pull request, #54295:
URL: https://github.com/apache/spark/pull/54295

   ### What changes were proposed in this pull request?
   
   Add `field.metadata is not None` check in `is_geometry()` and 
`is_geography()` before accessing `field.metadata` with the `in` operator.
   
   ### Why are the changes needed?
   
   PyArrow struct fields have `metadata=None` by default. When 
`from_arrow_type()` encounters a struct with a field named `wkb` that has no 
metadata, `is_geometry()` / `is_geography()` crash with `TypeError: argument of 
type 'NoneType' is not iterable` because the code does `b"geometry" in 
field.metadata` without checking for `None` first.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No
   
   ### How was this patch tested?
   
   Added `test_from_arrow_type_struct_with_wkb_field_no_metadata` in 
`test_arrow.py` that constructs a PyArrow struct with `wkb` and `srid` fields 
without metadata, and verifies `from_arrow_type()` returns a `StructType` 
without crashing.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No


-- 
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]

Reply via email to