使用Spark-shell怎么批量命令执行脚本

使用Spark-shell怎么批量命令执行脚本

这篇文章给大家介绍使用Spark-shell怎么批量命令执行脚本,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

批量执行spark-shell命令,并指定提交参数

#!/bin/bash

source /etc/profile

exec $SPARK_HOME/bin/spark-shell --queue tv --name spark-sql-test --executor-cores 8 --executor-memory 8g --num-executors 8 --conf spark.cleaner.ttl=240000 <<!EOF
import org.apache.spark.sql.SaveMode
sql("set hive.exec.dynamic.partition=true")
sql("set hive.exec.dynamic.partition.mode=nonstrict")
sql("use hr")
sql("SELECT * FROM t_abc ").rdd.saveAsTextFile("/tmp/out") 
sql("SELECT * FROM t_abc").rdd.map(_.toString).intersection(sc.textFile("/user/hdfs/t2_abc").map(_.toString).distinct).count
!EOF

关于使用Spark-shell怎么批量命令执行脚本就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。