重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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")