title: How to cache subquery result in WITH clause in Spark SQL
body: <p>I wonder if Spark SQL support caching result for the query defined in WITH clause.
  The Spark SQL query is something like this:</p>
  
  <pre><code>with base_view as
  (
   select some_columns from some_table
  WHERE 
   expensive_udf(some_column) = true
  )
  ... multiple query join based on this view
  </code></pre>
  
  <p>While this query works with Spark SQL, I noticed that the UDF were applied to the same data set multiple times. 
  In this use case, the UDF is very expensive. So I'd like to cache the query result of base_view so the subsequent queries would benefit from the cached result.</p>
  
  <p>P.S. I know you can create and cache a table with the given query and then reference it in the subqueries. In this specific case, though, I can't create any tables or views. </p>