title: How to store custom objects in Dataset?
body: <p>According to <a href="https://databricks.com/blog/2016/01/04/introducing-apache-spark-datasets.html" rel="noreferrer">Introducing Spark Datasets</a>:</p>
  
  <blockquote>
    <p>As we look forward to Spark 2.0, we plan some exciting improvements to Datasets, specifically:
    ...
    Custom encoders – while we currently autogenerate encoders for a wide variety of types, we’d like to open up an API for custom objects.</p>
  </blockquote>
  
  <p>and attempts to store custom type in a <code>Dataset</code> lead to following error like:</p>
  
  <blockquote>
    <p>Unable to find encoder for type stored in a Dataset. Primitive types (Int, String, etc) and Product types (case classes) are supported by importing sqlContext.implicits._ Support for serializing other types will be added in future releases</p>
  </blockquote>
  
  <p>or:</p>
  
  <blockquote>
    <p>Java.lang.UnsupportedOperationException: No Encoder found for ....</p>
  </blockquote>
  
  <p>Are there any existing workarounds?</p>
  
  <hr>
  
  <p>Note this question exists only as an entry point for a Community Wiki answer. Feel free to update / improve both question and answer.</p>