一篇好博客:https://blog.youkuaiyun.com/xwc35047/article/details/53933265
找不到hive表:
报错:org.apache.spark.sql.AnalysisException: Table or view not found
解决方法:在spark配置中加入hive-site.xml的路径
–files ${HIVE_SITE_PATH}
spark要查找hive中的数据,需要这个配置文件,里面是hive的一些信息。
spark作业jar包冲突:
可以在submit-spark时使用如下配置:
–conf spark.yarn.user.classpath.first=“true”
和
–jars xxxxxxx,xxxxxxx
这个设置是优先使用用户提交的jar,在遇到冲突时默认先使用用户提交的jar包,这样就可以屏蔽公共jar包了。(尤其适合公司使用)
spark dataframe存储数据:
spark.sql(sql4).coalesce(coalesce.toInt)
.write
.mode(SaveMode.Overwrite)
.option(“orc.compress”, “zlib”)
.orc(output)
存储数据时文件夹已存在:
报错:User class threw exception: org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory s3://xxxx/xxxx/test_mydata1 already exists
解决方法:
import java.net.URI
import org.apache.hadoop.fs.{FileSystem, Path}
FileSystem.get(new URI(s"s3://mob-emr-test"), spark.sparkContext.hadoopConfiguration).delete(new Path(output), true)