Creating a Spark DataFrame from a single string

后端 未结 1 903
小鲜肉
小鲜肉 2021-01-12 15:01

I\'m trying to take a hardcoded String and turn it into a 1-row Spark DataFrame (with a single column of type StringType) such that:

String fizz         


        
相关标签:
1条回答
  • 2021-01-12 15:39

    Try:

    sqlContext.sparkContext.parallelize(rawData).toDF()
    

    In 2.0 you can:

    import spark.implicits._
    
    rawData.toDF
    

    Optionally provide a sequence of names for toDF:

    sqlContext.sparkContext.parallelize(rawData).toDF("fizz")
    
    0 讨论(0)
提交回复
热议问题