用于将structtype转换为case类的scala宏

时间:2018-06-26 05:35:53

标签: scala generics macros case-class

我怎么定义一个scala宏来转换一个火花的结构类型,即

val foo = new StructType ()
    .add ("foo", LongType)
    .add ("bar", LongType)

到以下案例类:

MyCaseClass(foo:Long, bar:Long)

编辑

trait Schema {
    def schema: Seq[MyCol]
  }

  case class MyCol(name: String, colType: AbstractDataType, nullabilty: Boolean)

  case class FooSchema() extends Schema {
    override def schema: Seq[MyCol] = Seq(MyCol("foo", IntegerType, false), MyCol("bar", DoubleType, false))
  }

0 个答案:

没有答案