通过java进程构建工具直接执行hive sql 提交MR任务
import java.io.{BufferedReader, InputStreamReader}
import org.apache.spark.Logging
object CommandExecutor extends Logging with Serializable {
def hiveCommand(sql: String): Unit = {
import java.io.BufferedReader
import java.util
val command = new util.ArrayList[String]
command.add("hive")
command.add("-e")
command.add(sql)
val hiveProcessBuilder = new ProcessBuilder(command)
val br = new BufferedReader(new InputStreamReader(hiveProcessBuilder.start.getInputStream))
br.readLine()
}
}
// hiveContext.sql(output_ftp_sql)
// logError("hive -e " + output_ftp_sql)
// try {
// val exitValue = Process("nohup /usr/local/bin/hive -e " + output_ftp_sql).!
// if (0 != exitValue) {
// logError("call shell failed. error code is :" + exitValue);
// }
// } catch {
// case e: Exception => {
// logError("call shell failed. " + e);
// }
// }