1)创建一个DataFrame
scala> val df = spark.read.json(“/opt/module/spark/examples/src/main/resources/people.json”)
df: org.apache.spark.sql.DataFrame = [age: bigint, name: string]
2)查看DataFrame的Schema信息
scala> df.printSchema
root
|– age: long (nullable = true)
|– name: string (nullable = true)
3)只查看”name”列数据
4)查看”name”列数据以及”age+1”数据
5)查看”age”大于”21”的数据
6)按照”age”分组,查看数据条数