CODERNSINGH commented on code in PR #60233:
URL: https://github.com/apache/spark/pull/60233#discussion_r4547910064
##########
python/pyspark/sql/tests/arrow/test_arrow_udtf.py:
##########
@@ -1332,6 +1332,36 @@ def terminate(self) -> Iterator["pa.Table"]:
)
assertDataFrameEqual(result_df, expected_df)
+ def test_arrow_udtf_with_partition_by_nan_values(self):
+ @arrow_udtf(returnType="n int")
+ class CountRows:
+ def __init__(self):
+ self._n = 0
+
+ def eval(self, table_data: "pa.RecordBatch") ->
Iterator["pa.Table"]:
+ self._n += table_data.num_rows
+ return iter(())
+
+ def terminate(self) -> Iterator["pa.Table"]:
+ yield pa.table({"n": pa.array([self._n], type=pa.int32())})
+
+ self.spark.udtf.register("count_rows_arrow", CountRows)
+ nan = float("nan")
+ # NaN keys must form one partition, also when nested in an array or a
struct.
+ df = self.spark.createDataFrame(
+ [(nan, 1), (nan, 2), (1.0, 3), (1.0, 4)], "k double, v int"
Review Comment:
Done. The test now runs each subtest with both the default batch size and
`spark.sql.execution.arrow.maxRecordsPerBatch=1`, so each NaN partition spans
Arrow batches and the cross-batch comparison in
`_process_arrow_batch_by_partitions` is covered.
--
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]