Problems to create DataFrame from Rows containing Option[T]

后端 未结 2 650
猫巷女王i
猫巷女王i 2021-01-22 19:27

I\'m migrating some code from Spark 1.6 to Spark 2.1 and struggling with the following issue:

This worked perfectly in Spark 1.6

import org.apache.spark.         


        
2条回答
  •  感情败类
    2021-01-22 20:04

    There is actually an JIRA SPARK-19056 about this issue which is not actually one.

    So this behavior is intentional.

    Allowing Option in Row is never documented and brings a lot of troubles when we apply the encoder framework to all typed operations. Since Spark 2.0, please use Dataset for typed operation/custom objects. e.g.

    val ds = Seq(1 -> None, 2 -> Some("str")).toDS
    ds.toDF // schema: <_1: int, _2: string>
    

提交回复
热议问题