原文件:
{"name":"Michael"}
{"name":"Andy", "age":30}
{"name":"Justin", "age":19}
java
package com.dt.sparkApps.sql;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.SQLContext;
public class DataFrameOps {
public static void main(String[] args) {
// TODO Auto-generated method stub
SparkConf conf=new SparkConf().setAppName("DataFrameOps").setMaster("local");
JavaSparkContext sc=new JavaSparkContext(conf);
SQLContext sqlContext=new SQLContext(sc);
//DataFrame df=sqlContext.read().json("hdfs://master:9000/library/people.json");
DataFrame df=sqlContext.read().json("G://IMFBigData