You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/10/27 06:41:15 UTC

[GitHub] [spark] ueshin commented on a change in pull request #34389: [SPARK-37036][PYTHON] Add util function to raise advice warning for pandas API on Spark.

ueshin commented on a change in pull request #34389:
URL: https://github.com/apache/spark/pull/34389#discussion_r737151018



##########
File path: python/pyspark/pandas/utils.py
##########
@@ -958,6 +958,17 @@ def compare_allow_null(
     return left.isNull() | right.isNull() | comp(left, right)
 
 
+def log_advice(
+    message: str,
+) -> None:

Review comment:
       nit: shall we make it one liner?

##########
File path: python/pyspark/pandas/indexes/base.py
##########
@@ -488,6 +489,10 @@ def to_pandas(self) -> pd.Index:
         >>> df['dogs'].index.to_pandas()
         Index(['a', 'b', 'c', 'd'], dtype='object')
         """
+        log_advice(
+            "`to_pandas` loads all data into the driver's memory. "
+            "It should only be used if the resulting pandas Index is expected to be small."
+        )
         return self._to_internal_pandas().copy()
 
     def to_numpy(self, dtype: Optional[Union[str, Dtype]] = None, copy: bool = False) -> np.ndarray:

Review comment:
       Don't we need to show the message for to_numpy?

##########
File path: python/pyspark/pandas/frame.py
##########
@@ -4530,6 +4539,10 @@ def to_table(
         index_col: Optional[Union[str, List[str]]] = None,
         **options: Any
     ) -> None:
+        index_col is None and log_advice(  # type: ignore[func-returns-value]

Review comment:
       Why do we need the ignore?




-- 
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-unsubscribe@spark.apache.org

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



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