运维开发网

02_spark_sql

运维开发网 https://www.qedev.com 2020-10-19 12:59 出处:51CTO 作者:小小三郎1
02_spark_sql
  1. json文件

    M:192.168.249.70

    Worker:71/72   json文件要分发到worker节点

02_spark_sql

02_spark_sql

{"name":"lili","salary":3000}

{"name":"andy","salary":4000}

{"name":"tom","salary":5000}

{"name":"pipi","salary":6000}

{"name":"alice","salary":7000}

{"name":"to","salary":7000}

2.跑数据

./bin/spark-shell   --master spark://192.168.249.70:7077

 var  df =  spark.read.json("examples/employ.json")

 df.show()

02_spark_sql

3.sparksql 临时表

 var  df =  spark.read.json("examples/employ.json")

 df.show()

df.createTempView("tmp")

var  df1  = spark.sql("select * from tmp where  salary  > 5000")

df1.show()

02_spark_sql

4.

5.

6.

7.

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号