要想spark的Scala里面可以执行
import spark.sql
val orders=sql("select * from badou.orders1")
那么就需要关联hive元数据
cp ./hive-site.xml /home/hao/Pictures/spark-2.4.3-bin-hadoop2.7/conf
cp ./core-site.xml /home/hao/Pictures/spark-2.4.3-bin-hadoop2.7/conf
cp ./hdfs-site.xml /home/hao/Pictures/spark-2.4.3-bin-hadoop2.7/conf
cp ./mysql-connector-java-8.0.14.jar /home/hao/Pictures/spark-2.4.3-bin-hadoop2.7/jars
具体的路径根据自己文件所在位置而定
本文介绍如何在Spark中使用Scala执行SQL查询,通过关联Hive元数据来访问Hive表。具体步骤包括将hive-site.xml、core-site.xml、hdfs-site.xml复制到Spark配置目录,以及将mysql-connector-java-8.0.14.jar复制到Spark的jars目录。
4583

被折叠的 条评论
为什么被折叠?



