成都网站建设设计

将想法与焦点和您一起共享

SparkSQL读取MySQL的dept和hive的emp表,做join和分组查询,后写到json

val jdbcDF = spark.read.format("jdbc").option("url", "jdbc:MySQL://hadoop000:3306").option("dbtable", "hive.dept").option("user", "root").option("password", "123456").load()
jdbcDF.createOrReplaceTempView("dept")
val hiveDF = sql("SELECT * FROM emp")
val sqlDF = sql("SELECT * FROM emp e JOIN dept d ON e.deptno = d.deptno").show

sqlDF.write.format("json").save("file:///empJoinDept.json")

网页标题:SparkSQL读取MySQL的dept和hive的emp表,做join和分组查询,后写到json
网站网址:http://chengdu.cdxwcx.cn/article/piehpe.html