spark-test commented on code in PR #60581:
URL: https://github.com/apache/spark/pull/60581#discussion_r4594580317
##########
python/pyspark/sql/tests/test_udf.py:
##########
@@ -1572,6 +1581,40 @@ def test_eval_type_return_check_is_lazy(self):
},
)
+ @unittest.skipIf(
+ not have_pandas or not have_pyarrow,
+ pandas_requirement_message or pyarrow_requirement_message,
+ )
+ def test_invalid_return_type_for_arrow_and_pandas_apis(self):
+ df = self.spark.range(1)
+ grouped = df.groupBy("id")
+ cogrouped = grouped.cogroup(grouped)
+ # YearMonthIntervalType has no Arrow mapping.
Review Comment:
**Nit (P3):** Spark does have an Arrow mapping for `YearMonthIntervalType`.
The JVM's `ArrowUtils` converts it to
`ArrowType.Interval(IntervalUnit.YEAR_MONTH)` and back (`ArrowUtils.scala:116`
and `:151-152`), and PySpark's `from_arrow_type` maps Arrow's month interval
(type id 21) to it (`python/pyspark/sql/pandas/types.py:454-460`). The four
`NOT_IMPLEMENTED` cases below rely on something narrower. PySpark's
`to_arrow_type` has no case for the type, so it raises
`UNSUPPORTED_DATA_TYPE_FOR_ARROW_CONVERSION`, and `_check_return_type`
re-raises that as `NOT_IMPLEMENTED`. If the comment names that function, a
later reader knows which code these assertions depend on, for example when
someone adds the missing conversion and the assertions start failing.
```suggestion
# PySpark's to_arrow_type cannot convert YearMonthIntervalType.
```
**Verification:**
- **Inspection:** Confirm that the comment explaining why
YearMonthIntervalType drives the unsupported-type cases attributes those
failures to PySpark's Spark-to-Arrow conversion (`to_arrow_type`) lacking a
case for the type, that it no longer says the type has no Arrow mapping, and
that no test code or assertion changed.
--
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]