Yicong-Huang commented on code in PR #53718:
URL: https://github.com/apache/spark/pull/53718#discussion_r2683587202


##########
python/pyspark/tests/upstream/pyarrow/test_pyarrow_type_inference.py:
##########
@@ -0,0 +1,434 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+Test pa.array type inference for various input types.
+
+This test monitors the behavior of PyArrow's type inference to ensure
+PySpark's assumptions about PyArrow behavior remain valid across versions.
+
+Test cases are organized by input category:
+1. Nullable data - None value handling
+2. Python list - Plain Python lists
+3. Python tuple - Plain Python tuples
+4. Python dict - Plain Python dicts (inferred as struct)
+5. Pandas Series (numpy-backed)
+6. Pandas nullable extension types
+7. Pandas ArrowDtype
+8. NumPy array
+9. Nested list types
+10. Explicit type specification
+"""
+
+import datetime
+import unittest
+from decimal import Decimal
+from zoneinfo import ZoneInfo
+
+from pyspark.testing.utils import (
+    have_pandas,
+    have_pyarrow,
+    pandas_requirement_message,
+    pyarrow_requirement_message,
+)
+
+
[email protected](not have_pyarrow, pyarrow_requirement_message)
+class PyArrowTypeInferenceTests(unittest.TestCase):
+    """Test PyArrow's type inference behavior for pa.array."""
+
+    # =========================================================================
+    # Helper method
+    # =========================================================================
+    def _run_inference_tests(self, cases, use_expected_as_explicit=False):
+        """Run type inference tests from a list of (name, data, expected_type) 
tuples.
+
+        If use_expected_as_explicit is True, pass expected_type as explicit 
type to pa.array().
+        """
+        import pyarrow as pa
+
+        for name, data, expected_type in cases:
+            with self.subTest(name=name):
+                if use_expected_as_explicit:
+                    arr = pa.array(data, type=expected_type)
+                else:
+                    arr = pa.array(data)
+                self.assertEqual(arr.type, expected_type, f"Failed for {name}")
+
+    # =========================================================================
+    # 1. NULLABLE DATA - Test None value handling
+    # =========================================================================
+    def test_nullable_data(self):
+        """Test type inference with nullable data (None values)."""
+        import pyarrow as pa
+
+        cases = [
+            # fmt: off

Review Comment:
   sure, I have removed `name` field and also applied the format.



##########
python/pyspark/tests/upstream/pyarrow/test_pyarrow_type_inference.py:
##########
@@ -0,0 +1,434 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+Test pa.array type inference for various input types.
+
+This test monitors the behavior of PyArrow's type inference to ensure
+PySpark's assumptions about PyArrow behavior remain valid across versions.
+
+Test cases are organized by input category:
+1. Nullable data - None value handling
+2. Python list - Plain Python lists
+3. Python tuple - Plain Python tuples
+4. Python dict - Plain Python dicts (inferred as struct)
+5. Pandas Series (numpy-backed)
+6. Pandas nullable extension types
+7. Pandas ArrowDtype
+8. NumPy array
+9. Nested list types
+10. Explicit type specification
+"""
+
+import datetime
+import unittest
+from decimal import Decimal
+from zoneinfo import ZoneInfo
+
+from pyspark.testing.utils import (
+    have_pandas,
+    have_pyarrow,
+    pandas_requirement_message,
+    pyarrow_requirement_message,
+)
+
+
[email protected](not have_pyarrow, pyarrow_requirement_message)
+class PyArrowTypeInferenceTests(unittest.TestCase):
+    """Test PyArrow's type inference behavior for pa.array."""
+
+    # =========================================================================
+    # Helper method
+    # =========================================================================
+    def _run_inference_tests(self, cases, use_expected_as_explicit=False):
+        """Run type inference tests from a list of (name, data, expected_type) 
tuples.
+
+        If use_expected_as_explicit is True, pass expected_type as explicit 
type to pa.array().
+        """
+        import pyarrow as pa
+
+        for name, data, expected_type in cases:
+            with self.subTest(name=name):

Review Comment:
   removed both!



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