Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass sql file absolute path and fix for yarn-client mode #2151

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ object OpenmldbJobUtil {

def getSqlFromFile(spark: SparkSession, sqlFilePath: String): String = {
val sparkMaster = spark.conf.get("spark.master")
val sparkDeployMode = spark.conf.get("spark.submit.deployMode")

val actualSqlFilePath = if (sparkMaster.equals("local")) {
SparkFiles.get(sqlFilePath)
val actualSqlFilePath = if (sparkMaster.equalsIgnoreCase("yarn") &&
sparkDeployMode.equalsIgnoreCase("cluster")) {
sqlFilePath.split("/").last
} else {
sqlFilePath
}

println("tobe1: actualSqlFilePath: " + actualSqlFilePath)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the debug code.


if (!File(actualSqlFilePath).exists) {
throw new Exception("SQL file does not exist in " + actualSqlFilePath)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object OpenmldbBatchjobManager {
val mainClass = "com._4paradigm.openmldb.batchjob.RunBatchSql"

val tempSqlFile = SqlFileUtil.createTempSqlFile(sql)
val args = List(tempSqlFile.getName)
val args = List(tempSqlFile.getAbsolutePath)

val jobInfo = SparkJobManager.submitSparkJob(jobType, mainClass, args, tempSqlFile.getAbsolutePath,
sparkConf.asScala.toMap, defaultDb, blocking=true)
Expand All @@ -62,7 +62,7 @@ object OpenmldbBatchjobManager {
val mainClass = "com._4paradigm.openmldb.batchjob.RunBatchAndShow"

val tempSqlFile = SqlFileUtil.createTempSqlFile(sql)
val args = List(tempSqlFile.getName)
val args = List(tempSqlFile.getAbsolutePath)

SparkJobManager.submitSparkJob(jobType, mainClass, args, tempSqlFile.getAbsolutePath, sparkConf.asScala.toMap,
defaultDb)
Expand All @@ -73,7 +73,7 @@ object OpenmldbBatchjobManager {
val mainClass = "com._4paradigm.openmldb.batchjob.ImportOnlineData"

val tempSqlFile = SqlFileUtil.createTempSqlFile(sql)
val args = List(tempSqlFile.getName)
val args = List(tempSqlFile.getAbsolutePath)

SparkJobManager.submitSparkJob(jobType, mainClass, args, tempSqlFile.getAbsolutePath, sparkConf.asScala.toMap,
defaultDb)
Expand All @@ -84,7 +84,7 @@ object OpenmldbBatchjobManager {
val mainClass = "com._4paradigm.openmldb.batchjob.ImportOfflineData"

val tempSqlFile = SqlFileUtil.createTempSqlFile(sql)
val args = List(tempSqlFile.getName)
val args = List(tempSqlFile.getAbsolutePath)

SparkJobManager.submitSparkJob(jobType, mainClass, args, tempSqlFile.getAbsolutePath, sparkConf.asScala.toMap,
defaultDb)
Expand All @@ -95,7 +95,7 @@ object OpenmldbBatchjobManager {
val mainClass = "com._4paradigm.openmldb.batchjob.ExportOfflineData"

val tempSqlFile = SqlFileUtil.createTempSqlFile(sql)
val args = List(tempSqlFile.getName)
val args = List(tempSqlFile.getAbsolutePath)

SparkJobManager.submitSparkJob(jobType, mainClass, args, tempSqlFile.getAbsolutePath, sparkConf.asScala.toMap,
defaultDb)
Expand Down