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


##########
python/pyspark/sql/connect/client/core.py:
##########
@@ -1030,37 +1031,15 @@ def to_pandas(
                 error_on_duplicated_field_names = True
                 struct_in_pandas = "dict"
 
-            # SPARK-51112: If the table is empty, we avoid using pyarrow 
to_pandas to create the
-            # DataFrame, as it may fail with a segmentation fault.
-            if table.num_rows == 0:
-                # For empty tables, create empty Series with converters to 
preserve dtypes
-                pdf = pd.concat(
-                    [
-                        _create_converter_to_pandas(
-                            field.dataType,
-                            field.nullable,
-                            timezone=timezone,
-                            struct_in_pandas=struct_in_pandas,
-                            
error_on_duplicated_field_names=error_on_duplicated_field_names,
-                        )(pd.Series([], name=temp_col_names[i], 
dtype="object"))
-                        for i, field in enumerate(schema.fields)
-                    ],
-                    axis="columns",
-                )
-            else:
-                pdf = pd.concat(
-                    [
-                        _create_converter_to_pandas(
-                            field.dataType,
-                            field.nullable,
-                            timezone=timezone,
-                            struct_in_pandas=struct_in_pandas,
-                            
error_on_duplicated_field_names=error_on_duplicated_field_names,
-                        )(arrow_col.to_pandas(**pandas_options))
-                        for arrow_col, field in zip(table.columns, 
schema.fields)
-                    ],
-                    axis="columns",
-                )
+            pdf = _convert_arrow_table_to_pandas(
+                table,
+                schema.fields,

Review Comment:
   usually yes adding the keyword is ideal. however for this case all the 
parameters are named the same as the argument. Adding the keyword would be a 
bit verbose.
   
   ```
   pdf = _convert_arrow_table_to_pandas(
       table,
       schema_fields=schema.fields,
       temp_col_names=temp_col_names,
       timezone=timezone,
       struct_in_pandas=struct_in_pandas,
       error_on_duplicated_field_names=error_on_duplicated_field_names,
       pandas_options=pandas_options,
   )
   ```



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