title: How to mock inner call to pyspark sql function
body: <p>Got the following piece of pyspark code:</p>
  
  <pre><code>import pyspark.sql.functions as F
  
  null_or_unknown_count = df.sample(0.01).filter(
      F.col('env').isNull() | (F.col('env') == 'Unknown')
  ).count()
  </code></pre>
  
  <p>In test code, the data frame is mocked, so I am trying to set the return_value for this call like this:</p>
  
  <pre><code>from unittest import mock
  from unittest.mock import ANY
  
  @mock.patch('pyspark.sql.DataFrame', spec=pyspark.sql.DataFrame)
  def test_null_or_unknown_validation(self, mock_df):
      mock_df.sample(0.01).filter(ANY).count.return_value = 250
  </code></pre>
  
  <p>But this fails with the following:</p>
  
  <pre><code>File "/usr/local/lib/python3.7/site-packages/pyspark/sql/functions.py", line 44, in _
    jc = getattr(sc._jvm.functions, name)(col._jc if isinstance(col, Column) else col)
  AttributeError: 'NoneType' object has no attribute '_jvm'
  </code></pre>
  
  <p>Also tried <code>mock_df.sample().filter().count.return_value = 250</code>, which gives the same error.</p>
  
  <p>How do I mock the filter i.e. <code>F.col('env').isNull() | (F.col('env') == 'Unknown')</code> correctly?</p>