title: How to define schema for custom type in Spark SQL?
body: <p>The following example code tries to put some case objects into a dataframe. The code includes the definition of a case object hierarchy and a case class using this trait:</p>
  
  <pre><code>import org.apache.spark.{SparkContext, SparkConf}
  import org.apache.spark.sql.SQLContext
  
  sealed trait Some
  case object AType extends Some
  case object BType extends Some
  
  case class Data( name : String, t: Some)
  
  object Example {
    def main(args: Array[String]) : Unit = {
      val conf = new SparkConf()
        .setAppName( "Example" )
        .setMaster( "local[*]")
  
      val sc = new SparkContext(conf)
      val sqlContext = new SQLContext(sc)
  
      import sqlContext.implicits._
  
      val df = sc.parallelize( Seq( Data( "a", AType), Data( "b", BType) ), 4).toDF()
      df.show()
    }
  }    
  </code></pre>
  
  <p>When executing the code, I unfortunately encounter the following exception:</p>
  
  <pre><code>java.lang.UnsupportedOperationException: Schema for type Some is not supported
  </code></pre>
  
  <h2>Questions</h2>
  
  <ul>
  <li>Is there a possibility to add or define a schema for certain types (here type <code>Some</code>)?</li>
  <li>Does another approach exist to represent this kind of enumerations? 
  
  <ul>
  <li>I tried to use <code>Enumeration</code> directly, but also without success. (see below)</li>
  </ul></li>
  </ul>
  
  <p>Code for <code>Enumeration</code>:</p>
  
  <pre><code>object Some extends Enumeration {
    type Some = Value
    val AType, BType = Value
  }
  </code></pre>
  
  <p>Thanks in advance. I hope, that the best approach is not to use strings instead.</p>