zero323 commented on a change in pull request #34892:
URL: https://github.com/apache/spark/pull/34892#discussion_r769897401



##########
File path: python/pyspark/sql/functions.py
##########
@@ -1081,7 +1081,9 @@ def approx_count_distinct(col: "ColumnOrName", rsd: 
Optional[float] = None) -> C
     >>> df.agg(approx_count_distinct(df.age).alias('distinct_ages')).collect()
     [Row(distinct_ages=2)]
     """
-    sc = SparkContext._active_spark_context  # type: ignore[attr-defined]
+    sc = SparkContext._active_spark_context
+    assert sc is not None
+    assert sc._jvm is not None

Review comment:
       Nit: (I don't have strong feelings about it)  Doing this in a single 
line should work just fine and be preferable in the future:
   
   ```python
       assert sc is not None and sc._jvm is not None
   ```




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