Spark Rdd DataFrame操作汇总
Posted -早起的码农
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spark Rdd DataFrame操作汇总相关的知识,希望对你有一定的参考价值。
直接上测试代码:
import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.functions.udf, _
import org.junit.Assert, Test
import org.apache.spark.sql.types._
@Test
class SparkRddTest extends Assert
@Test
def testWriteRdd(): Unit =
val sparkConf = new SparkConf().setAppName("SparkTestRdd");
sparkConf.setMaster("local[*]");
val ss = SparkSession.builder.config(sparkConf).getOrCreate()
val seq = List("American Person", "Tom", "Jim")
var rdd = ss.sparkContext.makeRDD(seq)
rdd.saveAsTextFile("D:/SparkTest/rdd")
@Test
def testWriteRdd1(): Unit =
val sparkConf = new SparkConf().setAppName("SparkTestRdd");
sparkConf.setMaster("local[*]");
val ss = SparkSession.builder.config(sparkConf).getOrCreate()
val seq = List("American Person Test Spar
以上是关于Spark Rdd DataFrame操作汇总的主要内容,如果未能解决你的问题,请参考以下文章