xinrong-meng commented on code in PR #52247:
URL: https://github.com/apache/spark/pull/52247#discussion_r2325681005


##########
python/pyspark/sql/tests/udf_type_tests/test_udf_input_types.py:
##########
@@ -115,7 +115,34 @@ def value_udf(x):
                     return x
 
                 def value_str(x):
-                    return str(x)
+                    class NpPrintable:
+                        def __init__(self, x):
+                            self.x = x
+
+                        def __repr__(self):
+                            return f"np.{self.x.dtype}({self.x.item()})"
+
+                    # Numpy 1.x __repr__ returns a different format. We only 
care about
+                    # types and values of the elements,
+                    # so we accept this difference and implement our own repr 
to make
+                    # tests with numpy 1 return the same format as numpy 2.
+                    def convert_to_numpy_printable(x):
+                        if isinstance(x, Row):
+                            return Row(
+                                **{k: convert_to_numpy_printable(v) for k, v 
in x.asDict().items()}

Review Comment:
   Does this always preserve column order?



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to