How to convert List to JavaRDD

前端 未结 4 778
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-11 15:54

We know that in spark there is a method rdd.collect which converts RDD to a list.

List f= rdd.collect();
String[] array = f.toArray(new String[f.si         


        
4条回答
  •  野性不改
    2021-02-11 16:33

    List fields = new ArrayList<>();
    fields.add(DataTypes.createStructField("fieldx1", DataTypes.StringType, true));
    fields.add(DataTypes.createStructField("fieldx2", DataTypes.StringType, true));
    fields.add(DataTypes.createStructField("fieldx3", DataTypes.LongType, true));
    
    
    List data = new ArrayList<>();
    data.add(RowFactory.create("","",""));
    Dataset rawDataSet = spark.createDataFrame(data, schema).toDF();
    

提交回复
热议问题