vicennial commented on code in PR #49834: URL: https://github.com/apache/spark/pull/49834#discussion_r1946219534
########## python/pyspark/sql/connect/client/core.py: ########## @@ -958,8 +958,14 @@ def to_pandas( "coerce_temporal_nanoseconds": True, } ) - pdf = renamed_table.to_pandas(**pandas_options) - pdf.columns = schema.names + # 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. Instead, we create an empty pandas + # DataFrame manually with the correct schema. + if table.num_rows == 0: + pdf = pd.DataFrame(columns=[field.name for field in schema.fields]) + else: Review Comment: Ack. I've put the `pandas_options` creations within the 'else' now -- 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