Github user jhu-chang commented on the pull request:

    https://github.com/apache/spark/pull/8881#issuecomment-142795137
  
    There exists a case that user needs to skip the operation after the 
```transform```, especially, the output operation like saveAsXXXFiles (e.g. 
snapshot the state of updateStateByKey in every 10 batch interval), of course, 
user can use the ```foreachRDD``` to achieve this, but needs a little more 
coding. If ```transform``` can return ```None```, it can make such usage 
easier.  
    
    About the undefined behaviors, I think ```RDD.empty``` will also introduce 
some undefined behavior here because the new RDD has no relational with the 
upstream RDD (use ```rdd.filter(_ => false)``` can avoid this), so the upstream 
RDD may be not evaluated, if this RDD in state dstream (```updateStateByKey```, 
```reduceByKeyAndWIndow```) and after some checkpoint, the state may be not 
right. And creating empty RDD needs to use spark context, the user needs to pay 
attention for this if the application recover from some checkpoint: needs a 
redirect way to get the spark context instead of using the spark context 
directly.
    
    I agree that we can avoid NullPointerException by checking NULL and 
throwing a spark exception, if we forbid the ```None```  usage, I can modify 
the PR to check NULL. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to